diff options
author | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
---|---|---|
committer | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
commit | 5c4fc93d5f4137bf4c22ddf1a048c907a4a26727 (patch) | |
tree | a9a68e1f6a9c3bfe2b64fa1c3a4098865b7d3b5d /test/urltest.lua | |
parent | ccef3bc4e2aa6ee5b997a80aabb58f4ff0b0e98f (diff) | |
parent | 43a97b7f0053313b43906371dbdc226271e6c8ab (diff) | |
download | luasocket-hjelmeland-patch-1.tar.gz luasocket-hjelmeland-patch-1.tar.bz2 luasocket-hjelmeland-patch-1.zip |
Merge branch 'master' into hjelmeland-patch-1hjelmeland-patch-1
Diffstat (limited to 'test/urltest.lua')
-rw-r--r-- | test/urltest.lua | 211 |
1 files changed, 157 insertions, 54 deletions
diff --git a/test/urltest.lua b/test/urltest.lua index 32cb348..9a3c470 100644 --- a/test/urltest.lua +++ b/test/urltest.lua | |||
@@ -60,8 +60,8 @@ end | |||
60 | 60 | ||
61 | local check_absolute_url = function(base, relative, absolute) | 61 | local check_absolute_url = function(base, relative, absolute) |
62 | local res = socket.url.absolute(base, relative) | 62 | local res = socket.url.absolute(base, relative) |
63 | if res ~= absolute then | 63 | if res ~= absolute then |
64 | io.write("absolute: In test for '", relative, "' expected '", | 64 | io.write("absolute: In test for base='", base, "', rel='", relative, "' expected '", |
65 | absolute, "' but got '", res, "'\n") | 65 | absolute, "' but got '", res, "'\n") |
66 | os.exit() | 66 | os.exit() |
67 | end | 67 | end |
@@ -73,7 +73,7 @@ local check_parse_url = function(gaba) | |||
73 | local parsed = socket.url.parse(url) | 73 | local parsed = socket.url.parse(url) |
74 | for i, v in pairs(gaba) do | 74 | for i, v in pairs(gaba) do |
75 | if v ~= parsed[i] then | 75 | if v ~= parsed[i] then |
76 | io.write("parse: In test for '", url, "' expected ", i, " = '", | 76 | io.write("parse: In test for '", url, "' expected ", i, " = '", |
77 | v, "' but got '", tostring(parsed[i]), "'\n") | 77 | v, "' but got '", tostring(parsed[i]), "'\n") |
78 | for i,v in pairs(parsed) do print(i,v) end | 78 | for i,v in pairs(parsed) do print(i,v) end |
79 | os.exit() | 79 | os.exit() |
@@ -81,7 +81,7 @@ local check_parse_url = function(gaba) | |||
81 | end | 81 | end |
82 | for i, v in pairs(parsed) do | 82 | for i, v in pairs(parsed) do |
83 | if v ~= gaba[i] then | 83 | if v ~= gaba[i] then |
84 | io.write("parse: In test for '", url, "' expected ", i, " = '", | 84 | io.write("parse: In test for '", url, "' expected ", i, " = '", |
85 | tostring(gaba[i]), "' but got '", v, "'\n") | 85 | tostring(gaba[i]), "' but got '", v, "'\n") |
86 | for i,v in pairs(parsed) do print(i,v) end | 86 | for i,v in pairs(parsed) do print(i,v) end |
87 | os.exit() | 87 | os.exit() |
@@ -91,9 +91,78 @@ end | |||
91 | 91 | ||
92 | print("testing URL parsing") | 92 | print("testing URL parsing") |
93 | check_parse_url{ | 93 | check_parse_url{ |
94 | url = "scheme://user:pass$%?#wd@host:port/path;params?query#fragment", | ||
95 | scheme = "scheme", | ||
96 | authority = "user:pass$%?#wd@host:port", | ||
97 | host = "host", | ||
98 | port = "port", | ||
99 | userinfo = "user:pass$%?#wd", | ||
100 | password = "pass$%?#wd", | ||
101 | user = "user", | ||
102 | path = "/path", | ||
103 | params = "params", | ||
104 | query = "query", | ||
105 | fragment = "fragment" | ||
106 | } | ||
107 | check_parse_url{ | ||
108 | url = "scheme://user:pass?#wd@host:port/path;params?query#fragment", | ||
109 | scheme = "scheme", | ||
110 | authority = "user:pass?#wd@host:port", | ||
111 | host = "host", | ||
112 | port = "port", | ||
113 | userinfo = "user:pass?#wd", | ||
114 | password = "pass?#wd", | ||
115 | user = "user", | ||
116 | path = "/path", | ||
117 | params = "params", | ||
118 | query = "query", | ||
119 | fragment = "fragment" | ||
120 | } | ||
121 | check_parse_url{ | ||
122 | url = "scheme://user:pass-wd@host:port/path;params?query#fragment", | ||
123 | scheme = "scheme", | ||
124 | authority = "user:pass-wd@host:port", | ||
125 | host = "host", | ||
126 | port = "port", | ||
127 | userinfo = "user:pass-wd", | ||
128 | password = "pass-wd", | ||
129 | user = "user", | ||
130 | path = "/path", | ||
131 | params = "params", | ||
132 | query = "query", | ||
133 | fragment = "fragment" | ||
134 | } | ||
135 | check_parse_url{ | ||
136 | url = "scheme://user:pass#wd@host:port/path;params?query#fragment", | ||
137 | scheme = "scheme", | ||
138 | authority = "user:pass#wd@host:port", | ||
139 | host = "host", | ||
140 | port = "port", | ||
141 | userinfo = "user:pass#wd", | ||
142 | password = "pass#wd", | ||
143 | user = "user", | ||
144 | path = "/path", | ||
145 | params = "params", | ||
146 | query = "query", | ||
147 | fragment = "fragment" | ||
148 | } | ||
149 | check_parse_url{ | ||
150 | url = "scheme://user:pass#wd@host:port/path;params?query", | ||
151 | scheme = "scheme", | ||
152 | authority = "user:pass#wd@host:port", | ||
153 | host = "host", | ||
154 | port = "port", | ||
155 | userinfo = "user:pass#wd", | ||
156 | password = "pass#wd", | ||
157 | user = "user", | ||
158 | path = "/path", | ||
159 | params = "params", | ||
160 | query = "query", | ||
161 | } | ||
162 | check_parse_url{ | ||
94 | url = "scheme://userinfo@host:port/path;params?query#fragment", | 163 | url = "scheme://userinfo@host:port/path;params?query#fragment", |
95 | scheme = "scheme", | 164 | scheme = "scheme", |
96 | authority = "userinfo@host:port", | 165 | authority = "userinfo@host:port", |
97 | host = "host", | 166 | host = "host", |
98 | port = "port", | 167 | port = "port", |
99 | userinfo = "userinfo", | 168 | userinfo = "userinfo", |
@@ -106,8 +175,8 @@ check_parse_url{ | |||
106 | 175 | ||
107 | check_parse_url{ | 176 | check_parse_url{ |
108 | url = "scheme://user:password@host:port/path;params?query#fragment", | 177 | url = "scheme://user:password@host:port/path;params?query#fragment", |
109 | scheme = "scheme", | 178 | scheme = "scheme", |
110 | authority = "user:password@host:port", | 179 | authority = "user:password@host:port", |
111 | host = "host", | 180 | host = "host", |
112 | port = "port", | 181 | port = "port", |
113 | userinfo = "user:password", | 182 | userinfo = "user:password", |
@@ -121,8 +190,8 @@ check_parse_url{ | |||
121 | 190 | ||
122 | check_parse_url{ | 191 | check_parse_url{ |
123 | url = "scheme://userinfo@host:port/path;params?query#", | 192 | url = "scheme://userinfo@host:port/path;params?query#", |
124 | scheme = "scheme", | 193 | scheme = "scheme", |
125 | authority = "userinfo@host:port", | 194 | authority = "userinfo@host:port", |
126 | host = "host", | 195 | host = "host", |
127 | port = "port", | 196 | port = "port", |
128 | userinfo = "userinfo", | 197 | userinfo = "userinfo", |
@@ -135,8 +204,8 @@ check_parse_url{ | |||
135 | 204 | ||
136 | check_parse_url{ | 205 | check_parse_url{ |
137 | url = "scheme://userinfo@host:port/path;params?#fragment", | 206 | url = "scheme://userinfo@host:port/path;params?#fragment", |
138 | scheme = "scheme", | 207 | scheme = "scheme", |
139 | authority = "userinfo@host:port", | 208 | authority = "userinfo@host:port", |
140 | host = "host", | 209 | host = "host", |
141 | port = "port", | 210 | port = "port", |
142 | userinfo = "userinfo", | 211 | userinfo = "userinfo", |
@@ -149,8 +218,8 @@ check_parse_url{ | |||
149 | 218 | ||
150 | check_parse_url{ | 219 | check_parse_url{ |
151 | url = "scheme://userinfo@host:port/path;params#fragment", | 220 | url = "scheme://userinfo@host:port/path;params#fragment", |
152 | scheme = "scheme", | 221 | scheme = "scheme", |
153 | authority = "userinfo@host:port", | 222 | authority = "userinfo@host:port", |
154 | host = "host", | 223 | host = "host", |
155 | port = "port", | 224 | port = "port", |
156 | userinfo = "userinfo", | 225 | userinfo = "userinfo", |
@@ -162,8 +231,8 @@ check_parse_url{ | |||
162 | 231 | ||
163 | check_parse_url{ | 232 | check_parse_url{ |
164 | url = "scheme://userinfo@host:port/path;?query#fragment", | 233 | url = "scheme://userinfo@host:port/path;?query#fragment", |
165 | scheme = "scheme", | 234 | scheme = "scheme", |
166 | authority = "userinfo@host:port", | 235 | authority = "userinfo@host:port", |
167 | host = "host", | 236 | host = "host", |
168 | port = "port", | 237 | port = "port", |
169 | userinfo = "userinfo", | 238 | userinfo = "userinfo", |
@@ -176,8 +245,8 @@ check_parse_url{ | |||
176 | 245 | ||
177 | check_parse_url{ | 246 | check_parse_url{ |
178 | url = "scheme://userinfo@host:port/path?query#fragment", | 247 | url = "scheme://userinfo@host:port/path?query#fragment", |
179 | scheme = "scheme", | 248 | scheme = "scheme", |
180 | authority = "userinfo@host:port", | 249 | authority = "userinfo@host:port", |
181 | host = "host", | 250 | host = "host", |
182 | port = "port", | 251 | port = "port", |
183 | userinfo = "userinfo", | 252 | userinfo = "userinfo", |
@@ -189,8 +258,8 @@ check_parse_url{ | |||
189 | 258 | ||
190 | check_parse_url{ | 259 | check_parse_url{ |
191 | url = "scheme://userinfo@host:port/;params?query#fragment", | 260 | url = "scheme://userinfo@host:port/;params?query#fragment", |
192 | scheme = "scheme", | 261 | scheme = "scheme", |
193 | authority = "userinfo@host:port", | 262 | authority = "userinfo@host:port", |
194 | host = "host", | 263 | host = "host", |
195 | port = "port", | 264 | port = "port", |
196 | userinfo = "userinfo", | 265 | userinfo = "userinfo", |
@@ -203,8 +272,8 @@ check_parse_url{ | |||
203 | 272 | ||
204 | check_parse_url{ | 273 | check_parse_url{ |
205 | url = "scheme://userinfo@host:port", | 274 | url = "scheme://userinfo@host:port", |
206 | scheme = "scheme", | 275 | scheme = "scheme", |
207 | authority = "userinfo@host:port", | 276 | authority = "userinfo@host:port", |
208 | host = "host", | 277 | host = "host", |
209 | port = "port", | 278 | port = "port", |
210 | userinfo = "userinfo", | 279 | userinfo = "userinfo", |
@@ -213,7 +282,7 @@ check_parse_url{ | |||
213 | 282 | ||
214 | check_parse_url{ | 283 | check_parse_url{ |
215 | url = "//userinfo@host:port/path;params?query#fragment", | 284 | url = "//userinfo@host:port/path;params?query#fragment", |
216 | authority = "userinfo@host:port", | 285 | authority = "userinfo@host:port", |
217 | host = "host", | 286 | host = "host", |
218 | port = "port", | 287 | port = "port", |
219 | userinfo = "userinfo", | 288 | userinfo = "userinfo", |
@@ -226,7 +295,7 @@ check_parse_url{ | |||
226 | 295 | ||
227 | check_parse_url{ | 296 | check_parse_url{ |
228 | url = "//userinfo@host:port/path", | 297 | url = "//userinfo@host:port/path", |
229 | authority = "userinfo@host:port", | 298 | authority = "userinfo@host:port", |
230 | host = "host", | 299 | host = "host", |
231 | port = "port", | 300 | port = "port", |
232 | userinfo = "userinfo", | 301 | userinfo = "userinfo", |
@@ -236,7 +305,7 @@ check_parse_url{ | |||
236 | 305 | ||
237 | check_parse_url{ | 306 | check_parse_url{ |
238 | url = "//userinfo@host/path", | 307 | url = "//userinfo@host/path", |
239 | authority = "userinfo@host", | 308 | authority = "userinfo@host", |
240 | host = "host", | 309 | host = "host", |
241 | userinfo = "userinfo", | 310 | userinfo = "userinfo", |
242 | user = "userinfo", | 311 | user = "userinfo", |
@@ -245,7 +314,7 @@ check_parse_url{ | |||
245 | 314 | ||
246 | check_parse_url{ | 315 | check_parse_url{ |
247 | url = "//user:password@host/path", | 316 | url = "//user:password@host/path", |
248 | authority = "user:password@host", | 317 | authority = "user:password@host", |
249 | host = "host", | 318 | host = "host", |
250 | userinfo = "user:password", | 319 | userinfo = "user:password", |
251 | password = "password", | 320 | password = "password", |
@@ -255,7 +324,7 @@ check_parse_url{ | |||
255 | 324 | ||
256 | check_parse_url{ | 325 | check_parse_url{ |
257 | url = "//user:@host/path", | 326 | url = "//user:@host/path", |
258 | authority = "user:@host", | 327 | authority = "user:@host", |
259 | host = "host", | 328 | host = "host", |
260 | userinfo = "user:", | 329 | userinfo = "user:", |
261 | password = "", | 330 | password = "", |
@@ -265,7 +334,7 @@ check_parse_url{ | |||
265 | 334 | ||
266 | check_parse_url{ | 335 | check_parse_url{ |
267 | url = "//user@host:port/path", | 336 | url = "//user@host:port/path", |
268 | authority = "user@host:port", | 337 | authority = "user@host:port", |
269 | host = "host", | 338 | host = "host", |
270 | userinfo = "user", | 339 | userinfo = "user", |
271 | user = "user", | 340 | user = "user", |
@@ -275,7 +344,7 @@ check_parse_url{ | |||
275 | 344 | ||
276 | check_parse_url{ | 345 | check_parse_url{ |
277 | url = "//host:port/path", | 346 | url = "//host:port/path", |
278 | authority = "host:port", | 347 | authority = "host:port", |
279 | port = "port", | 348 | port = "port", |
280 | host = "host", | 349 | host = "host", |
281 | path = "/path", | 350 | path = "/path", |
@@ -283,14 +352,14 @@ check_parse_url{ | |||
283 | 352 | ||
284 | check_parse_url{ | 353 | check_parse_url{ |
285 | url = "//host/path", | 354 | url = "//host/path", |
286 | authority = "host", | 355 | authority = "host", |
287 | host = "host", | 356 | host = "host", |
288 | path = "/path", | 357 | path = "/path", |
289 | } | 358 | } |
290 | 359 | ||
291 | check_parse_url{ | 360 | check_parse_url{ |
292 | url = "//host", | 361 | url = "//host", |
293 | authority = "host", | 362 | authority = "host", |
294 | host = "host", | 363 | host = "host", |
295 | } | 364 | } |
296 | 365 | ||
@@ -364,7 +433,7 @@ check_parse_url{ | |||
364 | 433 | ||
365 | check_parse_url{ | 434 | check_parse_url{ |
366 | url = "//userinfo@[::FFFF:129.144.52.38]:port/path;params?query#fragment", | 435 | url = "//userinfo@[::FFFF:129.144.52.38]:port/path;params?query#fragment", |
367 | authority = "userinfo@[::FFFF:129.144.52.38]:port", | 436 | authority = "userinfo@[::FFFF:129.144.52.38]:port", |
368 | host = "::FFFF:129.144.52.38", | 437 | host = "::FFFF:129.144.52.38", |
369 | port = "port", | 438 | port = "port", |
370 | userinfo = "userinfo", | 439 | userinfo = "userinfo", |
@@ -378,7 +447,7 @@ check_parse_url{ | |||
378 | check_parse_url{ | 447 | check_parse_url{ |
379 | url = "scheme://user:password@[::192.9.5.5]:port/path;params?query#fragment", | 448 | url = "scheme://user:password@[::192.9.5.5]:port/path;params?query#fragment", |
380 | scheme = "scheme", | 449 | scheme = "scheme", |
381 | authority = "user:password@[::192.9.5.5]:port", | 450 | authority = "user:password@[::192.9.5.5]:port", |
382 | host = "::192.9.5.5", | 451 | host = "::192.9.5.5", |
383 | port = "port", | 452 | port = "port", |
384 | userinfo = "user:password", | 453 | userinfo = "user:password", |
@@ -393,7 +462,7 @@ check_parse_url{ | |||
393 | print("testing URL building") | 462 | print("testing URL building") |
394 | check_build_url { | 463 | check_build_url { |
395 | url = "scheme://user:password@host:port/path;params?query#fragment", | 464 | url = "scheme://user:password@host:port/path;params?query#fragment", |
396 | scheme = "scheme", | 465 | scheme = "scheme", |
397 | host = "host", | 466 | host = "host", |
398 | port = "port", | 467 | port = "port", |
399 | user = "user", | 468 | user = "user", |
@@ -430,7 +499,7 @@ check_build_url{ | |||
430 | 499 | ||
431 | check_build_url { | 500 | check_build_url { |
432 | url = "scheme://user:password@host/path;params?query#fragment", | 501 | url = "scheme://user:password@host/path;params?query#fragment", |
433 | scheme = "scheme", | 502 | scheme = "scheme", |
434 | host = "host", | 503 | host = "host", |
435 | user = "user", | 504 | user = "user", |
436 | password = "password", | 505 | password = "password", |
@@ -442,7 +511,7 @@ check_build_url { | |||
442 | 511 | ||
443 | check_build_url { | 512 | check_build_url { |
444 | url = "scheme://user@host/path;params?query#fragment", | 513 | url = "scheme://user@host/path;params?query#fragment", |
445 | scheme = "scheme", | 514 | scheme = "scheme", |
446 | host = "host", | 515 | host = "host", |
447 | user = "user", | 516 | user = "user", |
448 | path = "/path", | 517 | path = "/path", |
@@ -453,7 +522,7 @@ check_build_url { | |||
453 | 522 | ||
454 | check_build_url { | 523 | check_build_url { |
455 | url = "scheme://host/path;params?query#fragment", | 524 | url = "scheme://host/path;params?query#fragment", |
456 | scheme = "scheme", | 525 | scheme = "scheme", |
457 | host = "host", | 526 | host = "host", |
458 | path = "/path", | 527 | path = "/path", |
459 | params = "params", | 528 | params = "params", |
@@ -463,7 +532,7 @@ check_build_url { | |||
463 | 532 | ||
464 | check_build_url { | 533 | check_build_url { |
465 | url = "scheme://host/path;params#fragment", | 534 | url = "scheme://host/path;params#fragment", |
466 | scheme = "scheme", | 535 | scheme = "scheme", |
467 | host = "host", | 536 | host = "host", |
468 | path = "/path", | 537 | path = "/path", |
469 | params = "params", | 538 | params = "params", |
@@ -472,7 +541,7 @@ check_build_url { | |||
472 | 541 | ||
473 | check_build_url { | 542 | check_build_url { |
474 | url = "scheme://host/path#fragment", | 543 | url = "scheme://host/path#fragment", |
475 | scheme = "scheme", | 544 | scheme = "scheme", |
476 | host = "host", | 545 | host = "host", |
477 | path = "/path", | 546 | path = "/path", |
478 | fragment = "fragment" | 547 | fragment = "fragment" |
@@ -480,7 +549,7 @@ check_build_url { | |||
480 | 549 | ||
481 | check_build_url { | 550 | check_build_url { |
482 | url = "scheme://host/path", | 551 | url = "scheme://host/path", |
483 | scheme = "scheme", | 552 | scheme = "scheme", |
484 | host = "host", | 553 | host = "host", |
485 | path = "/path", | 554 | path = "/path", |
486 | } | 555 | } |
@@ -498,7 +567,7 @@ check_build_url { | |||
498 | 567 | ||
499 | check_build_url { | 568 | check_build_url { |
500 | url = "scheme://user:password@host:port/path;params?query#fragment", | 569 | url = "scheme://user:password@host:port/path;params?query#fragment", |
501 | scheme = "scheme", | 570 | scheme = "scheme", |
502 | host = "host", | 571 | host = "host", |
503 | port = "port", | 572 | port = "port", |
504 | user = "user", | 573 | user = "user", |
@@ -512,7 +581,7 @@ check_build_url { | |||
512 | 581 | ||
513 | check_build_url { | 582 | check_build_url { |
514 | url = "scheme://user:password@host:port/path;params?query#fragment", | 583 | url = "scheme://user:password@host:port/path;params?query#fragment", |
515 | scheme = "scheme", | 584 | scheme = "scheme", |
516 | host = "host", | 585 | host = "host", |
517 | port = "port", | 586 | port = "port", |
518 | user = "user", | 587 | user = "user", |
@@ -527,7 +596,7 @@ check_build_url { | |||
527 | 596 | ||
528 | check_build_url { | 597 | check_build_url { |
529 | url = "scheme://user:password@host:port/path;params?query#fragment", | 598 | url = "scheme://user:password@host:port/path;params?query#fragment", |
530 | scheme = "scheme", | 599 | scheme = "scheme", |
531 | host = "host", | 600 | host = "host", |
532 | port = "port", | 601 | port = "port", |
533 | userinfo = "user:password", | 602 | userinfo = "user:password", |
@@ -540,7 +609,7 @@ check_build_url { | |||
540 | 609 | ||
541 | check_build_url { | 610 | check_build_url { |
542 | url = "scheme://user:password@host:port/path;params?query#fragment", | 611 | url = "scheme://user:password@host:port/path;params?query#fragment", |
543 | scheme = "scheme", | 612 | scheme = "scheme", |
544 | authority = "user:password@host:port", | 613 | authority = "user:password@host:port", |
545 | path = "/path", | 614 | path = "/path", |
546 | params = "params", | 615 | params = "params", |
@@ -558,25 +627,37 @@ check_absolute_url("http://a/b/c/d;p?q#f", "/g", "http://a/g") | |||
558 | check_absolute_url("http://a/b/c/d;p?q#f", "//g", "http://g") | 627 | check_absolute_url("http://a/b/c/d;p?q#f", "//g", "http://g") |
559 | check_absolute_url("http://a/b/c/d;p?q#f", "?y", "http://a/b/c/d;p?y") | 628 | check_absolute_url("http://a/b/c/d;p?q#f", "?y", "http://a/b/c/d;p?y") |
560 | check_absolute_url("http://a/b/c/d;p?q#f", "g?y", "http://a/b/c/g?y") | 629 | check_absolute_url("http://a/b/c/d;p?q#f", "g?y", "http://a/b/c/g?y") |
561 | check_absolute_url("http://a/b/c/d;p?q#f", "g?y/./x", "http://a/b/c/g?y/./x") | 630 | check_absolute_url("http://a/b/c/d;p?q#f", "g?y/./x", "http://a/b/c/g?y/x") |
562 | check_absolute_url("http://a/b/c/d;p?q#f", "#s", "http://a/b/c/d;p?q#s") | 631 | check_absolute_url("http://a/b/c/d;p?q#f", "#s", "http://a/b/c/d;p?q#s") |
563 | check_absolute_url("http://a/b/c/d;p?q#f", "g#s", "http://a/b/c/g#s") | 632 | check_absolute_url("http://a/b/c/d;p?q#f", "g#s", "http://a/b/c/g#s") |
564 | check_absolute_url("http://a/b/c/d;p?q#f", "g#s/./x", "http://a/b/c/g#s/./x") | 633 | check_absolute_url("http://a/b/c/d;p?q#f", "g#s/./x", "http://a/b/c/g#s/x") |
565 | check_absolute_url("http://a/b/c/d;p?q#f", "g?y#s", "http://a/b/c/g?y#s") | 634 | check_absolute_url("http://a/b/c/d;p?q#f", "g?y#s", "http://a/b/c/g?y#s") |
566 | check_absolute_url("http://a/b/c/d;p?q#f", ";x", "http://a/b/c/d;x") | 635 | check_absolute_url("http://a/b/c/d;p?q#f", ";x", "http://a/b/c/d;x") |
567 | check_absolute_url("http://a/b/c/d;p?q#f", "g;x", "http://a/b/c/g;x") | 636 | check_absolute_url("http://a/b/c/d;p?q#f", "g;x", "http://a/b/c/g;x") |
568 | check_absolute_url("http://a/b/c/d;p?q#f", "g;x?y#s", "http://a/b/c/g;x?y#s") | 637 | check_absolute_url("http://a/b/c/d;p?q#f", "g;x?y#s", "http://a/b/c/g;x?y#s") |
569 | check_absolute_url("http://a/b/c/d;p?q#f", ".", "http://a/b/c/") | 638 | check_absolute_url("http://a/b/c/d;p?q#f", ".", "http://a/b/c/") |
570 | check_absolute_url("http://a/b/c/d;p?q#f", "./", "http://a/b/c/") | 639 | check_absolute_url("http://a/b/c/d;p?q#f", "./", "http://a/b/c/") |
640 | check_absolute_url("http://a/b/c/d;p?q#f", "./g", "http://a/b/c/g") | ||
641 | check_absolute_url("http://a/b/c/d;p?q#f", "./g/", "http://a/b/c/g/") | ||
642 | check_absolute_url("http://a/b/c/d;p?q#f", "././g", "http://a/b/c/g") | ||
643 | check_absolute_url("http://a/b/c/d;p?q#f", "././g/", "http://a/b/c/g/") | ||
644 | check_absolute_url("http://a/b/c/d;p?q#f", "g/.", "http://a/b/c/g/") | ||
645 | check_absolute_url("http://a/b/c/d;p?q#f", "g/./", "http://a/b/c/g/") | ||
646 | check_absolute_url("http://a/b/c/d;p?q#f", "g/./.", "http://a/b/c/g/") | ||
647 | check_absolute_url("http://a/b/c/d;p?q#f", "g/././", "http://a/b/c/g/") | ||
648 | check_absolute_url("http://a/b/c/d;p?q#f", "./.", "http://a/b/c/") | ||
649 | check_absolute_url("http://a/b/c/d;p?q#f", "././.", "http://a/b/c/") | ||
650 | check_absolute_url("http://a/b/c/d;p?q#f", "././g/./.", "http://a/b/c/g/") | ||
571 | check_absolute_url("http://a/b/c/d;p?q#f", "..", "http://a/b/") | 651 | check_absolute_url("http://a/b/c/d;p?q#f", "..", "http://a/b/") |
572 | check_absolute_url("http://a/b/c/d;p?q#f", "../", "http://a/b/") | 652 | check_absolute_url("http://a/b/c/d;p?q#f", "../", "http://a/b/") |
573 | check_absolute_url("http://a/b/c/d;p?q#f", "../g", "http://a/b/g") | 653 | check_absolute_url("http://a/b/c/d;p?q#f", "../g", "http://a/b/g") |
574 | check_absolute_url("http://a/b/c/d;p?q#f", "../..", "http://a/") | 654 | check_absolute_url("http://a/b/c/d;p?q#f", "../..", "http://a/") |
575 | check_absolute_url("http://a/b/c/d;p?q#f", "../../", "http://a/") | 655 | check_absolute_url("http://a/b/c/d;p?q#f", "../../", "http://a/") |
576 | check_absolute_url("http://a/b/c/d;p?q#f", "../../g", "http://a/g") | 656 | check_absolute_url("http://a/b/c/d;p?q#f", "../../g", "http://a/g") |
657 | check_absolute_url("http://a/b/c/d;p?q#f", "../../../g", "http://a/g") | ||
577 | check_absolute_url("http://a/b/c/d;p?q#f", "", "http://a/b/c/d;p?q#f") | 658 | check_absolute_url("http://a/b/c/d;p?q#f", "", "http://a/b/c/d;p?q#f") |
578 | check_absolute_url("http://a/b/c/d;p?q#f", "/./g", "http://a/./g") | 659 | check_absolute_url("http://a/b/c/d;p?q#f", "/./g", "http://a/g") |
579 | check_absolute_url("http://a/b/c/d;p?q#f", "/../g", "http://a/../g") | 660 | check_absolute_url("http://a/b/c/d;p?q#f", "/../g", "http://a/g") |
580 | check_absolute_url("http://a/b/c/d;p?q#f", "g.", "http://a/b/c/g.") | 661 | check_absolute_url("http://a/b/c/d;p?q#f", "g.", "http://a/b/c/g.") |
581 | check_absolute_url("http://a/b/c/d;p?q#f", ".g", "http://a/b/c/.g") | 662 | check_absolute_url("http://a/b/c/d;p?q#f", ".g", "http://a/b/c/.g") |
582 | check_absolute_url("http://a/b/c/d;p?q#f", "g..", "http://a/b/c/g..") | 663 | check_absolute_url("http://a/b/c/d;p?q#f", "g..", "http://a/b/c/g..") |
@@ -586,31 +667,53 @@ check_absolute_url("http://a/b/c/d;p?q#f", "./g/.", "http://a/b/c/g/") | |||
586 | check_absolute_url("http://a/b/c/d;p?q#f", "g/./h", "http://a/b/c/g/h") | 667 | check_absolute_url("http://a/b/c/d;p?q#f", "g/./h", "http://a/b/c/g/h") |
587 | check_absolute_url("http://a/b/c/d;p?q#f", "g/../h", "http://a/b/c/h") | 668 | check_absolute_url("http://a/b/c/d;p?q#f", "g/../h", "http://a/b/c/h") |
588 | 669 | ||
670 | check_absolute_url("http://a/b/c/d:p?q#f/", "../g/", "http://a/b/g/") | ||
671 | check_absolute_url("http://a/b/c/d:p?q#f/", "../g", "http://a/b/g") | ||
672 | check_absolute_url("http://a/b/c/d:p?q#f/", "../.g/", "http://a/b/.g/") | ||
673 | check_absolute_url("http://a/b/c/d:p?q#f/", "../.g", "http://a/b/.g") | ||
674 | check_absolute_url("http://a/b/c/d:p?q#f/", "../.g.h/", "http://a/b/.g.h/") | ||
675 | check_absolute_url("http://a/b/c/d:p?q#f/", "../.g.h", "http://a/b/.g.h") | ||
676 | |||
677 | check_absolute_url("http://a/b/c/d:p?q#f/", "g.h/", "http://a/b/c/g.h/") | ||
678 | check_absolute_url("http://a/b/c/d:p?q#f/", "../g.h/", "http://a/b/g.h/") | ||
679 | check_absolute_url("http://a/", "../g.h/", "http://a/g.h/") | ||
680 | |||
589 | -- extra tests | 681 | -- extra tests |
590 | check_absolute_url("//a/b/c/d;p?q#f", "d/e/f", "//a/b/c/d/e/f") | 682 | check_absolute_url("//a/b/c/d;p?q#f", "d/e/f", "//a/b/c/d/e/f") |
591 | check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f") | 683 | check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f") |
592 | check_absolute_url("a/b/c/d", "d/e/f", "a/b/c/d/e/f") | 684 | check_absolute_url("a/b/c/d", "d/e/f", "a/b/c/d/e/f") |
593 | check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f") | 685 | check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f") |
594 | check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html", | 686 | check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html", |
595 | "http://velox.telemar.com.br/dashboard/index.html") | 687 | "http://velox.telemar.com.br/dashboard/index.html") |
688 | check_absolute_url("http://example.com/", "../.badhost.com/", "http://example.com/.badhost.com/") | ||
689 | check_absolute_url("http://example.com/", "...badhost.com/", "http://example.com/...badhost.com/") | ||
690 | check_absolute_url("http://example.com/a/b/c/d/", "../q", "http://example.com/a/b/c/q") | ||
691 | check_absolute_url("http://example.com/a/b/c/d/", "../../q", "http://example.com/a/b/q") | ||
692 | check_absolute_url("http://example.com/a/b/c/d/", "../../../q", "http://example.com/a/q") | ||
693 | check_absolute_url("http://example.com", ".badhost.com", "http://example.com/.badhost.com") | ||
694 | check_absolute_url("http://example.com/a/b/c/d/", "..//../../../q", "http://example.com/a/q") | ||
695 | check_absolute_url("http://example.com/a/b/c/d/", "..//a/../../../../q", "http://example.com/a/q") | ||
696 | check_absolute_url("http://example.com/a/b/c/d/", "..//a/..//../../../q", "http://example.com/a/b/q") | ||
697 | check_absolute_url("http://example.com/a/b/c/d/", "..//a/..///../../../../q", "http://example.com/a/b/q") | ||
698 | check_absolute_url("http://example.com/a/b/c/d/", "../x/a/../y/z/../../../../q", "http://example.com/a/b/q") | ||
596 | 699 | ||
597 | print("testing path parsing and composition") | 700 | print("testing path parsing and composition") |
598 | check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 }) | 701 | check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 }) |
599 | check_parse_path("/eu/", { "eu"; is_absolute = 1, is_directory = 1 }) | 702 | check_parse_path("/eu/", { "eu"; is_absolute = 1, is_directory = 1 }) |
600 | check_parse_path("eu/tu/ele/nos/vos/eles/", | 703 | check_parse_path("eu/tu/ele/nos/vos/eles/", |
601 | { "eu", "tu", "ele", "nos", "vos", "eles"; is_directory = 1}) | 704 | { "eu", "tu", "ele", "nos", "vos", "eles"; is_directory = 1}) |
602 | check_parse_path("/", { is_absolute = 1, is_directory = 1}) | 705 | check_parse_path("/", { is_absolute = 1, is_directory = 1}) |
603 | check_parse_path("", { }) | 706 | check_parse_path("", { }) |
604 | check_parse_path("eu%01/%02tu/e%03l%04e/nos/vos%05/e%12les/", | 707 | check_parse_path("eu%01/%02tu/e%03l%04e/nos/vos%05/e%12les/", |
605 | { "eu\1", "\2tu", "e\3l\4e", "nos", "vos\5", "e\18les"; is_directory = 1}) | 708 | { "eu\1", "\2tu", "e\3l\4e", "nos", "vos\5", "e\18les"; is_directory = 1}) |
606 | check_parse_path("eu/tu", { "eu", "tu" }) | 709 | check_parse_path("eu/tu", { "eu", "tu" }) |
607 | 710 | ||
608 | print("testing path protection") | 711 | print("testing path protection") |
609 | check_protect({ "eu", "-_.!~*'():@&=+$,", "tu" }, "eu/-_.!~*'():@&=+$,/tu") | 712 | check_protect({ "eu", "-_.!~*'():@&=+$,", "tu" }, "eu/-_.!~*'():@&=+$,/tu") |
610 | check_protect({ "eu ", "~diego" }, "eu%20/~diego") | 713 | check_protect({ "eu ", "~diego" }, "eu%20/~diego") |
611 | check_protect({ "/eu>", "<diego?" }, "%2feu%3e/%3cdiego%3f") | 714 | check_protect({ "/eu>", "<diego?" }, "%2Feu%3E/%3Cdiego%3F") |
612 | check_protect({ "\\eu]", "[diego`" }, "%5ceu%5d/%5bdiego%60") | 715 | check_protect({ "\\eu]", "[diego`" }, "%5Ceu%5D/%5Bdiego%60") |
613 | check_protect({ "{eu}", "|diego\127" }, "%7beu%7d/%7cdiego%7f") | 716 | check_protect({ "{eu}", "|diego\127" }, "%7Beu%7D/%7Cdiego%7F") |
614 | check_protect({ "eu ", "~diego" }, "eu /~diego", 1) | 717 | check_protect({ "eu ", "~diego" }, "eu /~diego", 1) |
615 | check_protect({ "/eu>", "<diego?" }, "/eu>/<diego?", 1) | 718 | check_protect({ "/eu>", "<diego?" }, "/eu>/<diego?", 1) |
616 | check_protect({ "\\eu]", "[diego`" }, "\\eu]/[diego`", 1) | 719 | check_protect({ "\\eu]", "[diego`" }, "\\eu]/[diego`", 1) |