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"
26static CURLcode test_unit1395(const char *arg)
27{
28 UNITTEST_BEGIN_SIMPLE
30 unsigned int i;
31 int fails = 0;
33 struct dotdot {
34 const char *input;
35 const char *output;
36 };
38 static const struct dotdot pairs[] = {
39 { "/%2f%2e%2e%2f/../a", "/a" },
40 { "/%2f%2e%2e%2f/../", "/" },
41 { "/%2f%2e%2e%2f/.", "/%2f%2e%2e%2f/" },
42 { "/%2f%2e%2e%2f/", NULL },
43 { "/%2f%2e%2e%2f", NULL },
44 { "/%2f%2e%2e%2", NULL },
45 { "/%2f%2e%2e%", NULL },
46 { "/%2f%2e%2e", "/%2f%2e%2e" },
47 { "/%2f%2e%2", NULL },
48 { "/%2f%2e%", NULL },
49 { "/%2f%2e", "/%2f%2e" },
50 { "/%2f%2", NULL },
51 { "/%2f%", NULL },
52 { "/%2f", NULL },
53 { "/%2", NULL },
54 { "%2f%2e%2e%2f/../a", "%2f%2e%2e%2f/a" },
55 { "%2f%2e%2e%2f/../", "%2f%2e%2e%2f/" },
56 { "%2f%2e%2e%2f/.", "%2f%2e%2e%2f/" },
57 { "%2f%2e%2e%2f/", NULL },
58 { "%2f%2e%2e%2f", NULL },
59 { "%2f%2e%2e%2", NULL },
60 { "%2f%2e%2e%", NULL },
61 { "%2f%2e%2e", "%2f%2e%2e" },
62 { "%2f%2e%2", NULL },
63 { "%2f%2e%", NULL },
64 { "%2f%2e", "%2f%2e" },
65 { "%2f%2", NULL },
66 { "%2f%", NULL },
67 { "%2f", NULL },
68 { "%2", NULL },
69 { "%", NULL },
70 { "2", NULL },
71 { "e", NULL },
72 { ".", NULL },
73 { "./", "" },
74 { "..", "" },
75 { "../", "" },
76 { "../a", "a" },
77 { "///moo.", "///moo." },
78 { ".///moo.", "//moo." },
79 { "./moo..", "moo.." },
80 { "./moo../", "moo../" },
81 { "./moo../.m", "moo../.m" },
82 { "./moo", "moo" },
83 { "../moo", "moo" },
84 { "../moo?", "moo?" },
85 { "../moo?#", "moo?#" },
86 { "../moo?#?..", "moo?#?.." },
87 { "/../moo/..", "/" },
88 { "/a/c/%2e%2E/b", "/a/b" },
89 { "/a/%2e/g", "/a/g" },
90 { "/a/b/c/./g", "/a/b/c/g" },
91 { "/a/c/../b", "/a/b" },
92 { "/a/b/c/./../../g", "/a/g" },
93 { "/a/b/c/./%2e%2E/../g", "/a/g" },
94 { "/a/b/c/./../%2e%2E/g", "/a/g" },
95 { "/a/b/c/%2E/%2e%2E/%2e%2E/g", "/a/g" },
96 { "mid/content=5/../6", "mid/6" },
97 { "/hello/../moo", "/moo" },
98 { "/1/../1", "/1" },
99 { "/1/./1", "/1/1" },
100 { "/1/%2e/1", "/1/1" },
101 { "/1/%2E/1", "/1/1" },
102 { "/1/..", "/" },
103 { "/1/.", "/1/" },
104 { "/1/%2e", "/1/" },
105 { "/1/%2E", "/1/" },
106 { "/1/./..", "/" },
107 { "/1/%2e/.%2E", "/" },
108 { "/1/./%2e.", "/" },
109 { "/1/./../2", "/2" },
110 { "/hello/1/./../2", "/hello/2" },
111 { "test/this", NULL },
112 { "test/this/../now", "test/now" },
113 { "/1../moo../foo", "/1../moo../foo" },
114 { "/../../moo", "/moo" },
115 { "/../../moo?", "/moo?" },
116 { "/123?", NULL },
117 { "/", NULL },
118 { "", NULL },
119 { "/.../", "/.../" },
120 { "/.", "/" },
121 { "/..", "/" },
122 { "/moo/..", "/" },
123 { "/..", "/" },
124 { "/.", "/" },
125 { "////../a", "///a" },
126 { "/../../../../../../", "/" },
127 { "/..//..//", "//" },
128 { "/.config/../ssh", "/ssh" },
129 { "/..config/..", "/" },
130 { "/.../a", "/.../a" },
131 { "/a/%2E%2e/b", "/b" },
132 { "/a/%2e./b", "/b" },
133 { "/a/.%2e/b", "/b" },
134 { "/%2f..%2f", NULL },
135 { "/a/b/.", "/a/b/" },
136 { "/a/b/..", "/a/" },
137 { "well-known", NULL },
138 { ".well-known", NULL },
139 { "..well-known", NULL },
140 { "...well-known", NULL },
141 { "....well-known", NULL },
142 { "%2ewell-known", NULL },
143 { "%2Ewell-known", NULL },
144 { "../.well-known", ".well-known" },
145 };
147 for(i = 0; i < CURL_ARRAYSIZE(pairs); i++) {
148 char *out;
149 int err = dedotdotify(pairs[i].input, strlen(pairs[i].input), &out);
150 abort_unless(err == 0, "returned error");
151 abort_if(err && out, "returned error with output");
153 if(out && pairs[i].output && strcmp(out, pairs[i].output)) {
154 curl_mfprintf(stderr, "Test %u: '%s' gave '%s' instead of '%s'\n",
155 i, pairs[i].input, out, pairs[i].output);
156 fail("Test case output mismatched");
157 fails++;
158 }
159 else if((!out && pairs[i].output) ||
160 (out && !pairs[i].output)) {
161 curl_mfprintf(stderr, "Test %u: '%s' gave '%s' instead of '%s'\n",
162 i, pairs[i].input, out ? out : "(null)",
163 pairs[i].output ? pairs[i].output : "(null)");
164 fail("Test case output mismatched");
165 fails++;
166 }
167 else
168 curl_mfprintf(stderr, "Test %u: OK\n", i);
169 curlx_free(out);
170 }
172 fail_if(fails, "output mismatched");
174 UNITTEST_END_SIMPLE
175}
Diagnostics4 git calls · 148 ms
CallStatusSizeTime0148 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 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 · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 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 · hit29 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=29 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
fetch2001.6 KiB116 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=116 git.response.bytes=1615 git.response.cache=MISS git.response.duration_ms=116 git.fetch.wants=58945b59a2b1ff697e13914396342295434167c4 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=1615 git.pkt.payload.max=1594 git.sideband.band1.bytes=1593 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
- a5e1ff910a02a9c0
- Request
- 087a0fdf…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format