master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
26#if defined(_WIN32) || defined(MSDOS)
27#include "tool_cfgable.h"
28#include "tool_doswin.h"
30static void getflagstr(char *buf, size_t len, int flags)
31{
32 curl_msnprintf(buf, len, "%s,%s",
33 ((flags & SANITIZE_ALLOW_PATH) ?
34 "SANITIZE_ALLOW_PATH" : ""),
35 ((flags & SANITIZE_ALLOW_RESERVED) ?
36 "SANITIZE_ALLOW_RESERVED" : ""));
37}
39static void getcurlcodestr(char *buf, size_t len, int cc)
40{
41 curl_msnprintf(buf, len, "%s (%d)",
42 (cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
43 cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
44 cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" :
45 cc == SANITIZE_ERR_OUT_OF_MEMORY ? "SANITIZE_ERR_OUT_OF_MEMORY" :
46 "unexpected error code - add name"), cc);
47}
48#endif
50static CURLcode test_tool1604(const char *arg)
51{
52 UNITTEST_BEGIN_SIMPLE
54#if defined(_WIN32) || defined(MSDOS)
55 struct data {
56 const char *input;
57 int flags;
58 const char *expected_output;
59 SANITIZEcode expected_result;
60 };
62 /* START sanitize_file_name */
63 struct data data[] = {
64 { "", 0,
65 "", SANITIZE_ERR_OK
66 },
67 { "normal filename", 0,
68 "normal filename", SANITIZE_ERR_OK
69 },
70 { "control\tchar", 0,
71 "control_char", SANITIZE_ERR_OK
72 },
73 { "banned*char", 0,
74 "banned_char", SANITIZE_ERR_OK
75 },
76 { "f:foo", 0,
77 "f_foo", SANITIZE_ERR_OK
78 },
79 { "f:foo", SANITIZE_ALLOW_PATH,
80 "f:foo", SANITIZE_ERR_OK
81 },
82 { "f:\\foo", 0,
83 "f__foo", SANITIZE_ERR_OK
84 },
85 { "f:\\foo", SANITIZE_ALLOW_PATH,
86 "f:\\foo", SANITIZE_ERR_OK
87 },
88 { "f:/foo", 0,
89 "f__foo", SANITIZE_ERR_OK
90 },
91 { "f:/foo", SANITIZE_ALLOW_PATH,
92 "f:/foo", SANITIZE_ERR_OK
93 },
94#ifndef MSDOS
95 { "\\\\?\\C:\\foo", SANITIZE_ALLOW_PATH,
96 "\\\\?\\C:\\foo", SANITIZE_ERR_OK
97 },
98 { "\\\\?\\C:\\foo", 0,
99 "____C__foo", SANITIZE_ERR_OK
100 },
101#endif
102 { "foo:bar", 0,
103 "foo_bar", SANITIZE_ERR_OK
104 },
105 { "foo|<>/bar\\\":?*baz", 0,
106 "foo____bar_____baz", SANITIZE_ERR_OK
107 },
108 { "f:foo::$DATA", 0,
109 "f_foo__$DATA", SANITIZE_ERR_OK
110 },
111 { "con . air", 0,
112 "con _ air", SANITIZE_ERR_OK
113 },
114 { "con.air", 0,
115 "con_air", SANITIZE_ERR_OK
116 },
117 { "con:/x", 0,
118 "con__x", SANITIZE_ERR_OK
119 },
120 { "file . . . . .. .", 0,
121 "file", SANITIZE_ERR_OK
122 },
123 { "foo . . ? . . ", 0,
124 "foo . . _", SANITIZE_ERR_OK
125 },
126 { "com1", 0,
127 "_com1", SANITIZE_ERR_OK
128 },
129 { "com4", 0,
130 "_com4", SANITIZE_ERR_OK
131 },
132 { "com6", 0,
133 "_com6", SANITIZE_ERR_OK
134 },
135 { "com9", 0,
136 "_com9", SANITIZE_ERR_OK
137 },
138 { "com1", SANITIZE_ALLOW_RESERVED,
139 "com1", SANITIZE_ERR_OK
140 },
141 { "f:\\com1", 0,
142 "f__com1", SANITIZE_ERR_OK
143 },
144 { "f:\\com1", SANITIZE_ALLOW_PATH,
145 "f:\\_com1", SANITIZE_ERR_OK
146 },
147 { "f:\\com1", SANITIZE_ALLOW_RESERVED,
148 "f__com1", SANITIZE_ERR_OK
149 },
150 { "f:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_PATH,
151 "f:\\com1", SANITIZE_ERR_OK
152 },
153 { "com1:\\com1", SANITIZE_ALLOW_PATH,
154 "_com1:\\_com1", SANITIZE_ERR_OK
155 },
156 { "com1:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_PATH,
157 "com1:\\com1", SANITIZE_ERR_OK
158 },
159 { "com1:\\com1", SANITIZE_ALLOW_RESERVED,
160 "com1__com1", SANITIZE_ERR_OK
161 },
162#ifndef MSDOS
163 { "\\com1", SANITIZE_ALLOW_PATH,
164 "\\_com1", SANITIZE_ERR_OK
165 },
166 { "\\\\com1", SANITIZE_ALLOW_PATH,
167 "\\\\com1", SANITIZE_ERR_OK
168 },
169 { "\\\\?\\C:\\com1", SANITIZE_ALLOW_PATH,
170 "\\\\?\\C:\\com1", SANITIZE_ERR_OK
171 },
172#endif
173 { "CoM1", 0,
174 "_CoM1", SANITIZE_ERR_OK
175 },
176 { "CoM1", SANITIZE_ALLOW_RESERVED,
177 "CoM1", SANITIZE_ERR_OK
178 },
179 { "COM56", 0,
180 "COM56", SANITIZE_ERR_OK
181 },
182 { "COM\xc2\xb9", 0,
183 "_COM\xc2\xb9", SANITIZE_ERR_OK
184 },
185 { "COM\xc2\xb2", 0,
186 "_COM\xc2\xb2", SANITIZE_ERR_OK
187 },
188 { "COM\xc2\xb3", 0,
189 "_COM\xc2\xb3", SANITIZE_ERR_OK
190 },
191 { "COM\xb9", 0,
192 "_COM\xb9", SANITIZE_ERR_OK
193 },
194 { "COM\xb2", 0,
195 "_COM\xb2", SANITIZE_ERR_OK
196 },
197 { "COM\xb3", 0,
198 "_COM\xb3", SANITIZE_ERR_OK
199 },
200 { "lpt\xc2\xb9", 0,
201 "_lpt\xc2\xb9", SANITIZE_ERR_OK
202 },
203 { "lpt\xc2\xb2", 0,
204 "_lpt\xc2\xb2", SANITIZE_ERR_OK
205 },
206 { "lpt\xc2\xb3", 0,
207 "_lpt\xc2\xb3", SANITIZE_ERR_OK
208 },
209 { "lpt\xc2\xb9.txt", 0,
210 "lpt\xc2\xb9_txt", SANITIZE_ERR_OK
211 },
212 { "lpt\xc2\xb2.txt", 0,
213 "lpt\xc2\xb2_txt", SANITIZE_ERR_OK
214 },
215 { "lpt\xc2\xb3.txt", 0,
216 "lpt\xc2\xb3_txt", SANITIZE_ERR_OK
217 },
218 { "COM\xc2\xb3", SANITIZE_ALLOW_RESERVED,
219 "COM\xc2\xb3", SANITIZE_ERR_OK
220 },
221 { NULL, 0,
222 NULL, SANITIZE_ERR_BAD_ARGUMENT
223 },
224 };
226 size_t i;
228 for(i = 0; i < CURL_ARRAYSIZE(data); ++i) {
229 char *output = NULL;
230 char flagstr[256];
231 char receivedstr[256];
232 char expectedstr[256];
233 const char *flg = flagstr;
234 const char *rec = receivedstr;
235 const char *exp = expectedstr;
236 SANITIZEcode res;
238 res = sanitize_file_name(&output, data[i].input, data[i].flags);
240 if(res == data[i].expected_result &&
241 ((!output && !data[i].expected_output) ||
242 (output && data[i].expected_output &&
243 !strcmp(output, data[i].expected_output)))) { /* OK */
244 curlx_free(output);
245 continue;
246 }
248 getflagstr(flagstr, sizeof(flagstr), data[i].flags);
249 abort_unless(flg, "out of memory");
250 getcurlcodestr(receivedstr, sizeof(receivedstr), res);
251 abort_unless(rec, "out of memory");
252 getcurlcodestr(expectedstr, sizeof(expectedstr), data[i].expected_result);
253 abort_unless(exp, "out of memory");
255 unitfail++;
256 curl_mfprintf(stderr, "\n"
257 "%s:%d sanitize_file_name failed.\n"
258 "input: %s\n"
259 "flags: %s\n"
260 "output: %s\n"
261 "result: %s\n"
262 "expected output: %s\n"
263 "expected result: %s\n",
264 __FILE__, __LINE__,
265 data[i].input,
266 flagstr,
267 output ? output : "(null)",
268 receivedstr,
269 data[i].expected_output ? data[i].expected_output : "(null)",
270 expectedstr);
272 curlx_free(output);
273 }
274 /* END sanitize_file_name */
275#else
276 curl_mfprintf(stderr, "Skipped test not for this platform\n");
277#endif /* _WIN32 || MSDOS */
279 UNITTEST_END_SIMPLE
280}
Diagnostics4 git calls · 48 ms
CallStatusSizeTime048 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit24 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=24 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2002.1 KiB · hit22 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=22 git.response.bytes=2111 git.response.cache=HIT git.response.duration_ms=22 git.fetch.wants=80050b35236e03d8fab3bd4ab2bed0ef754f52d4 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2111 git.pkt.payload.max=2090 git.sideband.band1.bytes=2089 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e302d84aef7929
- Request
- 35521cde…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format