Tcl Library Source Code

Check-in [0b8557b27d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Module uri. Amend code and tests for full RFC 3986 compliance (except the RFC 1630 loophole). Add quirk options to permit non-compliant behavior, including for backward compatibility. Accept and amend certain invalid arguments instead of throwing an error. Test uri::split and uri::join both with and without the quirk "NoInitialSlash" (leading "/" in path for schemes http(s), ftp). Update uri.man.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0b8557b27dd3be1d52a89d50ed387ecea28a58bb
User & Date: kjnash 2017-01-09 23:57:34
Context
2017-01-10
08:04
Update the man page for test-anova-F and describe the recent changes check-in: 92b312ced8 user: arjenmarkus tags: trunk
2017-01-09
23:57
Module uri. Amend code and tests for full RFC 3986 compliance (except the RFC 1630 loophole). Add quirk options to permit non-compliant behavior, including for backward compatibility. Accept and amend certain invalid arguments instead of throwing an error. Test uri::split and uri::join both with and without the quirk "NoInitialSlash" (leading "/" in path for schemes http(s), ftp). Update uri.man. check-in: 0b8557b27d user: kjnash tags: trunk
20:18
Correct the tests for the ANOVA procedure and the comments regarding the purpose of ANOVA check-in: 55e0ff7a50 user: arjenmarkus tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/uri/uri-rfc2396.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

25
26
27
28
29
30
31
32
33
34
35
36
37
testsNeedTcltest 1.0

testing {
    useLocal uri.tcl uri
}

# ------------------------------------------------------------------------------
# 2016-12-17 revisions
# ------------------------------------------------------------------------------
# (1) Test result corrected to match RFC 3986 Sec. 5.4.1 for tests:
#     uri-rfc2396-1.7 uri-rfc2396-1.9 uri-rfc2396-2.7 uri-rfc2396-2.9
# (2) Add tests uri-rfc2396-1.14a uri-rfc2396-2.14a from the list in RFC 3986.
# (3) Constraints removed for all tests that now pass.
# (4) Tests uri-rfc2396-1.6 uri-rfc2396-2.6 still fail.  The Tcl result has "/"
#     appended.  RFC 3986 wants to resolve:
#        "//g"     =>  "http://g"    (test uri-rfc2396-1.6)

#        "../.."   =>  "http://a/"   (test uri-rfc2396-1.20)
#     The RFC is therefore ambiguous as to whether "http://host/" or
#     "http://host" is the canonical form.  Both URIs refer to the same
#     resource.
# (5) Add tests uri-rfc2396-11.* from RFC 3986 Sec. 5.4.2 "Abnormal Examples".
# (6) Test uri-rfc2396-11.19 fails - constraints and explanation added.
# ------------------------------------------------------------------------------

# Test the "Normal Examples" from RFC 3986 Sec. 5.4.1.

test uri-rfc2396-1.1 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g:h]
} g:h







|

|


|
|
|
|
>
|
<
<
|
|
|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


27
28
29
30
31
32
33
34
35
36
testsNeedTcltest 1.0

testing {
    useLocal uri.tcl uri
}

# ------------------------------------------------------------------------------
# 2016-12-16 to 2017-01-09 revisions (KJN)
# ------------------------------------------------------------------------------
# (1) Test results corrected to match RFC 3986 Sec. 5.4.1 for tests:
#     uri-rfc2396-1.7 uri-rfc2396-1.9 uri-rfc2396-2.7 uri-rfc2396-2.9
# (2) Add tests uri-rfc2396-1.14a uri-rfc2396-2.14a from the list in RFC 3986.
# (3) All tests now pass: existing "knownBug" constraints removed.
# (4) Add tests uri-rfc2396-3.*, uri-rfc2396-4.* for different cases of query
#     and fragment.
# (5) Add tests uri-rfc2396-5.*, uri-rfc2396-8.* for uri::resolve without
#     explicit call to uri::canonicalize.
# (6) Add tests uri-rfc2396-11.*,  uri-rfc2396-12.* from RFC 3986 Sec. 5.4.2


#     "Abnormal Examples".
# (7) Tests uri-rfc2396-11.19, uri-rfc2396-12.19 fail - new "knownBug"
#     constraints and explanation added.
# ------------------------------------------------------------------------------

# Test the "Normal Examples" from RFC 3986 Sec. 5.4.1.

test uri-rfc2396-1.1 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g:h]
} g:h
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g/]
} http://a/b/c/g/

test uri-rfc2396-1.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q /g]
} http://a/g

test uri-rfc2396-1.6 {uri::resolve RFC 3986 Sec. 5.4.1 is ambiguous - see comments in test file} {knownBug rfc3986-ambiguous} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q //g]
} http://g

test uri-rfc2396-1.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ?y]
} {http://a/b/c/d;p?y}








|







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g/]
} http://a/b/c/g/

test uri-rfc2396-1.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q /g]
} http://a/g

test uri-rfc2396-1.6 {uri::resolve} {} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q //g]
} http://g

test uri-rfc2396-1.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ?y]
} {http://a/b/c/d;p?y}

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g/]
} http://a/b/c/g/

test uri-rfc2396-2.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p /g]
} http://a/g

test uri-rfc2396-2.6 {uri::resolve RFC 3986 Sec. 5.4.1 is ambiguous - see comments in test file} {knownBug rfc3986-ambiguous} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p //g]
} http://g

test uri-rfc2396-2.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ?y]
} {http://a/b/c/d;p?y}








|







143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g/]
} http://a/b/c/g/

test uri-rfc2396-2.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p /g]
} http://a/g

test uri-rfc2396-2.6 {uri::resolve} {} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p //g]
} http://g

test uri-rfc2396-2.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ?y]
} {http://a/b/c/d;p?y}

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g/]
} http://a/b/c/g/

test uri-rfc2396-3.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f /g]
} http://a/g

test uri-rfc2396-3.6 {uri::resolve RFC 3986 Sec. 5.4.1 is ambiguous - see comments in test file} {knownBug rfc3986-ambiguous} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f //g]
} http://g

test uri-rfc2396-3.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ?y]
} {http://a/b/c/d;p?y}








|







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g/]
} http://a/b/c/g/

test uri-rfc2396-3.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f /g]
} http://a/g

test uri-rfc2396-3.6 {uri::resolve} {} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f //g]
} http://g

test uri-rfc2396-3.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ?y]
} {http://a/b/c/d;p?y}

335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g/]
} http://a/b/c/g/

test uri-rfc2396-4.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f /g]
} http://a/g

test uri-rfc2396-4.6 {uri::resolve RFC 3986 Sec. 5.4.1 is ambiguous - see comments in test file} {knownBug rfc3986-ambiguous} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f //g]
} http://g

test uri-rfc2396-4.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ?y]
} {http://a/b/c/d;p?y}








|







334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g/]
} http://a/b/c/g/

test uri-rfc2396-4.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f /g]
} http://a/g

test uri-rfc2396-4.6 {uri::resolve} {} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f //g]
} http://g

test uri-rfc2396-4.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ?y]
} {http://a/b/c/d;p?y}

430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
    uri::resolve http://a/b/c/d\;p?q g/
} http://a/b/c/g/

test uri-rfc2396-5.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q /g
} http://a/g

test uri-rfc2396-5.6 {uri::resolve RFC 3986 Sec. 5.4.1 is ambiguous - see comments in test file} {knownBug rfc3986-ambiguous} {
    uri::resolve http://a/b/c/d\;p?q //g
} http://g

test uri-rfc2396-5.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ?y
} {http://a/b/c/d;p?y}








|







429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
    uri::resolve http://a/b/c/d\;p?q g/
} http://a/b/c/g/

test uri-rfc2396-5.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q /g
} http://a/g

test uri-rfc2396-5.6 {uri::resolve} {} {
    uri::resolve http://a/b/c/d\;p?q //g
} http://g

test uri-rfc2396-5.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ?y
} {http://a/b/c/d;p?y}

527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
    uri::resolve http://a/b/c/d\;p g/
} http://a/b/c/g/

test uri-rfc2396-6.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p /g
} http://a/g

test uri-rfc2396-6.6 {uri::resolve RFC 3986 Sec. 5.4.1 is ambiguous - see comments in test file} {knownBug rfc3986-ambiguous} {
    uri::resolve http://a/b/c/d\;p //g
} http://g

test uri-rfc2396-6.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ?y
} {http://a/b/c/d;p?y}








|







526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
    uri::resolve http://a/b/c/d\;p g/
} http://a/b/c/g/

test uri-rfc2396-6.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p /g
} http://a/g

test uri-rfc2396-6.6 {uri::resolve} {} {
    uri::resolve http://a/b/c/d\;p //g
} http://g

test uri-rfc2396-6.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ?y
} {http://a/b/c/d;p?y}

623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
    uri::resolve http://a/b/c/d\;p?q#f g/
} http://a/b/c/g/

test uri-rfc2396-7.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f /g
} http://a/g

test uri-rfc2396-7.6 {uri::resolve RFC 3986 Sec. 5.4.1 is ambiguous - see comments in test file} {knownBug rfc3986-ambiguous} {
    uri::resolve http://a/b/c/d\;p?q#f //g
} http://g

test uri-rfc2396-7.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ?y
} {http://a/b/c/d;p?y}








|







622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
    uri::resolve http://a/b/c/d\;p?q#f g/
} http://a/b/c/g/

test uri-rfc2396-7.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f /g
} http://a/g

test uri-rfc2396-7.6 {uri::resolve} {} {
    uri::resolve http://a/b/c/d\;p?q#f //g
} http://g

test uri-rfc2396-7.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ?y
} {http://a/b/c/d;p?y}

719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
    uri::resolve http://a/b/c/d\;p#f g/
} http://a/b/c/g/

test uri-rfc2396-8.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f /g
} http://a/g

test uri-rfc2396-8.6 {uri::resolve RFC 3986 Sec. 5.4.1 is ambiguous - see comments in test file} {knownBug rfc3986-ambiguous} {
    uri::resolve http://a/b/c/d\;p#f //g
} http://g

test uri-rfc2396-8.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ?y
} {http://a/b/c/d;p?y}








|







718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
    uri::resolve http://a/b/c/d\;p#f g/
} http://a/b/c/g/

test uri-rfc2396-8.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f /g
} http://a/g

test uri-rfc2396-8.6 {uri::resolve} {} {
    uri::resolve http://a/b/c/d\;p#f //g
} http://g

test uri-rfc2396-8.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ?y
} {http://a/b/c/d;p?y}

867
868
869
870
871
872
873
874


875
876

877
878
879
880
881
882
883
} http://a/b/c/g#s/./x

test uri-rfc2396-11.18 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g#s/../x]
} http://a/b/c/g#s/../x

test uri-rfc2396-11.19 {uri::resolve abnormal examples
    RFC 3986 Sec. 5.4.2 advises avoiding this usage which is a loophole in RFC 1630.


    uri::resolve is a "strict parser" in the sense of RFC 3986 Sec. 5.2.2: it does not
    allow a relative URI such as "http:foo/bar.html" and therefore will fail this test.

} {knownBug rfc1630-loophole-avoid-use} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q http:g]
} http:g

# Cf. tests from RFC 3986 Sec. 5.4.2. "Abnormal Examples".
# Without explicit canonicalization.








|
>
>
|
<
>







866
867
868
869
870
871
872
873
874
875
876

877
878
879
880
881
882
883
884
} http://a/b/c/g#s/./x

test uri-rfc2396-11.18 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g#s/../x]
} http://a/b/c/g#s/../x

test uri-rfc2396-11.19 {uri::resolve abnormal examples
    RFC 3986 Sec. 5.4.2 advises avoiding this usage which is a loophole
    in RFC 1630, which allows a relative URI to specify the scheme if it
    is the same as the scheme of the base URI.
    uri::resolve is a "strict parser" in the sense of RFC 3986 Sec. 5.2.2:

    however, it does not handle the loophole correctly and fails this test.
} {knownBug rfc1630-loophole-avoid-use} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q http:g]
} http:g

# Cf. tests from RFC 3986 Sec. 5.4.2. "Abnormal Examples".
# Without explicit canonicalization.

950
951
952
953
954
955
956
957


958
959

960
961
962
963
964
965
966
} http://a/b/c/g#s/./x

test uri-rfc2396-12.18 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g#s/../x
} http://a/b/c/g#s/../x

test uri-rfc2396-12.19 {uri::resolve abnormal examples
    RFC 3986 Sec. 5.4.2 advises avoiding this usage which is a loophole in RFC 1630.


    uri::resolve is a "strict parser" in the sense of RFC 3986 Sec. 5.2.2: it does not
    allow a relative URI such as "http:foo/bar.html" and therefore will fail this test.

} {knownBug rfc1630-loophole-avoid-use} {
    uri::resolve http://a/b/c/d\;p?q http:g
} http:g



# ------------------------------------------------------------------------------







|
>
>
|
<
>







951
952
953
954
955
956
957
958
959
960
961

962
963
964
965
966
967
968
969
} http://a/b/c/g#s/./x

test uri-rfc2396-12.18 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g#s/../x
} http://a/b/c/g#s/../x

test uri-rfc2396-12.19 {uri::resolve abnormal examples
    RFC 3986 Sec. 5.4.2 advises avoiding this usage which is a loophole
    in RFC 1630, which allows a relative URI to specify the scheme if it
    is the same as the scheme of the base URI.
    uri::resolve is a "strict parser" in the sense of RFC 3986 Sec. 5.2.2:

    however, it does not handle the loophole correctly and fails this test.
} {knownBug rfc1630-loophole-avoid-use} {
    uri::resolve http://a/b/c/d\;p?q http:g
} http:g



# ------------------------------------------------------------------------------

Changes to modules/uri/uri.man.

1
2
3
4
5
6
7

8
9
10
11

12
13

14
15
16
17
18
19
20
21
22
23
24

25


26
27
28
29



30

31







32
33
34
35
36




37
38
39
40
41





42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77



78
79
80
81







82
83
84
85
86
87
88
89
90
91
92



93
94
95
96
97

98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138


139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
































































































































































188
189
190
191
192
193
194
195
196
197
[vset VERSION 1.2.6]
[manpage_begin uri n [vset VERSION]]
[keywords {fetching information}]
[keywords file]
[keywords ftp]
[keywords gopher]
[keywords http]

[keywords ldap]
[keywords mailto]
[keywords news]
[keywords prospero]

[keywords {rfc 2255}]
[keywords {rfc 2396}]

[keywords uri]
[keywords url]
[keywords wais]
[keywords www]
[moddesc   {Tcl Uniform Resource Identifier Management}]
[titledesc {URI utilities}]
[category  Networking]
[require Tcl 8.2]
[require uri [opt [vset VERSION]]]
[description]


This package contains two parts. First it provides regular expressions


for a number of url/uri schemes. Second it provides a number of
commands for manipulating urls/uris and fetching data specified by
them. For the latter this package analyses the requested url/uri and
then dispatches it to the appropriate package (http, ftp, ...) for



actual fetching.









[para]

The package currently does not conform to
RFC 2396 ([uri http://www.rfc-editor.org/rfc/rfc2396.txt]),
but quite likely should be. Patches and other help are welcome.





[section COMMANDS]

[list_begin definitions]






[call [cmd uri::split] [arg url] [opt [arg defaultscheme]]]

[cmd uri::split] takes an [arg url], decodes it and then returns a
list of key/value pairs suitable for [cmd "array set"] containing the
constituents of the [arg url]. If the scheme is missing from the url
it defaults to the value of [arg defaultscheme] if it was specified,
or [term http] else. Currently only the schemes [term http],

[term ftp], [term mailto], [term urn], [term news], [term ldap] and
[term file] are supported by the package itself.

See section [sectref EXTENDING] on how to expand that range.

[para]

The set of constituents of an url (= the set of keys in the returned
dictionary) is dependent on the scheme of the url. The only key which
is therefore always present is [const scheme]. For the following
schemes the constituents and their keys are known:

[list_begin definitions]
[def ftp]
[const user], [const pwd], [const host], [const port],
[const path], [const type]

[def http(s)]
[const user], [const pwd], [const host], [const port],
[const path], [const query], [const fragment]. The fragment
is optional.

[def file]
[const path], [const host]. The host is optional.

[def mailto]
[const user], [const host]. The host is optional.




[def news]
Either [const message-id] or [const newsgroup-name].

[list_end]







[para]

[call [cmd uri::join] [opt "[arg key] [arg value]"]...]

[cmd uri::join] takes a list of key/value pairs (generated by

[cmd uri::split], for example) and returns the canonical url they
represent. Currently only the schemes [term http], [term ftp],
[term mailto], [term urn], [term news], [term ldap] and [term file]
are supported. See section [sectref EXTENDING] on how to expand that
range.




[call [cmd uri::resolve] [arg base] [arg url]]

[cmd uri::resolve] resolves the specified [arg url] relative to


[arg base]. In other words: A non-relative [arg url] is returned
unchanged, whereas for a relative [arg url] the missing parts are
taken from [arg base] and prepended to it. The result of this
operation is returned. For an empty [arg url] the result is

[arg base].

[call [cmd uri::isrelative] [arg url]]

[cmd uri::isrelative] determines whether the specified [arg url] is
absolute or relative.

[call [cmd uri::geturl] [arg url] [opt "[arg options]..."]]

[cmd uri::geturl] decodes the specified [arg url] and then dispatches
the request to the package appropriate for the scheme found in the
url. The command assumes that the package to handle the given scheme
either has the same name as the scheme itself (including possible
capitalization) followed by [cmd ::geturl], or, in case of this
failing, has the same name as the scheme itself (including possible
capitalization). It further assumes that whatever package was loaded
provides a [cmd geturl]-command in the namespace of the same name as
the package itself. This command is called with the given [arg url]
and all given [arg options]. Currently [cmd geturl] does not handle
any options itself.

[para]

[emph Note:] [term file]-urls are an exception to the rule
described above. They are handled internally.

[para]

It is not possible to specify results of the command. They depend on
the [cmd geturl]-command for the scheme the request was dispatched to.

[call [cmd uri::canonicalize] [arg uri]]

[cmd uri::canonicalize] returns the canonical form of a URI.  The
canonical form of a URI is one where relative path specifications,
ie. . and .., have been resolved.



[call [cmd uri::register] [arg schemeList] [arg script]]

[cmd uri::register] registers the first element of [arg schemeList] as
a new scheme and the remaining elements as aliases for this scheme. It
creates the namespace for the scheme and executes the [arg script] in
the new namespace. The script has to declare variables containing the
regular expressions relevant to the scheme. At least the variable
[var schemepart] has to be declared as that one is used to extend
the variables keeping track of the registered schemes.

[list_end]

[section  SCHEMES]

In addition to the commands mentioned above this package provides
regular expression to recognize urls for a number of url schemes.

[para]

For each supported scheme a namespace of the same name as the scheme
itself is provided inside of the namespace [emph uri] containing the
variable [var url] whose contents are a regular expression to
recognize urls of that scheme. Additional variables may contain
regular expressions for parts of urls for that scheme.

[para]

The variable [var uri::schemes] contains a list of all supported
schemes. Currently these are [term ftp], [term ldap], [term file],

[term http], [term gopher], [term mailto], [term news],
[term wais] and [term prospero].

[section  EXTENDING]

Extending the range of schemes supported by [cmd uri::split] and

[cmd uri::join] is easy because both commands do not handle the
request by themselves but dispatch it to another command in the
[emph uri] namespace using the scheme of the url as criterion.

[para]

[cmd uri::split] and [cmd uri::join]

call [cmd "Split[lb]string totitle <scheme>[rb]"]
and  [cmd "Join[lb]string totitle <scheme>[rb]"] respectively.

































































































































































[section  CREDITS]
[para]

Original code (regular expressions) by Andreas Kupries.
Modularisation by Steve Ball, also the split/join/resolve
functionality.

[vset CATEGORY uri]
[include ../doctools2base/include/feedback.inc]
[manpage_end]
|






>




>


>











>
|
>
>
|
|
|
|
>
>
>
|
>

>
>
>
>
>
>
>


|
|
<
>
>
>
>





>
>
>
>
>


|

|

|
<
|






|
|






|



|
<







>
>
>




>
>
>
>
>
>
>






|
|
|
|
|
>
>
>





>
|



|
<




|





|











|











|
>
>






|









|






|
|



|
|
<
|





<


|








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





|




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

207
208
209
210
211
212

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
[vset VERSION 1.2.7]
[manpage_begin uri n [vset VERSION]]
[keywords {fetching information}]
[keywords file]
[keywords ftp]
[keywords gopher]
[keywords http]
[keywords https]
[keywords ldap]
[keywords mailto]
[keywords news]
[keywords prospero]
[keywords {rfc 1630}]
[keywords {rfc 2255}]
[keywords {rfc 2396}]
[keywords {rfc 3986}]
[keywords uri]
[keywords url]
[keywords wais]
[keywords www]
[moddesc   {Tcl Uniform Resource Identifier Management}]
[titledesc {URI utilities}]
[category  Networking]
[require Tcl 8.2]
[require uri [opt [vset VERSION]]]
[description]

This package does two things.

[para]

First, it provides a number of
commands for manipulating URLs/URIs and fetching data specified by
them. For fetching data this package analyses the requested URL/URI and
then dispatches it to the appropriate package ([package http], [package ftp], ...) for
actual retrieval.  Currently these commands are defined for the schemes
[term http], [term https], [term ftp], [term mailto], [term news],
[term ldap], [term ldaps] and [term file].  The package [package uri::urn] adds scheme [term urn].

[para]

Second, it provides regular expressions
for a number of [const registered] URL/URI schemes. Registered
schemes are currently [term ftp], [term ldap], [term ldaps], [term file],
[term http], [term https], [term gopher], [term mailto], [term news],
[term wais] and [term prospero].  The package [package uri::urn] adds scheme
[term urn].

[para]

The commands of the package conform to
RFC 3986 ([uri https://www.rfc-editor.org/rfc/rfc3986.txt]),

with the exception of a loophole arising from RFC 1630 and described
in RFC 3986 Sections 5.2.2 and 5.4.2. The loophole allows a relative
URI to include a scheme if it is the same as the scheme of the base
URI against which it is resolved. RFC 3986 recommends avoiding this usage.

[section COMMANDS]

[list_begin definitions]

[call [cmd uri::setQuirkOption] [arg option] [opt [arg value]]]

[cmd uri::setQuirkOption] is an accessor command for a number of "quirk options".
The command has the same semantics as the command [cmd set]: when called with one argument it reads an existing value; with two arguments it writes a new value.  The value of a "quirk option" is boolean: the value [const false] requests conformance with RFC 3986, while [const true] requests use of the quirk.  See section [sectref {QUIRK OPTIONS}] for discussion of the different options and their purpose.

[call [cmd uri::split] [arg url] [opt [arg defaultscheme]]]

[cmd uri::split] takes a [arg url], decodes it and then returns a
list of key/value pairs suitable for [cmd "array set"] containing the
constituents of the [arg url]. If the scheme is missing from the [arg url]
it defaults to the value of [arg defaultscheme] if it was specified,
or [term http] else. Currently the schemes [term http],

[term https], [term ftp], [term mailto], [term news], [term ldap], [term ldaps] and
[term file] are supported by the package itself.

See section [sectref EXTENDING] on how to expand that range.

[para]

The set of constituents of a URL (= the set of keys in the returned
dictionary) is dependent on the scheme of the URL. The only key which
is therefore always present is [const scheme]. For the following
schemes the constituents and their keys are known:

[list_begin definitions]
[def ftp]
[const user], [const pwd], [const host], [const port],
[const path], [const type], [const pbare].  The pbare is optional.

[def http(s)]
[const user], [const pwd], [const host], [const port],
[const path], [const query], [const fragment], [const pbare].  The pbare is optional.


[def file]
[const path], [const host]. The host is optional.

[def mailto]
[const user], [const host]. The host is optional.

[def ldap(s)]
[const host], [const port], [const dn], [const attrs], [const scope], [const filter], [const extensions]

[def news]
Either [const message-id] or [const newsgroup-name].

[list_end]

For discussion of the boolean [const pbare] see options [emph NoInitialSlash] and [emph NoExtraKeys] in [sectref {QUIRK OPTIONS}].

[para]

The constituents are returned as slices of the argument [arg url], without removal of percent-encoding ("url-encoding") or other adaptations.  Notably, on Windows® the [const path] in scheme [term file] is not a valid local filename.  See [sectref EXAMPLES] for more information.

[para]

[call [cmd uri::join] [opt "[arg key] [arg value]"]...]

[cmd uri::join] takes a list of key/value pairs (generated by

[cmd uri::split], for example) and returns the canonical URL they
represent. Currently the schemes [term http], [term https],
[term ftp], [term mailto], [term news], [term ldap], [term ldaps] and [term file]
are supported by the package itself. See section [sectref EXTENDING] on how to expand that range.

[para]

The arguments are expected to be slices of a valid URL, with percent-encoding ("url-encoding") and any other necessary adaptations.  Notably, on Windows the [const path] in scheme [term file] is not a valid local filename.  See [sectref EXAMPLES] for more information.

[call [cmd uri::resolve] [arg base] [arg url]]

[cmd uri::resolve] resolves the specified [arg url] relative to

[arg base], in conformance with RFC 3986. In other words: a
non-relative [arg url] is returned
unchanged, whereas for a relative [arg url] the missing parts are
taken from [arg base] and prepended to it. The result of this
operation is returned. For an empty [arg url] the result is
[arg base], without its URI fragment (if any).  The command is available for schemes [term http], [term https], [term ftp], and [term file].


[call [cmd uri::isrelative] [arg url]]

[cmd uri::isrelative] determines whether the specified [arg url] is
absolute or relative.  The command is available for a [arg url] of any scheme.

[call [cmd uri::geturl] [arg url] [opt "[arg options]..."]]

[cmd uri::geturl] decodes the specified [arg url] and then dispatches
the request to the package appropriate for the scheme found in the
URL. The command assumes that the package to handle the given scheme
either has the same name as the scheme itself (including possible
capitalization) followed by [cmd ::geturl], or, in case of this
failing, has the same name as the scheme itself (including possible
capitalization). It further assumes that whatever package was loaded
provides a [cmd geturl]-command in the namespace of the same name as
the package itself. This command is called with the given [arg url]
and all given [arg options]. Currently [cmd geturl] does not handle
any options itself.

[para]

[emph Note:] [term file]-URLs are an exception to the rule
described above. They are handled internally.

[para]

It is not possible to specify results of the command. They depend on
the [cmd geturl]-command for the scheme the request was dispatched to.

[call [cmd uri::canonicalize] [arg uri]]

[cmd uri::canonicalize] returns the canonical form of a URI.  The
canonical form of a URI is one where relative path specifications,
i.e. "." and "..", have been resolved.  The command is available for all
URI schemes that have [cmd uri::split] and [cmd uri::join] commands. The command
returns a canonicalized URI if the URI scheme has a [const path] component (i.e. [term http], [term https], [term ftp], and [term file]).  For schemes that have [cmd uri::split] and [cmd uri::join] commands but no [const path] component (i.e. [term mailto], [term news], [term ldap], and [term ldaps]), the command returns the [arg uri] unchanged.

[call [cmd uri::register] [arg schemeList] [arg script]]

[cmd uri::register] registers the first element of [arg schemeList] as
a new scheme and the remaining elements as aliases for this scheme. It
creates the namespace for the scheme and executes the [arg script] in
the new namespace. The script has to declare variables containing
regular expressions relevant to the scheme. At least the variable
[var schemepart] has to be declared as that one is used to extend
the variables keeping track of the registered schemes.

[list_end]

[section  SCHEMES]

In addition to the commands mentioned above this package provides
regular expression to recognize URLs for a number of URL schemes.

[para]

For each supported scheme a namespace of the same name as the scheme
itself is provided inside of the namespace [emph uri] containing the
variable [var url] whose contents are a regular expression to
recognize URLs of that scheme. Additional variables may contain
regular expressions for parts of URLs for that scheme.

[para]

The variable [var uri::schemes] contains a list of all registered
schemes. Currently these are [term ftp], [term ldap], [term ldaps], [term file],

[term http], [term https], [term gopher], [term mailto], [term news],
[term wais] and [term prospero].

[section  EXTENDING]

Extending the range of schemes supported by [cmd uri::split] and

[cmd uri::join] is easy because both commands do not handle the
request by themselves but dispatch it to another command in the
[emph uri] namespace using the scheme of the URL as criterion.

[para]

[cmd uri::split] and [cmd uri::join]

call [cmd "Split[lb]string totitle <scheme>[rb]"]
and  [cmd "Join[lb]string totitle <scheme>[rb]"] respectively.

[para]

The provision of split and join commands is sufficient to extend the commands [cmd uri::canonicalize] and [cmd uri::geturl]
(the latter subject to the availability of a suitable package with a [cmd geturl] command).  In contrast, to extend the command [cmd uri::resolve] to a new scheme, the command itself must be modified.

[para]

To extend the range of schemes for which pattern information is
available, use the command [cmd uri::register].

[para]

An example of a package that provides both commands and pattern information for a new scheme is [package uri::urn], which adds scheme [term urn].

[section {QUIRK OPTIONS}]

The value of a "quirk option" is boolean: the value [const false] requests conformance with RFC 3986, while [const true] requests use of the quirk.  Use command [cmd uri::setQuirkOption] to access the values of quirk options.

[para]

Quirk options are useful both for allowing backwards compatibility when a command
specification changes, and for adding useful features that are not included
in RFC specifications.  The following quirk options are currently defined:

[list_begin definitions]

[def [emph NoInitialSlash]]
This quirk option concerns the leading character of [const path] (if non-empty) in the schemes [term http], [term https], and [term ftp].

[para]

RFC 3986 defines [const path] in an absolute URI to have an initial "/", unless the value of [const path] is the empty string. For the scheme [term file], all versions of package [package uri] follow this rule.  The quirk option [emph NoInitialSlash] does not apply to scheme [term file].

[para]

For the schemes [term http], [term https], and [term ftp], versions of [package uri] before 1.2.7 define the [const path] [emph NOT] to include an initial "/".  When the quirk option [emph NoInitialSlash] is [const true] (the default), this behavior is also used in version 1.2.7.  To use instead values of [const path] as defined by RFC 3986, set this quirk option to [const false].

[para]

This setting does not affect RFC 3986 conformance.  If [emph NoInitialSlash] is [const true], then the value of [const path] in the schemes [term http], [term https], or [term ftp], cannot distinguish between URIs in which the full "RFC 3986 path" is the empty string "" or a single slash "/" respectively.  The missing information is recorded in an additional [cmd uri::split] key [const pbare].

[para]

The boolean [const pbare] is defined when quirk options [emph NoInitialSlash] and [emph NoExtraKeys] have values [const true] and [const false] respectively.  In this case, if the value of [const path] is the empty string "", [const pbare] is [const true] if the full "RFC 3986 path" is "", and [const pbare] is [const false] if the full "RFC 3986 path" is "/".

[para]

Using this quirk option [emph NoInitialSlash] is a matter of preference.

[def [emph NoExtraKeys]]
This quirk option permits full backward compatibility with versions of [package uri] before 1.2.7, by omitting the [cmd uri::split] key [const pbare] described above (see quirk option [emph NoInitialSlash]).  The outcome is greater backward compatibility of the [cmd uri::split] command, but an inability to distinguish between URIs in which the full "RFC 3986 path" is the empty string "" or a single slash "/" respectively - i.e. a minor non-conformance with RFC 3986.

[para]

If the quirk option [emph NoExtraKeys] is [const false] (the default), command [cmd uri::split] returns an additional key [const pbare], and the commands comply with RFC 3986. If the quirk option [emph NoExtraKeys] is [const true], the key [const pbare] is not defined and there is not full conformance with RFC 3986.

[para]

Using the quirk option [emph NoExtraKeys] is [emph NOT] recommended, because if set to [const true] it will reduce conformance with RFC 3986.  The option is included only for compatibility with code, written for earlier versions of [package uri], that needs values of [const path] without a leading "/", [emph {AND ALSO}] cannot tolerate unexpected keys in the results of [cmd uri::split].

[def [emph HostAsDriveLetter]]
When handling the scheme [term file] on the
Windows platform, versions of [package uri] before 1.2.7
use the [const host] field to represent a Windows drive letter and the colon that follows it, and the [const path] field to represent the filename path after the colon.  Such URIs are invalid, and are not recognized by any RFC. When the quirk option [emph HostAsDriveLetter] is [const true], this behavior is also used in version 1.2.7.  To use [term file] URIs on Windows that conform to RFC 3986, set this quirk option to [const false] (the default).

[para]

Using this quirk is [emph NOT] recommended, because if set to [const true] it will cause the [package uri] commands to expect and produce invalid URIs.  The option is included only for compatibility with legacy code.

[def [emph RemoveDoubleSlashes]]
When a URI is canonicalized by [cmd uri::canonicalize], its [const path] is normalized by removal of segments "." and "..".  RFC 3986 does not mandate
the removal of empty segments "" (i.e. the merger of double slashes, which is a feature of filename normalization but not of URI [const path] normalization): it treats URIs with excess slashes as referring to different resources.  When the quirk option [emph RemoveDoubleSlashes] is [const true] (the default), empty segments will be removed from [const path].  To prevent removal, and thereby conform to RFC 3986, set this quirk option to [const false].

[para]

Using this quirk is a matter of preference.  A URI with double slashes in its path was most likely generated by error, certainly so if it has a straightforward mapping to a file on a server.  In some cases it may be better to sanitize the URI; in others, to keep the URI and let the server handle the possible error.

[list_end]
[para]

[subsection {BACKWARD COMPATIBILITY}]

To behave as similarly as possible to versions of [package uri] earlier than 1.2.7, set the following quirk options:
[list_begin itemized]

[item] [cmd uri::setQuirkOption] [arg NoInitialSlash] 1
[item] [cmd uri::setQuirkOption] [arg NoExtraKeys] 1
[item] [cmd uri::setQuirkOption] [arg HostAsDriveLetter] 1
[item] [cmd uri::setQuirkOption] [arg RemoveDoubleSlashes] 0

[list_end]

In code that can tolerate the return by [cmd uri::split] of an additional key [const pbare], set

[list_begin itemized]

[item] [cmd uri::setQuirkOption] [arg NoExtraKeys] 0

[list_end]

in order to achieve greater compliance with RFC 3986.

[subsection {NEW DESIGNS}]

For new projects, the following settings are recommended:

[list_begin itemized]

[item] [cmd uri::setQuirkOption] [arg NoInitialSlash] 0
[item] [cmd uri::setQuirkOption] [arg NoExtraKeys] 0
[item] [cmd uri::setQuirkOption] [arg HostAsDriveLetter] 0
[item] [cmd uri::setQuirkOption] [arg RemoveDoubleSlashes] 0|1

[list_end]

[subsection {DEFAULT VALUES}]

The default values for package [package uri] version 1.2.7 are intended to be a compromise between backwards compatibility and improved features.  Different default values may be chosen in future versions of package [package uri].

[list_begin itemized]

[item] [cmd uri::setQuirkOption] [arg NoInitialSlash] 1
[item] [cmd uri::setQuirkOption] [arg NoExtraKeys] 0
[item] [cmd uri::setQuirkOption] [arg HostAsDriveLetter] 0
[item] [cmd uri::setQuirkOption] [arg RemoveDoubleSlashes] 1

[list_end]

[section  EXAMPLES]

A Windows® local filename such as "[const {C:\Other Files\startup.txt}]" is not suitable for use as the [const path] element of a URI in the scheme [term file].

[para]

The Tcl command [cmd {file normalize}] will convert the backslashes to forward slashes.  To generate a valid [const path] for the scheme [term file], the normalized filename must be prepended with "[const /]", and then any characters that do not match the [cmd regexp] bracket expression

[example {
    [a-zA-Z0-9$_.+!*'(,)?:@&=-]
}]

must be percent-encoded.

[para]

The result in this example is "[const /C:/Other%20Files/startup.txt]" which is a valid value for [const path].

[example {
% uri::join path /C:/Other%20Files/startup.txt scheme file

file:///C:/Other%20Files/startup.txt

% uri::split file:///C:/Other%20Files/startup.txt

path /C:/Other%20Files/startup.txt scheme file

}]

On UNIX® systems filenames begin with "[const /]" which is also used as the directory separator.  The only action needed to convert a filename to a valid [const path] is percent-encoding.


[section  CREDITS]
[para]

Original code (regular expressions) by Andreas Kupries.
Modularisation by Steve Ball, also the split/join/resolve
functionality. RFC 3986 conformance by Keith Nash.

[vset CATEGORY uri]
[include ../doctools2base/include/feedback.inc]
[manpage_end]

Changes to modules/uri/uri.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

26
27
28







29
30
31
32
33
34
35
# uri.tcl --
#
#	URI parsing and fetch
#
# Copyright (c) 2000 Zveno Pty Ltd
# Copyright (c) 2006 Pierre DAVID <[email protected]>
# Copyright (c) 2006 Andreas Kupries <[email protected]>
# Copyright (c) 2017 Keith Nash <[email protected]>
# Steve Ball, http://www.zveno.com/
# Derived from urls.tcl by Andreas Kupries
#
# TODO:
#	Handle www-url-encoding details
#
# CVS: $Id: uri.tcl,v 1.36 2011/03/23 04:39:54 andreas_kupries Exp $

package require Tcl 8.2

namespace eval ::uri {

    namespace export split join
    namespace export resolve isrelative
    namespace export geturl
    namespace export canonicalize
    namespace export register


    variable file:counter 0








    # --------------------------------------------------------------------------
    # These variables are used by uri::register and are a repository of
    # scheme-related pattern information that may be accessed by external code.
    # None is used by the other commands of this package.
    # --------------------------------------------------------------------------
    variable schemes       {}
    variable schemePattern ""











<
<
<











>



>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# uri.tcl --
#
#	URI parsing and fetch
#
# Copyright (c) 2000 Zveno Pty Ltd
# Copyright (c) 2006 Pierre DAVID <[email protected]>
# Copyright (c) 2006 Andreas Kupries <[email protected]>
# Copyright (c) 2017 Keith Nash <[email protected]>
# Steve Ball, http://www.zveno.com/
# Derived from urls.tcl by Andreas Kupries
#



# CVS: $Id: uri.tcl,v 1.36 2011/03/23 04:39:54 andreas_kupries Exp $

package require Tcl 8.2

namespace eval ::uri {

    namespace export split join
    namespace export resolve isrelative
    namespace export geturl
    namespace export canonicalize
    namespace export register
    namespace export setQuirkOption

    variable file:counter 0

    variable Quirks
    set Quirks(NoInitialSlash)      1
    set Quirks(NoExtraKeys)         0
    set Quirks(HostAsDriveLetter)   0
    set Quirks(RemoveDoubleSlashes) 1
    # Defaults for v1.2.7: {1 0 0 1}

    # --------------------------------------------------------------------------
    # These variables are used by uri::register and are a repository of
    # scheme-related pattern information that may be accessed by external code.
    # None is used by the other commands of this package.
    # --------------------------------------------------------------------------
    variable schemes       {}
    variable schemePattern ""
115
116
117
118
119
120
121












































122
123
124
125
126
127
128

	variable	unreserved	{[a-zA-Z0-9$_.+!*'(,)-]}
	variable	uChar		"(${unreserved}|${escape})"

    } ;# basic {}
}













































# ::uri::register --
#
#	Register a scheme (and aliases) in the package. The command
#	creates a namespace below "::uri" with the same name as the
#	scheme and executes the script declaring the pattern variables
#	for this scheme in the new namespace. At last it updates the
#	uri variables keeping track of overall scheme information.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

	variable	unreserved	{[a-zA-Z0-9$_.+!*'(,)-]}
	variable	uChar		"(${unreserved}|${escape})"

    } ;# basic {}
}

# ::uri::setQuirkOption
#
#	Accessor command for quirk options; uses "set" semantics.
#
#	Quirk options allow deviations from RFC 3986, and are fully documented
#	in the man page uri(n).
#
#	Currently defined quirk options are:
#	    NoInitialSlash
#	    NoExtraKeys
#	    RemoveDoubleSlashes
#	    HostAsDriveLetter
#
# Arguments:
#	key	name of a quirk option
#       value	(optional, boolean) new value
#
# Results:
#	The value of the quirk option.

proc ::uri::setQuirkOption {key args} {
    variable Quirks

    if {![info exists Quirks($key)]} {
	return -code error {unknown key}
    }

    set lenny [llength $args]
    if {$lenny == 0} {
	return $Quirks($key)
    } elseif {$lenny == 1} {
	set value [lindex $args 0]
	if {![string is boolean -strict $value]} {
	    return -code error {boolean value required}
	}
	set Quirks($key) [expr {$value && $value}]
	return $value
    } else {
        return -code error {wrong # args: should be "::uri::setQuirkOption\
		key ?newBooleanValue?"}
    }
}


# ::uri::register --
#
#	Register a scheme (and aliases) in the package. The command
#	creates a namespace below "::uri" with the same name as the
#	scheme and executes the script declaring the pattern variables
#	for this scheme in the new namespace. At last it updates the
#	uri variables keeping track of overall scheme information.
226
227
228
229
230
231
232

233
234
235
236
237
238
239
240
241
242
243

    if {[::info procs Split[string totitle $scheme]] == {}} {
	error "unknown scheme '$scheme' in '$url'"
    }

    regsub -- "^${scheme}:" $url {} url


    set       parts(scheme) [string tolower $scheme]
    array set parts [Split[string totitle $scheme] $url]

    # should decode all encoded characters!

    return [array get parts]
}

proc ::uri::SplitFtp {url} {
    # @c Splits the given ftp-<a url> into its constituents.
    # @a url: The url to split, without! scheme specification.







>



|







275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293

    if {[::info procs Split[string totitle $scheme]] == {}} {
	error "unknown scheme '$scheme' in '$url'"
    }

    regsub -- "^${scheme}:" $url {} url

    # Pass url without scheme: to the per-scheme handler.
    set       parts(scheme) [string tolower $scheme]
    array set parts [Split[string totitle $scheme] $url]

    # Does not decode encoded characters.

    return [array get parts]
}

proc ::uri::SplitFtp {url} {
    # @c Splits the given ftp-<a url> into its constituents.
    # @a url: The url to split, without! scheme specification.
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279

280
281
282

283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299












300






301
302
303
304
305
306
307




308
309
310
311
312
313
314
    # <password> is optional too.
    #
    # "//" [ <user> [":" <password> ] "@"] <host> [":" <port>] "/"
    #	<cwd1> "/" ..."/" <cwdN> "/" <name> [";type=" <typecode>]

    upvar \#0 [namespace current]::ftp::typepart ftptype

    array set parts {user {} pwd {} host {} port {} path {} type {}}

    # slash off possible type specification

    if {[regexp -indices -- "${ftptype}$" $url dummy ftype]} {

	set from	[lindex $ftype 0]
	set to		[lindex $ftype 1]

	set parts(type)	[string range   $url $from $to]

	set from	[lindex $dummy 0]
	set url		[string replace $url $from end]
    }

    # Handle user, password, host and port

    if {[string match "//*" $url]} {
	set url [string range $url 2 end]

	array set parts [GetUPHP url]

    }

    set parts(path) [string trimleft $url /]


    return [array get parts]
}

proc ::uri::JoinFtp args {
    set uphp [eval [linsert $args 0 ComposeUPHP {}]]

    array set components {
	path {} type {}
    }
    array set components $args

    set type {}
    if {[string length $components(type)]} {
	set type \;type=$components(type)
    }













    return ftp://${uphp}/[string trimleft $components(path) /]$type






}

proc ::uri::SplitHttps {url} {
    return [SplitHttp $url]
}

proc ::uri::SplitHttp {url} {




    # @c Splits the given http-<a url> into its constituents.
    # @a url: The url to split, without! scheme specification.
    # @r List containing the constituents, suitable for 'array set'.

    # general syntax:
    # //<host>:<port>/<path>?<searchpart>
    #







|




















>


|
>








|








>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>



|

|

>
>
>
>







302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
    # <password> is optional too.
    #
    # "//" [ <user> [":" <password> ] "@"] <host> [":" <port>] "/"
    #	<cwd1> "/" ..."/" <cwdN> "/" <name> [";type=" <typecode>]

    upvar \#0 [namespace current]::ftp::typepart ftptype

    array set parts {user {} pwd {} host {} port {} path {} type {} scheme ftp}

    # slash off possible type specification

    if {[regexp -indices -- "${ftptype}$" $url dummy ftype]} {

	set from	[lindex $ftype 0]
	set to		[lindex $ftype 1]

	set parts(type)	[string range   $url $from $to]

	set from	[lindex $dummy 0]
	set url		[string replace $url $from end]
    }

    # Handle user, password, host and port

    if {[string match "//*" $url]} {
	set url [string range $url 2 end]

	array set parts [GetUPHP url]
	# (also removes UPHP from url)
    }

    set parts(path) $url
    AddQuirk3986 parts

    return [array get parts]
}

proc ::uri::JoinFtp args {
    set uphp [eval [linsert $args 0 ComposeUPHP {}]]

    array set components {
	pbare 0 path {} type {}
    }
    array set components $args

    set type {}
    if {[string length $components(type)]} {
	set type \;type=$components(type)
    }

    RemoveQuirk3986 components

    # Botches to accept certain invalid arguments instead of raising an error.

    set PathFirst [string index $components(path) 0]
    if {($PathFirst != {}) && ($PathFirst != {/})} {
	# The path is invalid: if it is not empty it must begin with "/".
	# This botch allows the command nevertheless to return a valid URI.
	set components(path) "/$components(path)"
    }

    if {($components(path) == {}) && ($components(type) != "")} {
	set components(path) "/"
	# FTP requires a non-empty path if $type is non-empty.
	# RFC 1738 Sec. 5, 
	# This botch enforces that.
    }

    return ftp://${uphp}$components(path)$type
}

proc ::uri::SplitHttps {url} {
    return [SplitHttpInner https $url]
}

proc ::uri::SplitHttp {url} {
    return [SplitHttpInner http $url]
}

proc ::uri::SplitHttpInner {scheme url} {
    # @c Splits the given http-<a url> into its constituents.
    # @a url: The url to split, without! scheme specification.
    # @r List containing the constituents, suitable for 'array set'.

    # general syntax:
    # //<host>:<port>/<path>?<searchpart>
    #
322
323
324
325
326
327
328

329
330
331
332
333
334
335
    #   Within the <path> and <searchpart> components, "/", ";", "?" are
    #   reserved.  The "/" character may be used within HTTP to designate a
    #   hierarchical structure.
    #
    # path == <cwd1> "/" ..."/" <cwdN> "/" <name> ["#" <fragment>]

    array set parts {host {} port {} path {} query {} fragment {}}


    set fragmentPattern "#(.*)\$"

    # slash off possible fragment.

    # NOTE: This must be done before the query, because a fragment can
    # follow a query, and slashing off the query first will take the







>







396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
    #   Within the <path> and <searchpart> components, "/", ";", "?" are
    #   reserved.  The "/" character may be used within HTTP to designate a
    #   hierarchical structure.
    #
    # path == <cwd1> "/" ..."/" <cwdN> "/" <name> ["#" <fragment>]

    array set parts {host {} port {} path {} query {} fragment {}}
    array set parts [list scheme $scheme]

    set fragmentPattern "#(.*)\$"

    # slash off possible fragment.

    # NOTE: This must be done before the query, because a fragment can
    # follow a query, and slashing off the query first will take the
357
358
359
360
361
362
363

364
365
366

367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397











398
399
400
401
402
403
404

405
406
407
408
409
410
411
412

413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435

436
437
438
439
440
441

442
443
444
445
446

447
448

449
450
451
452
453








454
455
456
457
458
459
460
461
462
463
464
465
	set url          [string replace $url $pos end]
    }

    if {[string match "//*" $url]} {
	set url [string range $url 2 end]

	array set parts [GetUPHP url]

    }

    set parts(path) [string trimleft $url /]


    return [array get parts]
}

proc ::uri::JoinHttp {args} {
    return [eval [linsert $args 0 ::uri::JoinHttpInner http 80]]
}

proc ::uri::JoinHttps {args} {
    return [eval [linsert $args 0 ::uri::JoinHttpInner https 443]]
}

proc ::uri::JoinHttpInner {scheme defport args} {
    set uphp [eval [linsert $args 0 ComposeUPHP $defport]]

    array set components {path {} query {} fragment {}}
    array set components $args

    set query {}
    if {[string length $components(query)]} {
	set query ?$components(query)
    }

    regsub -- {^/} $components(path) {} components(path)

    if { $components(fragment) != "" } {
	set components(fragment) "#$components(fragment)"
    } else {
	set components(fragment) ""
    }












    return $scheme://$uphp/$components(path)$query$components(fragment)
}

proc ::uri::SplitFile {url} {
    # @c Splits the given file-<a url> into its constituents.
    # @a url: The url to split, without! scheme specification.
    # @r List containing the constituents, suitable for 'array set'.


    upvar #0 [namespace current]::basic::hostspec	hostspec

    if {[string match "//*" $url]} {
	set url [string range $url 2 end]

	set hostPattern "^($hostspec)"


	switch -exact -- $::tcl_platform(platform) {
	    windows {
		# Catch drive letter
		append hostPattern :?
	    }
	    default {
		# Proceed as usual
	    }
	}

	if {[regexp -indices -- $hostPattern $url match host]} {
	    set fh	[lindex $host 0]
	    set th	[lindex $host 1]

	    set parts(host)	[string range $url $fh $th]

	    set  matchEnd   [lindex $match 1]
	    incr matchEnd

	    set url	[string range $url $matchEnd end]
	}
    }


    set parts(path) $url

    return [array get parts]
}

proc ::uri::JoinFile args {

    array set components {
	host {} port {} path {}
    }
    array set components $args


    switch -exact -- $::tcl_platform(platform) {
	windows {

	    if {[string length $components(host)]} {
		return file://$components(host):$components(path)
	    } else {
		return file://$components(path)
	    }








	}
	default {
	    set components(path) [string trimleft $components(path) /]
	    return file://$components(host)/$components(path)
	}
    }
}

proc ::uri::SplitMailto {url} {
    # @c Splits the given mailto-<a url> into its constituents.
    # @a url: The url to split, without! scheme specification.
    # @r List containing the constituents, suitable for 'array set'.







>


|
>















|







<
<






>
>
>
>
>
>
>
>
>
>
>
|






>








>
|
|
|
|
|
<
|
<















>






>





>
|
|
>
|
|
|
|
|
>
>
>
>
>
>
>
>

|
<
|
<







432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466


467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505

506

507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553

554

555
556
557
558
559
560
561
	set url          [string replace $url $pos end]
    }

    if {[string match "//*" $url]} {
	set url [string range $url 2 end]

	array set parts [GetUPHP url]
	# (also removes UPHP from url)
    }

    set parts(path) $url
    AddQuirk3986 parts

    return [array get parts]
}

proc ::uri::JoinHttp {args} {
    return [eval [linsert $args 0 ::uri::JoinHttpInner http 80]]
}

proc ::uri::JoinHttps {args} {
    return [eval [linsert $args 0 ::uri::JoinHttpInner https 443]]
}

proc ::uri::JoinHttpInner {scheme defport args} {
    set uphp [eval [linsert $args 0 ComposeUPHP $defport]]

    array set components {pbare 0 path {} query {} fragment {}}
    array set components $args

    set query {}
    if {[string length $components(query)]} {
	set query ?$components(query)
    }



    if { $components(fragment) != "" } {
	set components(fragment) "#$components(fragment)"
    } else {
	set components(fragment) ""
    }

    RemoveQuirk3986 components

    # Botch to accept certain invalid arguments instead of raising an error.

    set PathFirst [string index $components(path) 0]
    if {($PathFirst != {}) && ($PathFirst != {/})} {
	# The path is invalid: if it is not empty it must begin with "/".
	# This botch allows the command nevertheless to return a valid URI.
	set components(path) "/$components(path)"
    }

    return $scheme://$uphp$components(path)$query$components(fragment)
}

proc ::uri::SplitFile {url} {
    # @c Splits the given file-<a url> into its constituents.
    # @a url: The url to split, without! scheme specification.
    # @r List containing the constituents, suitable for 'array set'.
    variable Quirks

    upvar #0 [namespace current]::basic::hostspec	hostspec

    if {[string match "//*" $url]} {
	set url [string range $url 2 end]

	set hostPattern "^($hostspec)"

	if {    $Quirks(HostAsDriveLetter)
	     && ($::tcl_platform(platform) == "windows")
	} {
	    # Catch drive letter
	    append hostPattern :?
	} else {

	    # Proceed as usual

	}

	if {[regexp -indices -- $hostPattern $url match host]} {
	    set fh	[lindex $host 0]
	    set th	[lindex $host 1]

	    set parts(host)	[string range $url $fh $th]

	    set  matchEnd   [lindex $match 1]
	    incr matchEnd

	    set url	[string range $url $matchEnd end]
	}
    }

    # This always begins with "/" if $url is a valid absolute file:// URL.
    set parts(path) $url

    return [array get parts]
}

proc ::uri::JoinFile args {
    variable Quirks
    array set components {
	host {} port {} path {}
    }
    array set components $args

    if {    $Quirks(HostAsDriveLetter)
	 && ($::tcl_platform(platform) == "windows")
    } {
	# This misfeature is kept for compatibility with legacy code.
	if {[string length $components(host)]} {
	    return file://$components(host):$components(path)
	} else {
	    return file://$components(path)
	}
    } else {
        # Botch to accept certain invalid arguments instead of raising an error.
	if {[string index $components(path) 0] != "/"} {
	    # The path argument is invalid: it must begin with "/" (an empty
	    # path is not allowed for the scheme "file", RFC 1738 Sec. 5).
	    # This botch allows the command nevertheless to return a valid URI.
	    set components(path) "/$components(path)"
	} else {
	}


	return file://$components(host)$components(path)

    }
}

proc ::uri::SplitMailto {url} {
    # @c Splits the given mailto-<a url> into its constituents.
    # @a url: The url to split, without! scheme specification.
    # @r List containing the constituents, suitable for 'array set'.
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676

	set  matchEnd   [lindex $match 1]
	incr matchEnd

	set url	[string range $url $matchEnd end]
    }
    
    if {![string match /* $url] && $url ne {}} {
	error [list {invalid url} $url $url_save]
    }

    return [array get parts]
}

# ::uri::resolve --
#
#	Resolve an arbitrary URL, given a base URL
#
# This code depends on the ability of uri::split to process relative URIs.
# N.B. http(s): and ftp: path does not begin with "/" and may be empty.
# The file: path (unix) always begins "/", even if a host is specified.
#
# RFC 3986 Sec. 5.2 defines how URI relative resolution should proceed.
# This command is a "strict parser" in the sense of Sec. 5.2.2: it does not
# allow a relative URI such as "http:foo/bar.html".  See also the last example
# in Sec. 5.4.2 and uri-rfc2396.test test uri-rfc2396-11.19.
#
# Arguments:







|












|







745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772

	set  matchEnd   [lindex $match 1]
	incr matchEnd

	set url	[string range $url $matchEnd end]
    }
    
    if {(![string match /* $url]) && ($url ne {})} {
	error [list {invalid url} $url $url_save]
    }

    return [array get parts]
}

# ::uri::resolve --
#
#	Resolve an arbitrary URL, given a base URL
#
# This code depends on the ability of uri::split to process relative URIs.
# N.B. http(s): and ftp: path does not begin with "/" and may be empty.
# The file: path (unix or win) always begins "/", even if a host is specified.
#
# RFC 3986 Sec. 5.2 defines how URI relative resolution should proceed.
# This command is a "strict parser" in the sense of Sec. 5.2.2: it does not
# allow a relative URI such as "http:foo/bar.html".  See also the last example
# in Sec. 5.4.2 and uri-rfc2396.test test uri-rfc2396-11.19.
#
# Arguments:
692
693
694
695
696
697
698
699







700
701
702
703
704
705
706
	    file {
		set changed 0
		array set relparts [split $baseparts(scheme):$url]
		if {[array names relparts path] != {path}} {
		    set relparts(path) {}
		}
		if { [string match /* $url] } {
		    set baseparts(path) $relparts(path)







		    catch {
			if {$relparts(host) != ""} {
			    # RFC 3986 section 4.2 and 5.2.2.
			    # url has no scheme, but has authority
			    # ("UPHP" or User,Password,Host,Port). Use that
			    # authority. Do not transfer credentials or port
			    # number from the base authority.







|
>
>
>
>
>
>
>







788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
	    file {
		set changed 0
		array set relparts [split $baseparts(scheme):$url]
		if {[array names relparts path] != {path}} {
		    set relparts(path) {}
		}
		if { [string match /* $url] } {
		    set baseparts(path)  $relparts(path)
		    if {    [info exists baseparts(pbare)]
		         && [info exists relparts(pbare)]
		    } {
			# This test and action are sufficient to make
			# uri::resolve work for all schemes and quirk options.
			set baseparts(pbare) $relparts(pbare)
		    }
		    catch {
			if {$relparts(host) != ""} {
			    # RFC 3986 section 4.2 and 5.2.2.
			    # url has no scheme, but has authority
			    # ("UPHP" or User,Password,Host,Port). Use that
			    # authority. Do not transfer credentials or port
			    # number from the base authority.
722
723
724
725
726
727
728

729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756

757
758
759
760
761

762
763
764
765
766
767
768

769
770
771
772
773
774
775
		} elseif { [string length $relparts(path)] > 0 } {
		    set path [lreplace [::split $baseparts(path) /] end end]
		    set baseparts(path) "[::join $path /]/$relparts(path)"
		    set changed 1
		} else {
		    # Do not overwrite baseparts(path).  In this case,
		    # RFC 3986 Sec. 5.2.2 does not demand canonicalization.

		    # FIXME check whether it assumes the base URI is already canonical.
		    set canon 0
		}
	    }
	    default {
		return -code error "unable to resolve relative URL \"$url\""
	    }
	}

	# query and fragment are defined for http, https; not for file, ftp
	# FIXME check the RFCs re fragment: it is useful in HTML documents when
	# accessed by file or ftp.
	switch -- $baseparts(scheme) {
	    http -
	    https {
		if {[array names relparts query] != {query}} {
		    set relparts(query) {}
		}
		if {[array names relparts fragment] != {fragment}} {
		    set relparts(fragment) {}
		}

		if {$changed || ($relparts(query) != {})} {
		    set baseparts(query) $relparts(query)
		    set changed 1
		} else {
		    # Keep base query.
		    # FIXME error if url has empty query "?".

		}

		# RFC 3986 section 5.2.2 requires that the base fragment
		# is always discarded.
		set baseparts(fragment) $relparts(fragment)

		# FIXME (in split/join) empty fragment "#".
	    }
	    ftp -
	    file -
	    default {
	    }
	}

	set url [eval [linsert [array get baseparts] 0 join]]
	if {$canon} {
	    # RFC 3986 section 5.2.2 requires us to canonicalize the path.
	    set url [canonicalize $url]
	} else {
	}
	return $url







>
|









|
|
















>





>







>







825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
		} elseif { [string length $relparts(path)] > 0 } {
		    set path [lreplace [::split $baseparts(path) /] end end]
		    set baseparts(path) "[::join $path /]/$relparts(path)"
		    set changed 1
		} else {
		    # Do not overwrite baseparts(path).  In this case,
		    # RFC 3986 Sec. 5.2.2 does not demand canonicalization.
		    # FIXME check whether the RFC assumes the base URI is
		    # already canonical.
		    set canon 0
		}
	    }
	    default {
		return -code error "unable to resolve relative URL \"$url\""
	    }
	}

	# query and fragment are defined for http, https; not for file, ftp
	# Fragment is useful in HTML documents that are accessed by file or ftp,
	# but this is not supported by the RFCs.
	switch -- $baseparts(scheme) {
	    http -
	    https {
		if {[array names relparts query] != {query}} {
		    set relparts(query) {}
		}
		if {[array names relparts fragment] != {fragment}} {
		    set relparts(fragment) {}
		}

		if {$changed || ($relparts(query) != {})} {
		    set baseparts(query) $relparts(query)
		    set changed 1
		} else {
		    # Keep base query.
		    # FIXME error if url has empty query "?".
		    # FIXME (in split/join) empty query "?".
		}

		# RFC 3986 section 5.2.2 requires that the base fragment
		# is always discarded.
		set baseparts(fragment) $relparts(fragment)
		# FIXME error if url has empty fragment "#".
		# FIXME (in split/join) empty fragment "#".
	    }
	    ftp -
	    file -
	    default {
	    }
	}

	set url [eval [linsert [array get baseparts] 0 join]]
	if {$canon} {
	    # RFC 3986 section 5.2.2 requires us to canonicalize the path.
	    set url [canonicalize $url]
	} else {
	}
	return $url
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
#	Depends on scheme

proc ::uri::geturl {url args} {
    array set urlparts [split $url]

    switch -- $urlparts(scheme) {
	file {
        return [eval [linsert $args 0 file_geturl $url]]
	}
	default {
	    # Load a geturl package for the scheme first and only if
	    # that fails the scheme package itself. This prevents
	    # cyclic dependencies between packages.
	    if {[catch {package require $urlparts(scheme)::geturl}]} {
		package require $urlparts(scheme)
	    }
        return [eval [linsert $args 0 $urlparts(scheme)::geturl $url]]
	}
    }
}

# ::uri::file_geturl --
#
#	geturl implementation for file: scheme







|








|







916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
#	Depends on scheme

proc ::uri::geturl {url args} {
    array set urlparts [split $url]

    switch -- $urlparts(scheme) {
	file {
	    return [eval [linsert $args 0 file_geturl $url]]
	}
	default {
	    # Load a geturl package for the scheme first and only if
	    # that fails the scheme package itself. This prevents
	    # cyclic dependencies between packages.
	    if {[catch {package require $urlparts(scheme)::geturl}]} {
		package require $urlparts(scheme)
	    }
	    return [eval [linsert $args 0 $urlparts(scheme)::geturl $url]]
	}
    }
}

# ::uri::file_geturl --
#
#	geturl implementation for file: scheme
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892


893
894
895
896
897
898
899
900
901
902
#	A URL

proc ::uri::join args {
    array set components $args

    return [eval [linsert $args 0 Join[string totitle $components(scheme)]]]
}

# ::uri::canonicalize --
#
#	Canonicalize a URL
#
# Acknowledgements:
#	Andreas Kupries <[email protected]>
#	Keith Nash <[email protected]>
#
# Arguments:
#	uri	URI (which contains a path component)
#
# Results:
#	The canonical form of the URI



proc ::uri::canonicalize uri {

    # Make uri canonical with respect to dots (path changing commands)
    #
    # Remove single dots (.)  => pwd not changing
    # Remove double dots (..) => gobble previous segment of path
    #
    # Fixes for this command:
    #







|












|
>
>


<







979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003

1004
1005
1006
1007
1008
1009
1010
#	A URL

proc ::uri::join args {
    array set components $args

    return [eval [linsert $args 0 Join[string totitle $components(scheme)]]]
}

# ::uri::canonicalize --
#
#	Canonicalize a URL
#
# Acknowledgements:
#	Andreas Kupries <[email protected]>
#	Keith Nash <[email protected]>
#
# Arguments:
#	uri	URI (which contains a path component)
#
# Results:
#	The URI with the filename path in its canonical form.
#	This is not full URI "normalization" which may require further
#	processing.

proc ::uri::canonicalize uri {

    # Make uri canonical with respect to dots (path changing commands)
    #
    # Remove single dots (.)  => pwd not changing
    # Remove double dots (..) => gobble previous segment of path
    #
    # Fixes for this command:
    #
913
914
915
916
917
918
919


































920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936

937

938
939
940


941
942
943
944
945
946
947
    if {[catch {array set u [::uri::split $uri]}]} {
	return $uri
    }
    if {![info exists u(path)]} {
	return $uri
    }



































    set oldList [::split $u(path) /]

    if {[lindex $oldList 0] == {}} {
	set lead 1
    } else {
	set lead 0
    }

    set end [llength $oldList]
    incr end -1

    # i - index of element seg in oldList
    # j - index of last element written to newList
    set i 0
    set j -1
    set newList {}
    foreach seg $oldList {

	if {($seg == {}) && ($i != 0) && ($i != $end)} {

	    # Throw away this empty segment.
	    # This merges adjacent "/".
	    # If the first or last segment is empty, it is handled at "else".


	} elseif {($seg == {.}) && ($i == $end)} {
	    # Replace "." with {} to keep a trailing "/" in path.
	    lappend newList {}
	    incr j
	} elseif {$seg == {.}} {
	    # Throw away this "." segment.
	} elseif {($seg == {..}) && ($j > $lead - 1) && ($i == $end)} {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
















>
|
>



>
>







1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
    if {[catch {array set u [::uri::split $uri]}]} {
	return $uri
    }
    if {![info exists u(path)]} {
	return $uri
    }

    # RemoveDotSegments works perfectly well on paths without a leading "/", but
    # removing and re-adding the quirks ensures RFC 3986 conformance in a few
    # corner cases.
    RemoveQuirk3986 u
    set u(path) [RemoveDotSegments $u(path)]
    AddQuirk3986 u

    set uri [eval [linsert [array get u] 0 ::uri::join]]

    return $uri
}


# ::uri::RemoveDotSegments --
#
#	Remove any segments "." and ".." from a URI path.
#	Optionally remove empty segments {}.
#
#	Intended to implement the "remove_dot_segments" routine
#	defined in RFC 3986 Sec. 5.2.4.
#
# Acknowledgements:
#	Andreas Kupries <[email protected]>
#	Keith Nash <[email protected]>
#
# Arguments:
#	path	path component of a URI
#
# Results:
#	The URI path in its canonical form.

proc ::uri::RemoveDotSegments path {
    variable Quirks

    set oldList [::split $path /]

    if {[lindex $oldList 0] == {}} {
	set lead 1
    } else {
	set lead 0
    }

    set end [llength $oldList]
    incr end -1

    # i - index of element seg in oldList
    # j - index of last element written to newList
    set i 0
    set j -1
    set newList {}
    foreach seg $oldList {
	if {    $Quirks(RemoveDoubleSlashes)
	     && ($seg == {}) && ($i != 0) && ($i != $end)
	} {
	    # Throw away this empty segment.
	    # This merges adjacent "/".
	    # If the first or last segment is empty, it is handled at "else".
	    # Other empty segments are also handled at "else" if this quirk has
	    # not been requested.
	} elseif {($seg == {.}) && ($i == $end)} {
	    # Replace "." with {} to keep a trailing "/" in path.
	    lappend newList {}
	    incr j
	} elseif {$seg == {.}} {
	    # Throw away this "." segment.
	} elseif {($seg == {..}) && ($j > $lead - 1) && ($i == $end)} {
964
965
966
967
968
969
970















































971




972




973

974
975








































976
977
978
979
980
981
982
	    lappend newList $seg
	    incr j
	}

	incr i
    }
















































    set u(path) [::join $newList /]




    set uri [eval [linsert [array get u] 0 ::uri::join]]






    return $uri
}









































# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# regular expressions covering various url schemes

# Currently known URL schemes:
#
# (RFC 1738)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
>
>
>
>
|
>
|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
	    lappend newList $seg
	    incr j
	}

	incr i
    }

    return [::join $newList /]
}


# ::uri::RemoveQuirk3986
#
#	Work on an array produced by uri::split. Read the path and pbare
#	elements, and convert the path element to RFC 3986 compliance from
#	NoInitialSlash and NoExtraKeys quirks modes IF the caller has requested
#	these quirks AND they are used by the array's scheme.
#
#	Full RFC 3986 compliance is not possible if the caller has set both the
#	quirks NoInitialSlash and NoExtraKeys.  This mode is offered for
#	backward compatibility.  See documentation uri(n).
#
# Arguments:
#	arrName	    Name of array in the caller's stack frame that holds the
#		    results of uri::split.
# Results:
#	No return value.  The array is modified as a side effect.

proc ::uri::RemoveQuirk3986 {arrName} {
    variable Quirks
    upvar 1 $arrName u

    if {    $Quirks(NoInitialSlash)
	 && ([lsearch {http https ftp} $u(scheme)] != -1)
    } {
        if {$Quirks(NoExtraKeys)} {
	    array set u {pbare 0}
	} else {
	    # Keep existing value of u(pbare).
	}

	set PathFirst [string index $u(path) 0]
	if {($PathFirst != {}) && ($PathFirst != {/})} {
	    # If the quirk is set and used, then the leading "/" of the path has
	    # been stripped.  Put it back.
	    set u(path) "/$u(path)"
	} elseif {($PathFirst != {}) && ($PathFirst == {/})} {
	    # In principle we should prepend "/" to u(path) here too, but this
	    # leads to perverse results, e.g. uri::join with path "/" becomes
	    # path "//".
	} elseif {($PathFirst == {}) && (!$u(pbare))} {
	    # This is how {} and / are distinguished for the value of the
	    # 3986-defined path, when the quirk is set and used, i.e. when the
	    # leading "/" of the path has been stripped.
	    set u(path) "/"
	} else {
	    # Leave u(path) unchanged.
	}
    }

    if {$Quirks(NoInitialSlash) && (!$Quirks(NoExtraKeys))} {
	# pbare is required
    } else {
	array unset u pbare
    }

    return
}

# ::uri::AddQuirk3986
#
#	Work on an array produced by uri::split. Read the path element, and
#	convert the path and pbare elements from RFC 3986 compliance to
#	NoInitialSlash and NoExtraKeys quirks modes IF the caller has requested
#	these quirks AND they are used by the array's scheme.
#
# Arguments:
#	arrName	    Name of array in the caller's stack frame that holds the
#		    results of uri::split.
# Results:
#	No return value.  The array is modified as a side effect.

proc ::uri::AddQuirk3986 arrName {
    variable Quirks
    upvar 1 $arrName u

    array unset u pbare

    if {    $Quirks(NoInitialSlash)
	 && ([lsearch {http https ftp} $u(scheme)] != -1)
    } {
	if {$Quirks(NoExtraKeys)} {
	    # u(pbare) is refused
	} elseif {($u(path) == {})} {
	    set u(pbare) 1
	} else {
	    set u(pbare) 0
	}
	# In principle we should remove only the first "/", not all
	# of them, but it in this quirk regime it is cleaner to keep the
	# rule that the path never begins with "/".
	set u(path) [string trimleft $u(path) /]
    } else {
    }

    return
}


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# regular expressions covering various url schemes

# Currently known URL schemes:
#
# (RFC 1738)
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
# ------------------------------------------------


# ------------------------------------------------------------------------------
#     IMPORTANT WARNINGS
# ------------------------------------------------------------------------------
# (1) THE PATTERNS DEFINED BELOW (with one exception) ARE NOT USED FOR PARSING
#     URLS BY ANY OF THIS PACKAGE'S COMMANDS.
# (2) THAT EXCEPTION IS THE VARIABLE ::uri::ftp::typepart
# (3) AS LONG AS THAT VARIABLE IS ASSIGNED THE CORRECT VALUE, ALL THE
#     uri::register CALLS CAN BE DELETED WITHOUT AFFECTING THE uri::* COMMANDS.
# (2) REGISTRATION OF A SCHEME DOES NOT IMPLEMENT COMMANDS FOR THAT SCHEME.
# (3) REGISTRATION OF A SCHEME IS NOT NECESSARY TO IMPLEMENT COMMANDS FOR THAT
#     SCHEME.
#     Instead:







|







1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
# ------------------------------------------------


# ------------------------------------------------------------------------------
#     IMPORTANT WARNINGS
# ------------------------------------------------------------------------------
# (1) THE PATTERNS DEFINED BELOW (with one exception) ARE NOT USED FOR PARSING
#     URLs BY ANY OF THIS PACKAGE'S COMMANDS.
# (2) THAT EXCEPTION IS THE VARIABLE ::uri::ftp::typepart
# (3) AS LONG AS THAT VARIABLE IS ASSIGNED THE CORRECT VALUE, ALL THE
#     uri::register CALLS CAN BE DELETED WITHOUT AFFECTING THE uri::* COMMANDS.
# (2) REGISTRATION OF A SCHEME DOES NOT IMPLEMENT COMMANDS FOR THAT SCHEME.
# (3) REGISTRATION OF A SCHEME IS NOT NECESSARY TO IMPLEMENT COMMANDS FOR THAT
#     SCHEME.
#     Instead:
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
    variable	path [set [namespace parent [namespace current]]::ftp::path]

    variable	schemepart	"//(${host}|localhost)?/${path}"
    variable	url		"file:${schemepart}"
}

# HTTP
uri::register http {
    # Please read the warnings above.
    variable	escape \
        [set [namespace parent [namespace current]]::basic::escape]
    variable	hostOrPort	\
        [set [namespace parent [namespace current]]::basic::hostOrPort]

    variable	charN		{[a-zA-Z0-9$_.+!*'(,);:@&=-]}







|







1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
    variable	path [set [namespace parent [namespace current]]::ftp::path]

    variable	schemepart	"//(${host}|localhost)?/${path}"
    variable	url		"file:${schemepart}"
}

# HTTP
uri::register {http https} {
    # Please read the warnings above.
    variable	escape \
        [set [namespace parent [namespace current]]::basic::escape]
    variable	hostOrPort	\
        [set [namespace parent [namespace current]]::basic::hostOrPort]

    variable	charN		{[a-zA-Z0-9$_.+!*'(,);:@&=-]}
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
    variable	fieldspec	";${fieldname}=${fieldvalue}"

    variable	schemepart	"//${hostOrPort}/${path}(${fieldspec})*"
    variable	url		"prospero:$schemepart"
}

# LDAP
uri::register ldap {
    # Please read the warnings above.
    variable	hostOrPort \
        [set [namespace parent [namespace current]]::basic::hostOrPort]

    # very crude parsing
    variable	dn		{[^?]*}
    variable	attrs		{[^?]*}







|







1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
    variable	fieldspec	";${fieldname}=${fieldvalue}"

    variable	schemepart	"//${hostOrPort}/${path}(${fieldspec})*"
    variable	url		"prospero:$schemepart"
}

# LDAP
uri::register {ldap ldaps} {
    # Please read the warnings above.
    variable	hostOrPort \
        [set [namespace parent [namespace current]]::basic::hostOrPort]

    # very crude parsing
    variable	dn		{[^?]*}
    variable	attrs		{[^?]*}

Changes to modules/uri/uri.test.

16
17
18
19
20
21
22
23
24





































25
26
27

28
29
30
31

32
33
34
35

36
37
38
39

40
41
42
43

44
45
46
47

48
49
50
51

52
53
54
55

56
57
58
59

60
61
62
63

64
65
66
67

68
69
70
71

72
73
74
75

76
77
78
79

80
81
82
83

84
85
86
87

88
89
90
91

92
93
94
95

96
97
98
99

100
101
102
103

104
105
106
107

108
109
110
111

112
113
114
115

116
117
118
119

120
121
122
123

124
125
126
127

128
129
130
131

132
133
134
135

136
137
138
139

140
141
142
143

144
145
146
147

148
149
150
151

152
153
154
155

156
157
158
159

160
161
162
163

164
165
166
167

168
169
170
171

172
173
174
175

176
177
178
179

180
181
182
183

184
185
186
187

188
189
190
191

192
193
194
195

196
197
198
199

200
201
202
203

204
205
206
207

208
209





















































































































































































































































































210
211

212
213
214
215

216
217
218
219

220
221
222
223

224
225
226
227

228
229
230
231

232
233
234
235

236
237
238
239

240
241
242
243

244
245
246
247




248

































































































































































































































































249

250
251
252
253

254
255
256
257

258
259
260
261

262
263
264
265

266
267
268
269

270
271
272
273

274
275
276
277

278
279
280
281

282
283
284
285

286
287
288
289

290
291
292
293

294
295
296
297

298
299
300
301
302
303
304

305
306
307
308

309
310
311
312

313
314
315
316

317
318
319
320

321
322
323
324

325
326
327
328
329
330

331
332
333
334

335
336
337
338

339
340
341
342

343
344
345
346

347
348
349
350

351
352
353
354

355
356
357
358

359
360
361
362

363
364
365
366

367
368
369
370

371
372
373
374

375
376
377
378

379
380
381
382

383
384
385
386

387
388
389
390

391
392
393
394

395
396
397
398

399
400
401
402

403
404
405
406

407
408
409
410

411
412
413
414

415
416
417
418

419
420
421
422

423
424
425
426

427
428
429
430

431
432
433






























434

435
436
437
438
439
440
441

testsNeedTcl     8.2
testsNeedTcltest 1.0

testing {
    useLocal uri.tcl uri
}

# -------------------------------------------------------------------------





































# Split tests

test uri-1.0 {uri::split - http w/- nested query} {

    dictsort [uri::split http://test.net/path/path2?query=url?otherquery]
} {fragment {} host test.net path path/path2 port {} pwd {} query query=url?otherquery scheme http user {}}

test uri-1.1 {uri::split - http w/- query} {

    dictsort [uri::split http://test.net/path/path2?query]
} {fragment {} host test.net path path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.2 {uri::split - https w/- query} {

    dictsort [uri::split https://test.net/path/path2?query]
} {fragment {} host test.net path path/path2 port {} pwd {} query query scheme https user {}}

test uri-1.3 {uri::split - http w/- port} {

    dictsort [uri::split http://test.net:8080]
} {fragment {} host test.net path {} port 8080 pwd {} query {} scheme http user {}}

test uri-1.4 {uri::split - https w/- port} {

    dictsort [uri::split https://test.net:8888]
} {fragment {} host test.net path {} port 8888 pwd {} query {} scheme https user {}}

test uri-1.5 {uri::split - ftp} {

    dictsort [uri::split ftp://ftp.test.net/path/to/resource]
} {host ftp.test.net path path/to/resource port {} pwd {} scheme ftp type {} user {}}

test uri-1.6 {uri::split - ftp with userinfo} {

    dictsort [uri::split {ftp://user:passwd@localhost/a/b/c.d}]
} {host localhost path a/b/c.d port {} pwd passwd scheme ftp type {} user user}

test uri-1.7 {uri::split - ftp with type} {

    dictsort [uri::split {ftp://localhost/a/b/c.d;type=i}]
} {host localhost path a/b/c.d port {} pwd {} scheme ftp type i user {}}

test uri-1.8 {uri::split - ftp with port} {

    dictsort [uri::split {ftp://localhost:21/a/b/c.d}]
} {host localhost path a/b/c.d port 21 pwd {} scheme ftp type {} user {}}

test uri-1.9 {uri::split - news with message-id} {

    dictsort [uri::split {news:[email protected]}]
} {message-id [email protected] scheme news}

test uri-1.10 {uri::split - news with newsgroup-name} {

    dictsort [uri::split {news:comp.lang.tcl}]
} {newsgroup-name comp.lang.tcl scheme news}

test uri-1.11 {uri::split - ldap simple} {

    dictsort [uri::split {ldap://ldaphost}]
} {attrs {} dn {} extensions {} filter {} host ldaphost port {} scheme ldap scope {}}

test uri-1.12 {uri::split - ldaps with port} {

    dictsort [uri::split {ldaps://h:636/}]
} {attrs {} dn {} extensions {} filter {} host h port 636 scheme ldaps scope {}}

test uri-1.13 {uri::split - ldap search} {

    dictsort [uri::split {ldap://ldaphost/o=mycomp?uid,mail?sub?(uid=pda)}]
} {attrs {uid mail} dn o=mycomp extensions {} filter (uid=pda) host ldaphost port {} scheme ldap scope sub}

test uri-1.14 {uri::split - ldap search with implicit scope an attributes} {

    dictsort [uri::split {ldap://ldaphost:999/o=mycomp???(uid=pda)}]
} {attrs {} dn o=mycomp extensions {} filter (uid=pda) host ldaphost port 999 scheme ldap scope {}}

test uri-1.15 {uri::split - https with IPv6} {

    dictsort [uri::split {https://[2001:db8::7]:8080?foo=bar}]
} {fragment {} host {[2001:db8::7]} path {} port 8080 pwd {} query foo=bar scheme https user {}}

test uri-1.16 {uri::split - ftp with auth and IPv6} {

    dictsort [uri::split {ftp://user:pass@[2001:db8::7]/alt}]
} {host {[2001:db8::7]} path alt port {} pwd pass scheme ftp type {} user user}

test uri-1.17 {uri::split - ldaps IPv6 search with port} {

    dictsort [uri::split {ldaps://[2001:db8::7]:987/o=mycomp?uid,mail?sub?(uid=pda)}]
} {attrs {uid mail} dn o=mycomp extensions {} filter (uid=pda) host {[2001:db8::7]} port 987 scheme ldaps scope sub}

test uri-1.18 {uri::split - http w/- valid hostname on local network} {

    dictsort [uri::split http://test-host/path/path2?query]
} {fragment {} host test-host path path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.19 {uri::split - http w/- valid hostname on local network FQDN} {

    dictsort [uri::split http://test-host./path/path2?query]
} {fragment {} host test-host. path path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.20 {uri::split - http w/- valid hostname on local network and port} {

    dictsort [uri::split http://test-host:8080/path/path2?query]
} {fragment {} host test-host path path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.21 {uri::split - http w/- valid hostname on local network FQDN and port} {

    dictsort [uri::split http://test-host.:8080/path/path2?query]
} {fragment {} host test-host. path path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.22 {uri::split - http w/- valid hostname "9" on local network} {

    dictsort [uri::split http://9/path/path2?query]
} {fragment {} host 9 path path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.23 {uri::split - http w/- valid hostname "9" on local network FQDN} {

    dictsort [uri::split http://9./path/path2?query]
} {fragment {} host 9. path path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.24 {uri::split - http w/- valid hostname "9" on local network and port} {

    dictsort [uri::split http://9:8080/path/path2?query]
} {fragment {} host 9 path path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.25 {uri::split - http w/- valid hostname "9" on local network FQDN and port} {

    dictsort [uri::split http://9.:8080/path/path2?query]
} {fragment {} host 9. path path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.26 {uri::split - http w/- valid hostname "0-9" on local network} {

    dictsort [uri::split http://0-9/path/path2?query]
} {fragment {} host 0-9 path path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.27 {uri::split - http w/- valid hostname "0-9" on local network FQDN} {

    dictsort [uri::split http://0-9./path/path2?query]
} {fragment {} host 0-9. path path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.28 {uri::split - http w/- valid hostname "0-9" on local network and port} {

    dictsort [uri::split http://0-9:8080/path/path2?query]
} {fragment {} host 0-9 path path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.29 {uri::split - http w/- valid hostname "0-9" on local network FQDN and port} {

    dictsort [uri::split http://0-9.:8080/path/path2?query]
} {fragment {} host 0-9. path path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.30 {uri::split - http w/- nested query and FQDN} {

    dictsort [uri::split http://test.net./path/path2?query=url?otherquery]
} {fragment {} host test.net. path path/path2 port {} pwd {} query query=url?otherquery scheme http user {}}

test uri-1.31 {uri::split - http w/- nested query and FQDN and port} {

    dictsort [uri::split http://test.net.:8080/path/path2?query=url?otherquery]
} {fragment {} host test.net. path path/path2 port 8080 pwd {} query query=url?otherquery scheme http user {}}

test uri-1.32 {uri::split - http w/- query test / in query} {

    dictsort [uri::split http://test.net/path/path2?fetch=dir/file.txt]
} {fragment {} host test.net path path/path2 port {} pwd {} query fetch=dir/file.txt scheme http user {}}

test uri-1.33 {uri::split - http w/- fragment test / ? in fragment} {

    dictsort [uri::split http://test.net/path/path2?fetch=dir/file.txt#ab5/s?too]
} {fragment ab5/s?too host test.net path path/path2 port {} pwd {} query fetch=dir/file.txt scheme http user {}}

test uri-1.34 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {

    dictsort [uri::split http://test.net/path/path2?fetch=dir/file.txt#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path path/path2 port {} pwd {} query fetch=dir/file.txt scheme http user {}}

test uri-1.35 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {

    dictsort [uri::split http://test.net/path/path2#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path path/path2 port {} pwd {} query {} scheme http user {}}

test uri-1.36 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {

    dictsort [uri::split http://test.net/#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path {} port {} pwd {} query {} scheme http user {}}

test uri-1.37 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {

    dictsort [uri::split http://test.net#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path {} port {} pwd {} query {} scheme http user {}}

test uri-1.38 {uri::split - relative URI} {

    dictsort [uri::split //test.net#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path {} port {} pwd {} query {} scheme http user {}}

test uri-1.39 {uri::split - relative URI} {

    dictsort [uri::split //test.net#ab5/s?to#o{and}fg https]
} {fragment ab5/s?to#o{and}fg host test.net path {} port {} pwd {} query {} scheme https user {}}

test uri-1.40 {uri::split - relative URI {}} {

    dictsort [uri::split {}]
} {fragment {} host {} path {} port {} pwd {} query {} scheme http user {}}

test uri-1.41 {uri::split - relative URI http cf bug 2798448} {

    dictsort [uri::split host.td]
} {fragment {} host host.td path {} port {} pwd {} query {} scheme http user {}}

test uri-1.42 {uri::split - relative URI http cf bug 2798448} {

    dictsort [uri::split http://host.td]
} {fragment {} host host.td path {} port {} pwd {} query {} scheme http user {}}

test uri-1.43 {uri::split - relative URI ftp cf bug 2798448} {

    dictsort [uri::split host.td ftp]
} {host host.td path {} port {} pwd {} scheme ftp type {} user {}}

test uri-1.44 {uri::split - relative URI ftp cf bug 2798448} {

    dictsort [uri::split ftp://host.td]
} {host host.td path {} port {} pwd {} scheme ftp type {} user {}}

test uri-1.45 {uri::split relative URI http/https/ftp path} {

    dictsort [::uri::split gone/away]
} {fragment {} host gone path away port {} pwd {} query {} scheme http user {}}






















































































































































































































































































test uri-1.46 {uri::split relative URI http/https/ftp path} {

    dictsort [::uri::split /gone/away]
} {fragment {} host {} path gone/away port {} pwd {} query {} scheme http user {}}

test uri-1.47 {uri::split relative URI http/https/ftp path} {

    dictsort [::uri::split //gone/away]
} {fragment {} host gone path away port {} pwd {} query {} scheme http user {}}

test uri-1.48 {uri::split relative URI http/https/ftp path} {

    dictsort [::uri::split ///gone/away]
} {fragment {} host {} path gone/away port {} pwd {} query {} scheme http user {}}

test uri-1.49 {uri::split relative URI http/https/ftp path} {

    dictsort [::uri::split ////gone/away]
} {fragment {} host {} path gone/away port {} pwd {} query {} scheme http user {}}

test uri-1.50 {uri::split relative URI file path} {

    dictsort [::uri::split gone/away file]
} {path gone/away scheme file}

test uri-1.51 {uri::split relative URI file path} {

    dictsort [::uri::split /gone/away file]
} {path /gone/away scheme file}

test uri-1.52 {uri::split relative URI file path} {

    dictsort [::uri::split //gone/away file]
} {host gone path /away scheme file}

test uri-1.53 {uri::split relative URI file path} {

    dictsort [::uri::split ///gone/away file]
} {path /gone/away scheme file}

test uri-1.54 {uri::split relative URI file path} {

    dictsort [::uri::split ////gone/away file]
} {path //gone/away scheme file}

# -------------------------------------------------------------------------






































































































































































































































































test uri-2.1 {uri::join - http} {

    uri::join scheme http path / host www.w3.org
} http://www.w3.org/

test uri-2.2 {uri::join - https} {

    uri::join scheme https path / host www.w3.org
} https://www.w3.org/

test uri-2.3 {uri::join - http w/- query} {

    uri::join scheme http query abc=def&ghi=jkl host www.test.net path /path/
} http://www.test.net/path/?abc=def&ghi=jkl

test uri-2.4 {uri::join - https w/- query} {

    uri::join scheme https query abc=def&ghi=jkl host www.test.net path /path/
} https://www.test.net/path/?abc=def&ghi=jkl

test uri-2.5 {uri::join - http w/- port} {

    uri::join scheme http port 8080 host www.test.net path /path/
} http://www.test.net:8080/path/

test uri-2.6 {uri::join - https w/- port} {

    uri::join scheme https port 8888 host www.test.net path /path/
} https://www.test.net:8888/path/

test uri-2.7 {uri::join - ftp} {

    uri::join host ftp.test.net path /my/file scheme ftp
} ftp://ftp.test.net/my/file

test uri-2.8 {uri::join - identity function} {

    eval uri::join [uri::split http://www.w3.org/XML/?abc=def]
} http://www.w3.org/XML/?abc=def

test uri-2.9 {uri::join - ftp userinfo check} {

    eval uri::join scheme ftp host localhost port 21 path /filename user user pwd passwd
} {ftp://user:passwd@localhost:21/filename}

test uri-2.10 {uri::join - ftp userinfo check with no passwd} {

    eval uri::join scheme ftp host localhost path /filename user user
} {ftp://user@localhost/filename}

test uri-2.11 {uri::join - ftp path prefix} {

    eval uri::join scheme ftp host localhost path a/b/c.d
} ftp://localhost/a/b/c.d

test uri-2.12 {uri::join - ftp w/- image type} {

    eval uri::join scheme ftp host localhost path a/b/c.d type i
} {ftp://localhost/a/b/c.d;type=i}

test uri-2.13 {uri::join - ftp w/- ascii type} {

    eval uri::join scheme ftp host localhost path a/b/c.d type a
} {ftp://localhost/a/b/c.d;type=a}

# I am not sure that this shouldn't produce an error. The semi-colon is 
# reserved so in this case with an invalid suffix the semi-colon should
# probably be quoted. [PT]
test uri-2.14 {uri::join - ftp w/- invalid type} {

    eval uri::join scheme ftp host localhost path a/b/c.d type X
} {ftp://localhost/a/b/c.d;type=X}

test uri-2.15 {uri::join - news message-id} {

    eval uri::join scheme news message-id [email protected]
} {news:[email protected]}

test uri-2.16 {uri::join - news newsgroup-name} {

    eval uri::join scheme news newsgroup-name comp.lang.tcl
} {news:comp.lang.tcl}

test uri-2.17 {uri::join - ldap simple} {

    uri::join scheme ldap host ldaphost
} {ldap://ldaphost}

test uri-2.18 {uri::join - ldaps with default port} {

    uri::join scheme ldaps host ldaphost port 636
} {ldaps://ldaphost}

test uri-2.19 {uri::join - ldaps with port} {

    uri::join scheme ldaps host ldaphost port 999
} {ldaps://ldaphost:999}

test uri-2.20 {uri::join - ldap search} {
    # I should use "attrs {uid mail}" and not "attrs uid,mail"
    # but this is a perverse effect of the "eval" command

    uri::join attrs uid,mail dn o=mycomp filter (uid=pda) host ldaphost scheme ldap scope sub
} {ldap://ldaphost/o=mycomp?uid,mail?sub?(uid=pda)}

test uri-2.21 {uri::join - ldap search with implicit scope an attributes} {

    uri::join dn o=mycomp filter (uid=pda) host ldaphost port 999 scheme ldap
} {ldap://ldaphost:999/o=mycomp???(uid=pda)}

test uri-2.22 {uri::join - https w/- query user pwd frag} {

    uri::join scheme https query abc=def&ghi=jkl host www.test.net path /path/ user user pwd passwd fragment f
} https://user:[email protected]/path/?abc=def&ghi=jkl#f

test uri-2.23 {uri::join - https w/- query user pwd frag FQDN} {

    uri::join scheme https query abc=def&ghi=jkl host www.test.net. path /path/ user user pwd passwd fragment f
} https://user:[email protected]./path/?abc=def&ghi=jkl#f

test uri-2.24 {uri::join - https w/- query user pwd frag port} {

    uri::join scheme https query abc=def&ghi=jkl host www.test.net path /path/ user user pwd passwd fragment f port 8080
} https://user:[email protected]:8080/path/?abc=def&ghi=jkl#f

test uri-2.25 {uri::join - https w/- query user pwd frag FQDN port} {

    uri::join scheme https query abc=def&ghi=jkl host www.test.net. path /path/ user user pwd passwd fragment f port 8080
} https://user:[email protected].:8080/path/?abc=def&ghi=jkl#f

test uri-2.26 {uri::join - https w/- query user pwd frag valid hostname on local network} {

    uri::join scheme https query abc=def&ghi=jkl host test-host path /path/ user user pwd passwd fragment f
} https://user:passwd@test-host/path/?abc=def&ghi=jkl#f

test uri-2.27 {uri::join - https w/- query user pwd frag valid hostname on local network FQDN} {

    uri::join scheme https query abc=def&ghi=jkl host test-host. path /path/ user user pwd passwd fragment f
} https://user:passwd@test-host./path/?abc=def&ghi=jkl#f

test uri-2.28 {uri::join - https w/- query user pwd frag valid hostname on local network port} {

    uri::join scheme https query abc=def&ghi=jkl host test-host path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@test-host:8080/path/?abc=def&ghi=jkl#f

test uri-2.29 {uri::join - https w/- query user pwd frag valid hostname on local network FQDN port} {

    uri::join scheme https query abc=def&ghi=jkl host test-host. path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@test-host.:8080/path/?abc=def&ghi=jkl#f

test uri-2.30 {uri::join - https w/- query user pwd frag valid hostname "9" on local network} {

    uri::join scheme https query abc=def&ghi=jkl host 9 path /path/ user user pwd passwd fragment f
} https://user:passwd@9/path/?abc=def&ghi=jkl#f

test uri-2.31 {uri::join - https w/- query user pwd frag valid hostname "9" on local network FQDN} {

    uri::join scheme https query abc=def&ghi=jkl host 9. path /path/ user user pwd passwd fragment f
} https://user:passwd@9./path/?abc=def&ghi=jkl#f

test uri-2.32 {uri::join - https w/- query user pwd frag valid hostname "9" on local network port} {

    uri::join scheme https query abc=def&ghi=jkl host 9 path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@9:8080/path/?abc=def&ghi=jkl#f

test uri-2.33 {uri::join - https w/- query user pwd frag valid hostname "9" on local network FQDN port} {

    uri::join scheme https query abc=def&ghi=jkl host 9. path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@9.:8080/path/?abc=def&ghi=jkl#f

test uri-2.34 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network} {

    uri::join scheme https query abc=def&ghi=jkl host 0-9 path /path/ user user pwd passwd fragment f
} https://user:passwd@0-9/path/?abc=def&ghi=jkl#f

test uri-2.35 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network FQDN} {

    uri::join scheme https query abc=def&ghi=jkl host 0-9. path /path/ user user pwd passwd fragment f
} https://user:passwd@0-9./path/?abc=def&ghi=jkl#f

test uri-2.36 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network port} {

    uri::join scheme https query abc=def&ghi=jkl host 0-9 path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@0-9:8080/path/?abc=def&ghi=jkl#f

test uri-2.37 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network FQDN port} {

    uri::join scheme https query abc=def&ghi=jkl host 0-9. path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@0-9.:8080/path/?abc=def&ghi=jkl#f

test uri-2.38 {uri::join -- scheme file, do not use first segment of path as host} {

    ::uri::join path b/c/d scheme file
} file:///b/c/d

test uri-2.39 {uri::join -- scheme file, usual case} {

    ::uri::join path /b/c/d scheme file
} file:///b/c/d

test uri-2.40 {uri::join -- scheme file, trimleft excess "/", do not use first segment of path as host} {

    ::uri::join path //b/c/d scheme file
} file:///b/c/d

test uri-2.41 {uri::join -- scheme file, trimleft excess "/", do not use first segment of path as host} {

    ::uri::join path ///b/c/d scheme file
} file:///b/c/d

test uri-2.42 {uri::join -- scheme file, trimleft excess "/", do not use first segment of path as host} {

    ::uri::join path ////b/c/d scheme file
} file:///b/c/d

test uri-2.43 {uri::join -- with uri::split, identity function preserves user:pwd for http; appends "/"} {

  eval ::uri::join [::uri::split http://anonymous:[email protected]]
} http://anonymous:[email protected]/

test uri-2.44 {uri::join -- with uri::split, identity function preserves user:pwd and port for http} {

    eval ::uri::join [::uri::split http://anonymous:[email protected]:8080/foo]
} http://anonymous:[email protected]:8080/foo

test uri-2.45 {uri::join -- with uri::split, identity function preserves user:pwd and port for http FQDN} {

    eval ::uri::join [::uri::split http://anonymous:[email protected].:8080/foo]
} http://anonymous:[email protected].:8080/foo































# -------------------------------------------------------------------------


test uri-3.1 {uri::resolve - relative URL, base trailing slash} {
    uri::resolve http://www.w3.org/path/ test.html
} http://www.w3.org/path/test.html

test uri-3.2 {uri::resolve - relative URL path, base trailing slash} {
    uri::resolve http://www.w3.org/path/ relpath/test.html









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|
>

|

|
>

|

|
>

|

|
>



|
>



|
>

|

|
>

|

|
>

|

|
>

|

|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>

|

|
>



|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>

|

|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>

|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
>

|

|
>

|

|
>

|

|
>

|

|
>



|
>



|
>



|
>



|
>




>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>






|
>



|
>



|
>



|
>



|
>



|
>



|


>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>



|
>

|
|
|
>

|
|
|
>

|
|
|
>

|

|
>



|
>



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147

testsNeedTcl     8.2
testsNeedTcltest 1.0

testing {
    useLocal uri.tcl uri
}

# -------------------------------------------------------------------------
# Quirk Option NoInitialSlash
# -------------------------------------------------------------------------
#   uri::split, uri::join
# - Commands uri::split, uri::join have separate tests for each boolean
#   value of the quirk option NoInitialSlash.
# - Tests *-0, *-1 use [::uri::setQuirkOption NoInitialSlash] values
#   0, 1 respectively.
# - For tests of uri::split, the results of tests *-1 remove the leading "/"
#   from the path, and define key pbare.
# - Any other differences in the test script or the results are noted in the
#   test description with the words "differs from".
#
#   uri::isrelative, uri::resolve, uri::canonicalize
# - Command uri::isrelative does not involve option NoInitialSlash.
# - Commands uri::resolve, uri::canonicalize should give results that are
#   independent of NoInitialSlash, and so do not have separate tests for
#   each case.  The non-default value of NoInitialSlash can be tested by
#   setting the value of BaseValue(NoInitialSlash) below.
# -------------------------------------------------------------------------

# -------------------------------------------------------------------------
# Quirk Options NoExtraKeys and (for Windows) HostAsDriveLetter
# -------------------------------------------------------------------------
# Some tests will fail if these options are set true.
# Separate tests have not been written for these cases.
# -------------------------------------------------------------------------

set BaseValue(NoInitialSlash) [::uri::setQuirkOption NoInitialSlash]
# set BaseValue(NoInitialSlash) 1

::uri::setQuirkOption NoInitialSlash $BaseValue(NoInitialSlash)
# ::uri::setQuirkOption NoExtraKeys         0
# ::uri::setQuirkOption HostAsDriveLetter   0
# set ::tcl_platform(platform)              windows
# ::uri::setQuirkOption RemoveDoubleSlashes 1

# -------------------------------------------------------------------------
# Split tests

test uri-1.0-0 {uri::split - http w/- nested query} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net/path/path2?query=url?otherquery]
} {fragment {} host test.net path /path/path2 port {} pwd {} query query=url?otherquery scheme http user {}}

test uri-1.1-0 {uri::split - http w/- query} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net/path/path2?query]
} {fragment {} host test.net path /path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.2-0 {uri::split - https w/- query} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split https://test.net/path/path2?query]
} {fragment {} host test.net path /path/path2 port {} pwd {} query query scheme https user {}}

test uri-1.3-0 {uri::split - http w/- port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net:8080]
} {fragment {} host test.net path {} port 8080 pwd {} query {} scheme http user {}}

test uri-1.4-0 {uri::split - https w/- port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split https://test.net:8888]
} {fragment {} host test.net path {} port 8888 pwd {} query {} scheme https user {}}

test uri-1.5-0 {uri::split - ftp} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split ftp://ftp.test.net/path/to/resource]
} {host ftp.test.net path /path/to/resource port {} pwd {} scheme ftp type {} user {}}

test uri-1.6-0 {uri::split - ftp with userinfo} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {ftp://user:passwd@localhost/a/b/c.d}]
} {host localhost path /a/b/c.d port {} pwd passwd scheme ftp type {} user user}

test uri-1.7-0 {uri::split - ftp with type} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {ftp://localhost/a/b/c.d;type=i}]
} {host localhost path /a/b/c.d port {} pwd {} scheme ftp type i user {}}

test uri-1.8-0 {uri::split - ftp with port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {ftp://localhost:21/a/b/c.d}]
} {host localhost path /a/b/c.d port 21 pwd {} scheme ftp type {} user {}}

test uri-1.9-0 {uri::split - news with message-id} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {news:[email protected]}]
} {message-id [email protected] scheme news}

test uri-1.10-0 {uri::split - news with newsgroup-name} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {news:comp.lang.tcl}]
} {newsgroup-name comp.lang.tcl scheme news}

test uri-1.11-0 {uri::split - ldap simple} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {ldap://ldaphost}]
} {attrs {} dn {} extensions {} filter {} host ldaphost port {} scheme ldap scope {}}

test uri-1.12-0 {uri::split - ldaps with port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {ldaps://h:636/}]
} {attrs {} dn {} extensions {} filter {} host h port 636 scheme ldaps scope {}}

test uri-1.13-0 {uri::split - ldap search} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {ldap://ldaphost/o=mycomp?uid,mail?sub?(uid=pda)}]
} {attrs {uid mail} dn o=mycomp extensions {} filter (uid=pda) host ldaphost port {} scheme ldap scope sub}

test uri-1.14-0 {uri::split - ldap search with implicit scope an attributes} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {ldap://ldaphost:999/o=mycomp???(uid=pda)}]
} {attrs {} dn o=mycomp extensions {} filter (uid=pda) host ldaphost port 999 scheme ldap scope {}}

test uri-1.15-0 {uri::split - https with IPv6} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {https://[2001:db8::7]:8080?foo=bar}]
} {fragment {} host {[2001:db8::7]} path {} port 8080 pwd {} query foo=bar scheme https user {}}

test uri-1.16-0 {uri::split - ftp with auth and IPv6} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {ftp://user:pass@[2001:db8::7]/alt}]
} {host {[2001:db8::7]} path /alt port {} pwd pass scheme ftp type {} user user}

test uri-1.17-0 {uri::split - ldaps IPv6 search with port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {ldaps://[2001:db8::7]:987/o=mycomp?uid,mail?sub?(uid=pda)}]
} {attrs {uid mail} dn o=mycomp extensions {} filter (uid=pda) host {[2001:db8::7]} port 987 scheme ldaps scope sub}

test uri-1.18-0 {uri::split - http w/- valid hostname on local network} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test-host/path/path2?query]
} {fragment {} host test-host path /path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.19-0 {uri::split - http w/- valid hostname on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test-host./path/path2?query]
} {fragment {} host test-host. path /path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.20-0 {uri::split - http w/- valid hostname on local network and port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test-host:8080/path/path2?query]
} {fragment {} host test-host path /path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.21-0 {uri::split - http w/- valid hostname on local network FQDN and port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test-host.:8080/path/path2?query]
} {fragment {} host test-host. path /path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.22-0 {uri::split - http w/- valid hostname "9" on local network} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://9/path/path2?query]
} {fragment {} host 9 path /path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.23-0 {uri::split - http w/- valid hostname "9" on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://9./path/path2?query]
} {fragment {} host 9. path /path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.24-0 {uri::split - http w/- valid hostname "9" on local network and port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://9:8080/path/path2?query]
} {fragment {} host 9 path /path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.25-0 {uri::split - http w/- valid hostname "9" on local network FQDN and port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://9.:8080/path/path2?query]
} {fragment {} host 9. path /path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.26-0 {uri::split - http w/- valid hostname "0-9" on local network} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://0-9/path/path2?query]
} {fragment {} host 0-9 path /path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.27-0 {uri::split - http w/- valid hostname "0-9" on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://0-9./path/path2?query]
} {fragment {} host 0-9. path /path/path2 port {} pwd {} query query scheme http user {}}

test uri-1.28-0 {uri::split - http w/- valid hostname "0-9" on local network and port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://0-9:8080/path/path2?query]
} {fragment {} host 0-9 path /path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.29-0 {uri::split - http w/- valid hostname "0-9" on local network FQDN and port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://0-9.:8080/path/path2?query]
} {fragment {} host 0-9. path /path/path2 port 8080 pwd {} query query scheme http user {}}

test uri-1.30-0 {uri::split - http w/- nested query and FQDN} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net./path/path2?query=url?otherquery]
} {fragment {} host test.net. path /path/path2 port {} pwd {} query query=url?otherquery scheme http user {}}

test uri-1.31-0 {uri::split - http w/- nested query and FQDN and port} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net.:8080/path/path2?query=url?otherquery]
} {fragment {} host test.net. path /path/path2 port 8080 pwd {} query query=url?otherquery scheme http user {}}

test uri-1.32-0 {uri::split - http w/- query test / in query} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net/path/path2?fetch=dir/file.txt]
} {fragment {} host test.net path /path/path2 port {} pwd {} query fetch=dir/file.txt scheme http user {}}

test uri-1.33-0 {uri::split - http w/- fragment test / ? in fragment} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net/path/path2?fetch=dir/file.txt#ab5/s?too]
} {fragment ab5/s?too host test.net path /path/path2 port {} pwd {} query fetch=dir/file.txt scheme http user {}}

test uri-1.34-0 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net/path/path2?fetch=dir/file.txt#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path /path/path2 port {} pwd {} query fetch=dir/file.txt scheme http user {}}

test uri-1.35-0 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net/path/path2#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path /path/path2 port {} pwd {} query {} scheme http user {}}

test uri-1.36-0 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net/#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path / port {} pwd {} query {} scheme http user {}}

test uri-1.37-0 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://test.net#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path {} port {} pwd {} query {} scheme http user {}}

test uri-1.38-0 {uri::split - relative URI} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split //test.net#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path {} port {} pwd {} query {} scheme http user {}}

test uri-1.39-0 {uri::split - relative URI} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split //test.net#ab5/s?to#o{and}fg https]
} {fragment ab5/s?to#o{and}fg host test.net path {} port {} pwd {} query {} scheme https user {}}

test uri-1.40-0 {uri::split - relative URI {}} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split {}]
} {fragment {} host {} path {} port {} pwd {} query {} scheme http user {}}

test uri-1.41-0 {uri::split - relative URI http cf bug 2798448} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split host.td]
} {fragment {} host host.td path {} port {} pwd {} query {} scheme http user {}}

test uri-1.42-0 {uri::split - relative URI http cf bug 2798448} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://host.td]
} {fragment {} host host.td path {} port {} pwd {} query {} scheme http user {}}

test uri-1.43-0 {uri::split - relative URI ftp cf bug 2798448} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split host.td ftp]
} {host host.td path {} port {} pwd {} scheme ftp type {} user {}}

test uri-1.44-0 {uri::split - relative URI ftp cf bug 2798448} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split ftp://host.td]
} {host host.td path {} port {} pwd {} scheme ftp type {} user {}}

test uri-1.45-0 {uri::split relative URI http/https/ftp path} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split gone/away]
} {fragment {} host gone path /away port {} pwd {} query {} scheme http user {}}

test uri-1.46-0 {uri::split relative URI http/https/ftp path} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split /gone/away]
} {fragment {} host {} path /gone/away port {} pwd {} query {} scheme http user {}}

test uri-1.47-0 {uri::split relative URI http/https/ftp path} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split //gone/away]
} {fragment {} host gone path /away port {} pwd {} query {} scheme http user {}}

test uri-1.48-0 {uri::split relative URI http/https/ftp path} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split ///gone/away]
} {fragment {} host {} path /gone/away port {} pwd {} query {} scheme http user {}}

test uri-1.49-0 {uri::split relative URI http/https/ftp path - result significantly differs from 1.49-1 - excess leading slashes are NOT removed} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split ////gone/away]
} {fragment {} host {} path //gone/away port {} pwd {} query {} scheme http user {}}

test uri-1.50-0 {uri::split relative URI file path} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split gone/away file]
} {path gone/away scheme file}

test uri-1.51-0 {uri::split relative URI file path} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split /gone/away file]
} {path /gone/away scheme file}

test uri-1.52-0 {uri::split relative URI file path} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split //gone/away file]
} {host gone path /away scheme file}

test uri-1.53-0 {uri::split relative URI file path} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split ///gone/away file]
} {path /gone/away scheme file}

test uri-1.54-0 {uri::split relative URI file path - in scheme "file" excess leading slashes are retained} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [::uri::split ////gone/away file]
} {path //gone/away scheme file}

# ---

test uri-1.0-1 {uri::split - http w/- nested query} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net/path/path2?query=url?otherquery]
} {fragment {} host test.net path path/path2 pbare 0 port {} pwd {} query query=url?otherquery scheme http user {}}

test uri-1.1-1 {uri::split - http w/- query} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net/path/path2?query]
} {fragment {} host test.net path path/path2 pbare 0 port {} pwd {} query query scheme http user {}}

test uri-1.2-1 {uri::split - https w/- query} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split https://test.net/path/path2?query]
} {fragment {} host test.net path path/path2 pbare 0 port {} pwd {} query query scheme https user {}}

test uri-1.3-1 {uri::split - http w/- port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net:8080]
} {fragment {} host test.net path {} pbare 1 port 8080 pwd {} query {} scheme http user {}}

test uri-1.4-1 {uri::split - https w/- port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split https://test.net:8888]
} {fragment {} host test.net path {} pbare 1 port 8888 pwd {} query {} scheme https user {}}

test uri-1.5-1 {uri::split - ftp} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split ftp://ftp.test.net/path/to/resource]
} {host ftp.test.net path path/to/resource pbare 0 port {} pwd {} scheme ftp type {} user {}}

test uri-1.6-1 {uri::split - ftp with userinfo} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {ftp://user:passwd@localhost/a/b/c.d}]
} {host localhost path a/b/c.d pbare 0 port {} pwd passwd scheme ftp type {} user user}

test uri-1.7-1 {uri::split - ftp with type} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {ftp://localhost/a/b/c.d;type=i}]
} {host localhost path a/b/c.d pbare 0 port {} pwd {} scheme ftp type i user {}}

test uri-1.8-1 {uri::split - ftp with port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {ftp://localhost:21/a/b/c.d}]
} {host localhost path a/b/c.d pbare 0 port 21 pwd {} scheme ftp type {} user {}}

test uri-1.9-1 {uri::split - news with message-id} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {news:[email protected]}]
} {message-id [email protected] scheme news}

test uri-1.10-1 {uri::split - news with newsgroup-name} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {news:comp.lang.tcl}]
} {newsgroup-name comp.lang.tcl scheme news}

test uri-1.11-1 {uri::split - ldap simple} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {ldap://ldaphost}]
} {attrs {} dn {} extensions {} filter {} host ldaphost port {} scheme ldap scope {}}

test uri-1.12-1 {uri::split - ldaps with port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {ldaps://h:636/}]
} {attrs {} dn {} extensions {} filter {} host h port 636 scheme ldaps scope {}}

test uri-1.13-1 {uri::split - ldap search} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {ldap://ldaphost/o=mycomp?uid,mail?sub?(uid=pda)}]
} {attrs {uid mail} dn o=mycomp extensions {} filter (uid=pda) host ldaphost port {} scheme ldap scope sub}

test uri-1.14-1 {uri::split - ldap search with implicit scope an attributes} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {ldap://ldaphost:999/o=mycomp???(uid=pda)}]
} {attrs {} dn o=mycomp extensions {} filter (uid=pda) host ldaphost port 999 scheme ldap scope {}}

test uri-1.15-1 {uri::split - https with IPv6} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {https://[2001:db8::7]:8080?foo=bar}]
} {fragment {} host {[2001:db8::7]} path {} pbare 1 port 8080 pwd {} query foo=bar scheme https user {}}

test uri-1.16-1 {uri::split - ftp with auth and IPv6} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {ftp://user:pass@[2001:db8::7]/alt}]
} {host {[2001:db8::7]} path alt pbare 0 port {} pwd pass scheme ftp type {} user user}

test uri-1.17-1 {uri::split - ldaps IPv6 search with port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {ldaps://[2001:db8::7]:987/o=mycomp?uid,mail?sub?(uid=pda)}]
} {attrs {uid mail} dn o=mycomp extensions {} filter (uid=pda) host {[2001:db8::7]} port 987 scheme ldaps scope sub}

test uri-1.18-1 {uri::split - http w/- valid hostname on local network} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test-host/path/path2?query]
} {fragment {} host test-host path path/path2 pbare 0 port {} pwd {} query query scheme http user {}}

test uri-1.19-1 {uri::split - http w/- valid hostname on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test-host./path/path2?query]
} {fragment {} host test-host. path path/path2 pbare 0 port {} pwd {} query query scheme http user {}}

test uri-1.20-1 {uri::split - http w/- valid hostname on local network and port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test-host:8080/path/path2?query]
} {fragment {} host test-host path path/path2 pbare 0 port 8080 pwd {} query query scheme http user {}}

test uri-1.21-1 {uri::split - http w/- valid hostname on local network FQDN and port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test-host.:8080/path/path2?query]
} {fragment {} host test-host. path path/path2 pbare 0 port 8080 pwd {} query query scheme http user {}}

test uri-1.22-1 {uri::split - http w/- valid hostname "9" on local network} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://9/path/path2?query]
} {fragment {} host 9 path path/path2 pbare 0 port {} pwd {} query query scheme http user {}}

test uri-1.23-1 {uri::split - http w/- valid hostname "9" on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://9./path/path2?query]
} {fragment {} host 9. path path/path2 pbare 0 port {} pwd {} query query scheme http user {}}

test uri-1.24-1 {uri::split - http w/- valid hostname "9" on local network and port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://9:8080/path/path2?query]
} {fragment {} host 9 path path/path2 pbare 0 port 8080 pwd {} query query scheme http user {}}

test uri-1.25-1 {uri::split - http w/- valid hostname "9" on local network FQDN and port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://9.:8080/path/path2?query]
} {fragment {} host 9. path path/path2 pbare 0 port 8080 pwd {} query query scheme http user {}}

test uri-1.26-1 {uri::split - http w/- valid hostname "0-9" on local network} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://0-9/path/path2?query]
} {fragment {} host 0-9 path path/path2 pbare 0 port {} pwd {} query query scheme http user {}}

test uri-1.27-1 {uri::split - http w/- valid hostname "0-9" on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://0-9./path/path2?query]
} {fragment {} host 0-9. path path/path2 pbare 0 port {} pwd {} query query scheme http user {}}

test uri-1.28-1 {uri::split - http w/- valid hostname "0-9" on local network and port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://0-9:8080/path/path2?query]
} {fragment {} host 0-9 path path/path2 pbare 0 port 8080 pwd {} query query scheme http user {}}

test uri-1.29-1 {uri::split - http w/- valid hostname "0-9" on local network FQDN and port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://0-9.:8080/path/path2?query]
} {fragment {} host 0-9. path path/path2 pbare 0 port 8080 pwd {} query query scheme http user {}}

test uri-1.30-1 {uri::split - http w/- nested query and FQDN} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net./path/path2?query=url?otherquery]
} {fragment {} host test.net. path path/path2 pbare 0 port {} pwd {} query query=url?otherquery scheme http user {}}

test uri-1.31-1 {uri::split - http w/- nested query and FQDN and port} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net.:8080/path/path2?query=url?otherquery]
} {fragment {} host test.net. path path/path2 pbare 0 port 8080 pwd {} query query=url?otherquery scheme http user {}}

test uri-1.32-1 {uri::split - http w/- query test / in query} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net/path/path2?fetch=dir/file.txt]
} {fragment {} host test.net path path/path2 pbare 0 port {} pwd {} query fetch=dir/file.txt scheme http user {}}

test uri-1.33-1 {uri::split - http w/- fragment test / ? in fragment} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net/path/path2?fetch=dir/file.txt#ab5/s?too]
} {fragment ab5/s?too host test.net path path/path2 pbare 0 port {} pwd {} query fetch=dir/file.txt scheme http user {}}

test uri-1.34-1 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net/path/path2?fetch=dir/file.txt#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path path/path2 pbare 0 port {} pwd {} query fetch=dir/file.txt scheme http user {}}

test uri-1.35-1 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net/path/path2#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path path/path2 pbare 0 port {} pwd {} query {} scheme http user {}}

test uri-1.36-1 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net/#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path {} pbare 0 port {} pwd {} query {} scheme http user {}}

test uri-1.37-1 {uri::split - http w/- fragment test {}# in fragment - illegal chars see [7b5c6cb477]} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://test.net#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path {} pbare 1 port {} pwd {} query {} scheme http user {}}

test uri-1.38-1 {uri::split - relative URI} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split //test.net#ab5/s?to#o{and}fg]
} {fragment ab5/s?to#o{and}fg host test.net path {} pbare 1 port {} pwd {} query {} scheme http user {}}

test uri-1.39-1 {uri::split - relative URI} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split //test.net#ab5/s?to#o{and}fg https]
} {fragment ab5/s?to#o{and}fg host test.net path {} pbare 1 port {} pwd {} query {} scheme https user {}}

test uri-1.40-1 {uri::split - relative URI {}} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split {}]
} {fragment {} host {} path {} pbare 1 port {} pwd {} query {} scheme http user {}}

test uri-1.41-1 {uri::split - relative URI http cf bug 2798448} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split host.td]
} {fragment {} host host.td path {} pbare 1 port {} pwd {} query {} scheme http user {}}

test uri-1.42-1 {uri::split - relative URI http cf bug 2798448} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://host.td]
} {fragment {} host host.td path {} pbare 1 port {} pwd {} query {} scheme http user {}}

test uri-1.43-1 {uri::split - relative URI ftp cf bug 2798448} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split host.td ftp]
} {host host.td path {} pbare 1 port {} pwd {} scheme ftp type {} user {}}

test uri-1.44-1 {uri::split - relative URI ftp cf bug 2798448} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split ftp://host.td]
} {host host.td path {} pbare 1 port {} pwd {} scheme ftp type {} user {}}

test uri-1.45-1 {uri::split relative URI http/https/ftp path} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split gone/away]
} {fragment {} host gone path away pbare 0 port {} pwd {} query {} scheme http user {}}

test uri-1.46-1 {uri::split relative URI http/https/ftp path} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split /gone/away]
} {fragment {} host {} path gone/away pbare 0 port {} pwd {} query {} scheme http user {}}

test uri-1.47-1 {uri::split relative URI http/https/ftp path} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split //gone/away]
} {fragment {} host gone path away pbare 0 port {} pwd {} query {} scheme http user {}}

test uri-1.48-1 {uri::split relative URI http/https/ftp path} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split ///gone/away]
} {fragment {} host {} path gone/away pbare 0 port {} pwd {} query {} scheme http user {}}

test uri-1.49-1 {uri::split relative URI http/https/ftp path - result significantly differs from 1.49-0 - excess leading slashes are removed} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split ////gone/away]
} {fragment {} host {} path gone/away pbare 0 port {} pwd {} query {} scheme http user {}}

test uri-1.50-1 {uri::split relative URI file path} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split gone/away file]
} {path gone/away scheme file}

test uri-1.51-1 {uri::split relative URI file path} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split /gone/away file]
} {path /gone/away scheme file}

test uri-1.52-1 {uri::split relative URI file path} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split //gone/away file]
} {host gone path /away scheme file}

test uri-1.53-1 {uri::split relative URI file path} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split ///gone/away file]
} {path /gone/away scheme file}

test uri-1.54-1 {uri::split relative URI file path - in scheme "file" excess leading slashes are retained} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [::uri::split ////gone/away file]
} {path //gone/away scheme file}

# -------------------------------------------------------------------------
test uri-2.1-0 {uri::join - http} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme http path / host www.w3.org
} http://www.w3.org/

test uri-2.2-0 {uri::join - https} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https path / host www.w3.org
} https://www.w3.org/

test uri-2.3-0 {uri::join - http w/- query} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme http query abc=def&ghi=jkl host www.test.net path /path/
} http://www.test.net/path/?abc=def&ghi=jkl

test uri-2.4-0 {uri::join - https w/- query} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host www.test.net path /path/
} https://www.test.net/path/?abc=def&ghi=jkl

test uri-2.5-0 {uri::join - http w/- port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme http port 8080 host www.test.net path /path/
} http://www.test.net:8080/path/

test uri-2.6-0 {uri::join - https w/- port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https port 8888 host www.test.net path /path/
} https://www.test.net:8888/path/

test uri-2.7-0 {uri::join - ftp} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join host ftp.test.net path /my/file scheme ftp
} ftp://ftp.test.net/my/file

test uri-2.8-0 {uri::join - identity function} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join [uri::split http://www.w3.org/XML/?abc=def]
} http://www.w3.org/XML/?abc=def

test uri-2.9-0 {uri::join - ftp userinfo check} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join scheme ftp host localhost port 21 path /filename user user pwd passwd
} {ftp://user:passwd@localhost:21/filename}

test uri-2.10-0 {uri::join - ftp userinfo check with no passwd} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join scheme ftp host localhost path /filename user user
} {ftp://user@localhost/filename}

test uri-2.11-0 {uri::join - ftp path prefix} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join scheme ftp host localhost path a/b/c.d
} ftp://localhost/a/b/c.d

test uri-2.12-0 {uri::join - ftp w/- image type} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join scheme ftp host localhost path a/b/c.d type i
} {ftp://localhost/a/b/c.d;type=i}

test uri-2.13-0 {uri::join - ftp w/- ascii type} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join scheme ftp host localhost path a/b/c.d type a
} {ftp://localhost/a/b/c.d;type=a}

# I am not sure that this shouldn't produce an error. The semi-colon is 
# reserved so in this case with an invalid suffix the semi-colon should
# probably be quoted. [PT]
test uri-2.14-0 {uri::join - ftp w/- invalid type} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join scheme ftp host localhost path a/b/c.d type X
} {ftp://localhost/a/b/c.d;type=X}

test uri-2.15-0 {uri::join - news message-id} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join scheme news message-id [email protected]
} {news:[email protected]}

test uri-2.16-0 {uri::join - news newsgroup-name} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join scheme news newsgroup-name comp.lang.tcl
} {news:comp.lang.tcl}

test uri-2.17-0 {uri::join - ldap simple} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme ldap host ldaphost
} {ldap://ldaphost}

test uri-2.18-0 {uri::join - ldaps with default port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme ldaps host ldaphost port 636
} {ldaps://ldaphost}

test uri-2.19-0 {uri::join - ldaps with port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme ldaps host ldaphost port 999
} {ldaps://ldaphost:999}

test uri-2.20-0 {uri::join - ldap search} {
    # I should use "attrs {uid mail}" and not "attrs uid,mail"
    # but this is a perverse effect of the "eval" command
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join attrs uid,mail dn o=mycomp filter (uid=pda) host ldaphost scheme ldap scope sub
} {ldap://ldaphost/o=mycomp?uid,mail?sub?(uid=pda)}

test uri-2.21-0 {uri::join - ldap search with implicit scope an attributes} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join dn o=mycomp filter (uid=pda) host ldaphost port 999 scheme ldap
} {ldap://ldaphost:999/o=mycomp???(uid=pda)}

test uri-2.22-0 {uri::join - https w/- query user pwd frag} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host www.test.net path /path/ user user pwd passwd fragment f
} https://user:[email protected]/path/?abc=def&ghi=jkl#f

test uri-2.23-0 {uri::join - https w/- query user pwd frag FQDN} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host www.test.net. path /path/ user user pwd passwd fragment f
} https://user:[email protected]./path/?abc=def&ghi=jkl#f

test uri-2.24-0 {uri::join - https w/- query user pwd frag port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host www.test.net path /path/ user user pwd passwd fragment f port 8080
} https://user:[email protected]:8080/path/?abc=def&ghi=jkl#f

test uri-2.25-0 {uri::join - https w/- query user pwd frag FQDN port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host www.test.net. path /path/ user user pwd passwd fragment f port 8080
} https://user:[email protected].:8080/path/?abc=def&ghi=jkl#f

test uri-2.26-0 {uri::join - https w/- query user pwd frag valid hostname on local network} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host test-host path /path/ user user pwd passwd fragment f
} https://user:passwd@test-host/path/?abc=def&ghi=jkl#f

test uri-2.27-0 {uri::join - https w/- query user pwd frag valid hostname on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host test-host. path /path/ user user pwd passwd fragment f
} https://user:passwd@test-host./path/?abc=def&ghi=jkl#f

test uri-2.28-0 {uri::join - https w/- query user pwd frag valid hostname on local network port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host test-host path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@test-host:8080/path/?abc=def&ghi=jkl#f

test uri-2.29-0 {uri::join - https w/- query user pwd frag valid hostname on local network FQDN port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host test-host. path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@test-host.:8080/path/?abc=def&ghi=jkl#f

test uri-2.30-0 {uri::join - https w/- query user pwd frag valid hostname "9" on local network} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host 9 path /path/ user user pwd passwd fragment f
} https://user:passwd@9/path/?abc=def&ghi=jkl#f

test uri-2.31-0 {uri::join - https w/- query user pwd frag valid hostname "9" on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host 9. path /path/ user user pwd passwd fragment f
} https://user:passwd@9./path/?abc=def&ghi=jkl#f

test uri-2.32-0 {uri::join - https w/- query user pwd frag valid hostname "9" on local network port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host 9 path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@9:8080/path/?abc=def&ghi=jkl#f

test uri-2.33-0 {uri::join - https w/- query user pwd frag valid hostname "9" on local network FQDN port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host 9. path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@9.:8080/path/?abc=def&ghi=jkl#f

test uri-2.34-0 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host 0-9 path /path/ user user pwd passwd fragment f
} https://user:passwd@0-9/path/?abc=def&ghi=jkl#f

test uri-2.35-0 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host 0-9. path /path/ user user pwd passwd fragment f
} https://user:passwd@0-9./path/?abc=def&ghi=jkl#f

test uri-2.36-0 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host 0-9 path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@0-9:8080/path/?abc=def&ghi=jkl#f

test uri-2.37-0 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network FQDN port} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme https query abc=def&ghi=jkl host 0-9. path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@0-9.:8080/path/?abc=def&ghi=jkl#f

test uri-2.38-0 {uri::join -- scheme file, do not use first segment of path as host} {
    ::uri::setQuirkOption NoInitialSlash 0
    ::uri::join path b/c/d scheme file
} file:///b/c/d

test uri-2.39-0 {uri::join -- scheme file, usual case} {
    ::uri::setQuirkOption NoInitialSlash 0
    ::uri::join path /b/c/d scheme file
} file:///b/c/d

test uri-2.40-0 {uri::join -- scheme file, trimleft excess "/", do not use first segment of path as host} {
    ::uri::setQuirkOption NoInitialSlash 0
    ::uri::join path //b/c/d scheme file
} file:////b/c/d
# file:///b/c/d
test uri-2.41-0 {uri::join -- scheme file, trimleft excess "/", do not use first segment of path as host} {
    ::uri::setQuirkOption NoInitialSlash 0
    ::uri::join path ///b/c/d scheme file
} file://///b/c/d
# file:///b/c/d
test uri-2.42-0 {uri::join -- scheme file, trimleft excess "/", do not use first segment of path as host} {
    ::uri::setQuirkOption NoInitialSlash 0
    ::uri::join path ////b/c/d scheme file
} file://////b/c/d
# file:///b/c/d
test uri-2.43-0 {uri::join -- with uri::split, identity function preserves user:pwd for http} {
    ::uri::setQuirkOption NoInitialSlash 0
  eval ::uri::join [::uri::split http://anonymous:[email protected]]
} http://anonymous:[email protected]

test uri-2.44-0 {uri::join -- with uri::split, identity function preserves user:pwd and port for http} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval ::uri::join [::uri::split http://anonymous:[email protected]:8080/foo]
} http://anonymous:[email protected]:8080/foo

test uri-2.45-0 {uri::join -- with uri::split, identity function preserves user:pwd and port for http FQDN} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval ::uri::join [::uri::split http://anonymous:[email protected].:8080/foo]
} http://anonymous:[email protected].:8080/foo

test uri-2.46-0 {uri::join - http - pbare is irrelevant - result differs from 2.46.1} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme http path {} host www.w3.org
} http://www.w3.org

test uri-2.47-0 {uri::join - http - pbare is irrelevant} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme http path {} host www.w3.org pbare 1
} http://www.w3.org

test uri-2.48-0 {uri::join - http - pbare is irrelevant - result differs from 2.48.1} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme http path {} host www.w3.org pbare 0
} http://www.w3.org

test uri-2.49-0 {uri::join - http - pbare is irrelevant} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme http path / host www.w3.org
} http://www.w3.org/

test uri-2.50-0 {uri::join - http - pbare is irrelevant} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme http path / host www.w3.org pbare 1
} http://www.w3.org/

test uri-2.51-0 {uri::join - http - pbare is irrelevant} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join scheme http path / host www.w3.org pbare 0
} http://www.w3.org/

# ---

test uri-2.1-1 {uri::join - http} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme http path / host www.w3.org
} http://www.w3.org/

test uri-2.2-1 {uri::join - https} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https path / host www.w3.org
} https://www.w3.org/

test uri-2.3-1 {uri::join - http w/- query} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme http query abc=def&ghi=jkl host www.test.net path /path/
} http://www.test.net/path/?abc=def&ghi=jkl

test uri-2.4-1 {uri::join - https w/- query} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host www.test.net path /path/
} https://www.test.net/path/?abc=def&ghi=jkl

test uri-2.5-1 {uri::join - http w/- port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme http port 8080 host www.test.net path /path/
} http://www.test.net:8080/path/

test uri-2.6-1 {uri::join - https w/- port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https port 8888 host www.test.net path /path/
} https://www.test.net:8888/path/

test uri-2.7-1 {uri::join - ftp} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join host ftp.test.net path /my/file scheme ftp
} ftp://ftp.test.net/my/file

test uri-2.8-1 {uri::join - identity function} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join [uri::split http://www.w3.org/XML/?abc=def]
} http://www.w3.org/XML/?abc=def

test uri-2.9-1 {uri::join - ftp userinfo check} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join scheme ftp host localhost port 21 path /filename user user pwd passwd
} {ftp://user:passwd@localhost:21/filename}

test uri-2.10-1 {uri::join - ftp userinfo check with no passwd} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join scheme ftp host localhost path /filename user user
} {ftp://user@localhost/filename}

test uri-2.11-1 {uri::join - ftp path prefix} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join scheme ftp host localhost path a/b/c.d
} ftp://localhost/a/b/c.d

test uri-2.12-1 {uri::join - ftp w/- image type} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join scheme ftp host localhost path a/b/c.d type i
} {ftp://localhost/a/b/c.d;type=i}

test uri-2.13-1 {uri::join - ftp w/- ascii type} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join scheme ftp host localhost path a/b/c.d type a
} {ftp://localhost/a/b/c.d;type=a}

# I am not sure that this shouldn't produce an error. The semi-colon is 
# reserved so in this case with an invalid suffix the semi-colon should
# probably be quoted. [PT]
test uri-2.14-1 {uri::join - ftp w/- invalid type} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join scheme ftp host localhost path a/b/c.d type X
} {ftp://localhost/a/b/c.d;type=X}

test uri-2.15-1 {uri::join - news message-id} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join scheme news message-id [email protected]
} {news:[email protected]}

test uri-2.16-1 {uri::join - news newsgroup-name} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join scheme news newsgroup-name comp.lang.tcl
} {news:comp.lang.tcl}

test uri-2.17-1 {uri::join - ldap simple} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme ldap host ldaphost
} {ldap://ldaphost}

test uri-2.18-1 {uri::join - ldaps with default port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme ldaps host ldaphost port 636
} {ldaps://ldaphost}

test uri-2.19-1 {uri::join - ldaps with port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme ldaps host ldaphost port 999
} {ldaps://ldaphost:999}

test uri-2.20-1 {uri::join - ldap search} {
    # I should use "attrs {uid mail}" and not "attrs uid,mail"
    # but this is a perverse effect of the "eval" command
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join attrs uid,mail dn o=mycomp filter (uid=pda) host ldaphost scheme ldap scope sub
} {ldap://ldaphost/o=mycomp?uid,mail?sub?(uid=pda)}

test uri-2.21-1 {uri::join - ldap search with implicit scope an attributes} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join dn o=mycomp filter (uid=pda) host ldaphost port 999 scheme ldap
} {ldap://ldaphost:999/o=mycomp???(uid=pda)}

test uri-2.22-1 {uri::join - https w/- query user pwd frag} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host www.test.net path /path/ user user pwd passwd fragment f
} https://user:[email protected]/path/?abc=def&ghi=jkl#f

test uri-2.23-1 {uri::join - https w/- query user pwd frag FQDN} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host www.test.net. path /path/ user user pwd passwd fragment f
} https://user:[email protected]./path/?abc=def&ghi=jkl#f

test uri-2.24-1 {uri::join - https w/- query user pwd frag port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host www.test.net path /path/ user user pwd passwd fragment f port 8080
} https://user:[email protected]:8080/path/?abc=def&ghi=jkl#f

test uri-2.25-1 {uri::join - https w/- query user pwd frag FQDN port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host www.test.net. path /path/ user user pwd passwd fragment f port 8080
} https://user:[email protected].:8080/path/?abc=def&ghi=jkl#f

test uri-2.26-1 {uri::join - https w/- query user pwd frag valid hostname on local network} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host test-host path /path/ user user pwd passwd fragment f
} https://user:passwd@test-host/path/?abc=def&ghi=jkl#f

test uri-2.27-1 {uri::join - https w/- query user pwd frag valid hostname on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host test-host. path /path/ user user pwd passwd fragment f
} https://user:passwd@test-host./path/?abc=def&ghi=jkl#f

test uri-2.28-1 {uri::join - https w/- query user pwd frag valid hostname on local network port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host test-host path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@test-host:8080/path/?abc=def&ghi=jkl#f

test uri-2.29-1 {uri::join - https w/- query user pwd frag valid hostname on local network FQDN port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host test-host. path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@test-host.:8080/path/?abc=def&ghi=jkl#f

test uri-2.30-1 {uri::join - https w/- query user pwd frag valid hostname "9" on local network} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host 9 path /path/ user user pwd passwd fragment f
} https://user:passwd@9/path/?abc=def&ghi=jkl#f

test uri-2.31-1 {uri::join - https w/- query user pwd frag valid hostname "9" on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host 9. path /path/ user user pwd passwd fragment f
} https://user:passwd@9./path/?abc=def&ghi=jkl#f

test uri-2.32-1 {uri::join - https w/- query user pwd frag valid hostname "9" on local network port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host 9 path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@9:8080/path/?abc=def&ghi=jkl#f

test uri-2.33-1 {uri::join - https w/- query user pwd frag valid hostname "9" on local network FQDN port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host 9. path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@9.:8080/path/?abc=def&ghi=jkl#f

test uri-2.34-1 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host 0-9 path /path/ user user pwd passwd fragment f
} https://user:passwd@0-9/path/?abc=def&ghi=jkl#f

test uri-2.35-1 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network FQDN} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host 0-9. path /path/ user user pwd passwd fragment f
} https://user:passwd@0-9./path/?abc=def&ghi=jkl#f

test uri-2.36-1 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host 0-9 path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@0-9:8080/path/?abc=def&ghi=jkl#f

test uri-2.37-1 {uri::join - https w/- query user pwd frag valid hostname "0-9" on local network FQDN port} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme https query abc=def&ghi=jkl host 0-9. path /path/ user user pwd passwd fragment f port 8080
} https://user:passwd@0-9.:8080/path/?abc=def&ghi=jkl#f

test uri-2.38-1 {uri::join -- scheme file, do not use first segment of path as host} {
    ::uri::setQuirkOption NoInitialSlash 1
    ::uri::join path b/c/d scheme file
} file:///b/c/d

test uri-2.39-1 {uri::join -- scheme file, usual case} {
    ::uri::setQuirkOption NoInitialSlash 1
    ::uri::join path /b/c/d scheme file
} file:///b/c/d

test uri-2.40-1 {uri::join -- scheme file, trimleft excess "/", do not use first segment of path as host} {
    ::uri::setQuirkOption NoInitialSlash 1
    ::uri::join path //b/c/d scheme file
} file:////b/c/d
# file:///b/c/d
test uri-2.41-1 {uri::join -- scheme file, trimleft excess "/", do not use first segment of path as host} {
    ::uri::setQuirkOption NoInitialSlash 1
    ::uri::join path ///b/c/d scheme file
} file://///b/c/d
# file:///b/c/d
test uri-2.42-1 {uri::join -- scheme file, trimleft excess "/", do not use first segment of path as host} {
    ::uri::setQuirkOption NoInitialSlash 1
    ::uri::join path ////b/c/d scheme file
} file://////b/c/d
# file:///b/c/d
test uri-2.43-1 {uri::join -- with uri::split, identity function preserves user:pwd for http} {
    ::uri::setQuirkOption NoInitialSlash 1
  eval ::uri::join [::uri::split http://anonymous:[email protected]]
} http://anonymous:[email protected]

test uri-2.44-1 {uri::join -- with uri::split, identity function preserves user:pwd and port for http} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval ::uri::join [::uri::split http://anonymous:[email protected]:8080/foo]
} http://anonymous:[email protected]:8080/foo

test uri-2.45-1 {uri::join -- with uri::split, identity function preserves user:pwd and port for http FQDN} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval ::uri::join [::uri::split http://anonymous:[email protected].:8080/foo]
} http://anonymous:[email protected].:8080/foo

test uri-2.46-1 {uri::join - http - controlled by pbare - result differs from 2.46.0} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme http path {} host www.w3.org
} http://www.w3.org/

test uri-2.47-1 {uri::join - http - controlled by pbare} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme http path {} host www.w3.org pbare 1
} http://www.w3.org

test uri-2.48-1 {uri::join - http - controlled by pbare - result differs from 2.48.0} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme http path {} host www.w3.org pbare 0
} http://www.w3.org/

test uri-2.49-1 {uri::join - http - not controlled by pbare} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme http path / host www.w3.org
} http://www.w3.org/

test uri-2.50-1 {uri::join - http - not controlled by pbare} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme http path / host www.w3.org pbare 1
} http://www.w3.org/

test uri-2.51-1 {uri::join - http - not controlled by pbare} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join scheme http path / host www.w3.org pbare 0
} http://www.w3.org/

# -------------------------------------------------------------------------
::uri::setQuirkOption NoInitialSlash $BaseValue(NoInitialSlash)

test uri-3.1 {uri::resolve - relative URL, base trailing slash} {
    uri::resolve http://www.w3.org/path/ test.html
} http://www.w3.org/path/test.html

test uri-3.2 {uri::resolve - relative URL path, base trailing slash} {
    uri::resolve http://www.w3.org/path/ relpath/test.html
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494

test uri-3.12 {uri::resolve - scheme-relative url with authority, rfc3986 4.2} {
    uri::resolve https://www.foo.com/ //www.bar.com/
}  https://www.bar.com/

test uri-3.13 {uri::resolve - scheme-relative url with authority, rfc3986 4.2} {
    uri::resolve https://www.foo.com/ //www.bar.com
}  https://www.bar.com/

test uri-3.14 {uri::resolve - two queries,
    one absolute URL, one absolute path, port} {
    uri::resolve http://www.example.com:8080/baz?foo=bar /baz?shoo=bee
} http://www.example.com:8080/baz?shoo=bee

test uri-3.15 {uri::resolve - two queries,







|







1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200

test uri-3.12 {uri::resolve - scheme-relative url with authority, rfc3986 4.2} {
    uri::resolve https://www.foo.com/ //www.bar.com/
}  https://www.bar.com/

test uri-3.13 {uri::resolve - scheme-relative url with authority, rfc3986 4.2} {
    uri::resolve https://www.foo.com/ //www.bar.com
}  https://www.bar.com

test uri-3.14 {uri::resolve - two queries,
    one absolute URL, one absolute path, port} {
    uri::resolve http://www.example.com:8080/baz?foo=bar /baz?shoo=bee
} http://www.example.com:8080/baz?shoo=bee

test uri-3.15 {uri::resolve - two queries,
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839












840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039












1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239












1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369

1370
1371
1372
1373
1374
1375
1376
1377
1378
1379

1380




1381
1382
1383
1384
1385
1386






1387
1388
1389
1390
1391
1392

1393
1394





1395
1396
1397
1398

1399




1400

1401
1402






1403
1404
1405
1406
1407
1408

1409
1410





1411
1412
1413
1414

1415
1416
1417
1418

1419
1420
1421










1422


1423
1424
1425
1426
1427
1428
1429
    set token [uri::geturl file://$file]
    removeFile __testdata
    string compare $data [set [subst $token](data)]
} 0

# -------------------------------------------------------------------------

test uri-5.1-0 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/path1/./remove/../path2/resource
} http://www.test.net/path1/path2/resource

test uri-5.2-0 {uri::canonicalize infinite loop} {
    uri::canonicalize http://www.test.net/../path2/resource
} {http://www.test.net/path2/resource}

test uri-5.3-0 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./path1/./remove/../path2/../resource
} http://www.test.net/path1/resource

test uri-5.4-0 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./././path1/./remove/../path2/../resource
} http://www.test.net/path1/resource

test uri-5.5-0 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./././path1/./remove/path2/../../resource
} http://www.test.net/path1/resource

test uri-5.6-0 {uri::canonicalize infinite loop} {
    uri::canonicalize http://www.test.net/../../../path2/resource
} {http://www.test.net/path2/resource}

test uri-5.7-0 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/path1/./remove/../path.html/resource
} http://www.test.net/path1/path.html/resource

test uri-5.8-0 {uri::canonicalize infinite loop} {
    uri::canonicalize http://www.test.net/../path.html/resource
} {http://www.test.net/path.html/resource}

test uri-5.9-0 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./path1/./remove/../path.html/../resource
} http://www.test.net/path1/resource

test uri-5.10-0 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./././path1/./remove/../path.html/../resource
} http://www.test.net/path1/resource

test uri-5.11-0 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./././path1/./remove/path.html/../../resource
} http://www.test.net/path1/resource

test uri-5.12-0 {uri::canonicalize infinite loop} {
    uri::canonicalize http://www.test.net/../../../path.html/resource
} {http://www.test.net/path.html/resource}

test uri-5.13-0 {uri::canonicalize} {
    uri::canonicalize http://www.eldritchpress.org/jc/../help.html
} {http://www.eldritchpress.org/help.html}

test uri-5.14-0 {uri::canonicalize trailing ..} {
    uri::canonicalize http://www.example.com/foo/bar/..
} {http://www.example.com/foo/}

test uri-5.15-0 {uri::canonicalize trailing ..} {
    uri::canonicalize http://www.example.com/..
} {http://www.example.com/}

test uri-5.16-0 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/..s
} {http://www.example.com/..s}

test uri-5.17-0 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/..s/
} {http://www.example.com/..s/}

test uri-5.18-0 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/path1/..s
} {http://www.example.com/path1/..s}

test uri-5.19-0 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/path1/..s/
} {http://www.example.com/path1/..s/}

test uri-5.20-0 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/path1/..s/path2
} {http://www.example.com/path1/..s/path2}

test uri-5.21-0 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/path1/..s/path2/
} {http://www.example.com/path1/..s/path2/}

test uri-5.22-0 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/..s/path1
} {http://www.example.com/..s/path1}

test uri-5.23-0 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/..s/path1/
} {http://www.example.com/..s/path1/}

test uri-5.24-0 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/.s
} {http://www.example.com/.s}

test uri-5.25-0 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/.s/
} {http://www.example.com/.s/}

test uri-5.26-0 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/path1/.s
} {http://www.example.com/path1/.s}

test uri-5.27-0 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/path1/.s/
} {http://www.example.com/path1/.s/}

test uri-5.28-0 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/path1/.s/path2
} {http://www.example.com/path1/.s/path2}

test uri-5.29-0 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/path1/.s/path2/
} {http://www.example.com/path1/.s/path2/}

test uri-5.30-0 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/.s/path1
} {http://www.example.com/.s/path1}

test uri-5.31-0 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/.s/path1/
} {http://www.example.com/.s/path1/}

test uri-5.32-0 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/s..
} {http://www.example.com/s..}

test uri-5.33-0 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/s../
} {http://www.example.com/s../}

test uri-5.34-0 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/path1/s..
} {http://www.example.com/path1/s..}

test uri-5.35-0 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/path1/s../
} {http://www.example.com/path1/s../}

test uri-5.36-0 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/path1/s../path2
} {http://www.example.com/path1/s../path2}

test uri-5.37-0 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/path1/s../path2/
} {http://www.example.com/path1/s../path2/}

test uri-5.38-0 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/s../path1
} {http://www.example.com/s../path1}

test uri-5.39-0 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/s../path1/
} {http://www.example.com/s../path1/}

test uri-5.40-0 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/s.
} {http://www.example.com/s.}

test uri-5.41-0 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/s./
} {http://www.example.com/s./}

test uri-5.42-0 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/path1/s.
} {http://www.example.com/path1/s.}

test uri-5.43-0 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/path1/s./
} {http://www.example.com/path1/s./}

test uri-5.44-0 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/path1/s./path2
} {http://www.example.com/path1/s./path2}

test uri-5.45-0 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/path1/s./path2/
} {http://www.example.com/path1/s./path2/}

test uri-5.46-0 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/s./path1
} {http://www.example.com/s./path1}

test uri-5.47-0 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/s./path1/
} {http://www.example.com/s./path1/}

test uri-5.48-0 {uri::canonicalize infinite loop, valid hostname on local network} {
    uri::canonicalize http://test-host/../path.html/resource
} {http://test-host/path.html/resource}

test uri-5.49-0 {uri::canonicalize infinite loop, valid hostname "9" on local network} {
    uri::canonicalize http://9/../path.html/resource
} {http://9/path.html/resource}

test uri-5.50-0 {uri::canonicalize infinite loop, valid hostname "0-9" on local network} {
    uri::canonicalize http://0-9/../path.html/resource
} {http://0-9/path.html/resource}

test uri-5.51-0 {uri::canonicalize infinite loop, valid hostname on local network, FQDN} {
    uri::canonicalize http://test-host./../path.html/resource
} {http://test-host./path.html/resource}

test uri-5.52-0 {uri::canonicalize infinite loop, valid hostname "9" on local network, FQDN} {
    uri::canonicalize http://9./../path.html/resource
} {http://9./path.html/resource}

test uri-5.53-0 {uri::canonicalize infinite loop, valid hostname "0-9" on local network, FQDN} {
    uri::canonicalize http://0-9./../path.html/resource
} {http://0-9./path.html/resource}

test uri-5.1-1 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/path1/./remove/../path2/resource
} ftp://ftp.test.net/path1/path2/resource

test uri-5.2-1 {uri::canonicalize infinite loop} {
    uri::canonicalize ftp://ftp.test.net/../path2/resource
} {ftp://ftp.test.net/path2/resource}

test uri-5.3-1 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./path1/./remove/../path2/../resource
} ftp://ftp.test.net/path1/resource

test uri-5.4-1 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./././path1/./remove/../path2/../resource
} ftp://ftp.test.net/path1/resource

test uri-5.5-1 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./././path1/./remove/path2/../../resource
} ftp://ftp.test.net/path1/resource

test uri-5.6-1 {uri::canonicalize infinite loop} {
    uri::canonicalize ftp://ftp.test.net/../../../path2/resource
} {ftp://ftp.test.net/path2/resource}

test uri-5.7-1 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/path1/./remove/../path.html/resource
} ftp://ftp.test.net/path1/path.html/resource

test uri-5.8-1 {uri::canonicalize infinite loop} {
    uri::canonicalize ftp://ftp.test.net/../path.html/resource
} {ftp://ftp.test.net/path.html/resource}

test uri-5.9-1 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./path1/./remove/../path.html/../resource
} ftp://ftp.test.net/path1/resource

test uri-5.10-1 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./././path1/./remove/../path.html/../resource
} ftp://ftp.test.net/path1/resource

test uri-5.11-1 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./././path1/./remove/path.html/../../resource
} ftp://ftp.test.net/path1/resource

test uri-5.12-1 {uri::canonicalize infinite loop} {
    uri::canonicalize ftp://ftp.test.net/../../../path.html/resource
} {ftp://ftp.test.net/path.html/resource}













test uri-5.16-1 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/..s
} {ftp://ftp.test.net/..s}

test uri-5.17-1 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/..s/
} {ftp://ftp.test.net/..s/}

test uri-5.18-1 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/path1/..s
} {ftp://ftp.test.net/path1/..s}

test uri-5.19-1 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/path1/..s/
} {ftp://ftp.test.net/path1/..s/}

test uri-5.20-1 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/path1/..s/path2
} {ftp://ftp.test.net/path1/..s/path2}

test uri-5.21-1 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/path1/..s/path2/
} {ftp://ftp.test.net/path1/..s/path2/}

test uri-5.22-1 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/..s/path1
} {ftp://ftp.test.net/..s/path1}

test uri-5.23-1 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/..s/path1/
} {ftp://ftp.test.net/..s/path1/}

test uri-5.24-1 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/.s
} {ftp://ftp.test.net/.s}

test uri-5.25-1 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/.s/
} {ftp://ftp.test.net/.s/}

test uri-5.26-1 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/path1/.s
} {ftp://ftp.test.net/path1/.s}

test uri-5.27-1 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/path1/.s/
} {ftp://ftp.test.net/path1/.s/}

test uri-5.28-1 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/path1/.s/path2
} {ftp://ftp.test.net/path1/.s/path2}

test uri-5.29-1 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/path1/.s/path2/
} {ftp://ftp.test.net/path1/.s/path2/}

test uri-5.30-1 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/.s/path1
} {ftp://ftp.test.net/.s/path1}

test uri-5.31-1 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/.s/path1/
} {ftp://ftp.test.net/.s/path1/}

test uri-5.32-1 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/s..
} {ftp://ftp.test.net/s..}

test uri-5.33-1 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/s../
} {ftp://ftp.test.net/s../}

test uri-5.34-1 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/path1/s..
} {ftp://ftp.test.net/path1/s..}

test uri-5.35-1 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/path1/s../
} {ftp://ftp.test.net/path1/s../}

test uri-5.36-1 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/path1/s../path2
} {ftp://ftp.test.net/path1/s../path2}

test uri-5.37-1 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/path1/s../path2/
} {ftp://ftp.test.net/path1/s../path2/}

test uri-5.38-1 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/s../path1
} {ftp://ftp.test.net/s../path1}

test uri-5.39-1 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/s../path1/
} {ftp://ftp.test.net/s../path1/}

test uri-5.40-1 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/s.
} {ftp://ftp.test.net/s.}

test uri-5.41-1 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/s./
} {ftp://ftp.test.net/s./}

test uri-5.42-1 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/path1/s.
} {ftp://ftp.test.net/path1/s.}

test uri-5.43-1 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/path1/s./
} {ftp://ftp.test.net/path1/s./}

test uri-5.44-1 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/path1/s./path2
} {ftp://ftp.test.net/path1/s./path2}

test uri-5.45-1 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/path1/s./path2/
} {ftp://ftp.test.net/path1/s./path2/}

test uri-5.46-1 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/s./path1
} {ftp://ftp.test.net/s./path1}

test uri-5.47-1 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/s./path1/
} {ftp://ftp.test.net/s./path1/}

test uri-5.48-1 {uri::canonicalize infinite loop, valid hostname on local network} {
    uri::canonicalize ftp://test-host/../path.html/resource
} {ftp://test-host/path.html/resource}

test uri-5.49-1 {uri::canonicalize infinite loop, valid hostname "9" on local network} {
    uri::canonicalize ftp://9/../path.html/resource
} {ftp://9/path.html/resource}

test uri-5.50-1 {uri::canonicalize infinite loop, valid hostname "0-9" on local network} {
    uri::canonicalize ftp://0-9/../path.html/resource
} {ftp://0-9/path.html/resource}

test uri-5.51-1 {uri::canonicalize infinite loop, valid hostname on local network, FQDN} {
    uri::canonicalize ftp://test-host./../path.html/resource
} {ftp://test-host./path.html/resource}

test uri-5.52-1 {uri::canonicalize infinite loop, valid hostname "9" on local network, FQDN} {
    uri::canonicalize ftp://9./../path.html/resource
} {ftp://9./path.html/resource}

test uri-5.53-1 {uri::canonicalize infinite loop, valid hostname "0-9" on local network, FQDN} {
    uri::canonicalize ftp://0-9./../path.html/resource
} {ftp://0-9./path.html/resource}

test uri-5.1-2 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/path1/./remove/../path2/resource
} file://goo.test.net/path1/path2/resource

test uri-5.2-2 {uri::canonicalize infinite loop} {
    uri::canonicalize file://goo.test.net/../path2/resource
} {file://goo.test.net/path2/resource}

test uri-5.3-2 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./path1/./remove/../path2/../resource
} file://goo.test.net/path1/resource

test uri-5.4-2 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./././path1/./remove/../path2/../resource
} file://goo.test.net/path1/resource

test uri-5.5-2 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./././path1/./remove/path2/../../resource
} file://goo.test.net/path1/resource

test uri-5.6-2 {uri::canonicalize infinite loop} {
    uri::canonicalize file://goo.test.net/../../../path2/resource
} {file://goo.test.net/path2/resource}

test uri-5.7-2 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/path1/./remove/../path.html/resource
} file://goo.test.net/path1/path.html/resource

test uri-5.8-2 {uri::canonicalize infinite loop} {
    uri::canonicalize file://goo.test.net/../path.html/resource
} {file://goo.test.net/path.html/resource}

test uri-5.9-2 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./path1/./remove/../path.html/../resource
} file://goo.test.net/path1/resource

test uri-5.10-2 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./././path1/./remove/../path.html/../resource
} file://goo.test.net/path1/resource

test uri-5.11-2 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./././path1/./remove/path.html/../../resource
} file://goo.test.net/path1/resource

test uri-5.12-2 {uri::canonicalize infinite loop} {
    uri::canonicalize file://goo.test.net/../../../path.html/resource
} {file://goo.test.net/path.html/resource}













test uri-5.16-2 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/..s
} {file://goo.test.net/..s}

test uri-5.17-2 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/..s/
} {file://goo.test.net/..s/}

test uri-5.18-2 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/path1/..s
} {file://goo.test.net/path1/..s}

test uri-5.19-2 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/path1/..s/
} {file://goo.test.net/path1/..s/}

test uri-5.20-2 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/path1/..s/path2
} {file://goo.test.net/path1/..s/path2}

test uri-5.21-2 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/path1/..s/path2/
} {file://goo.test.net/path1/..s/path2/}

test uri-5.22-2 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/..s/path1
} {file://goo.test.net/..s/path1}

test uri-5.23-2 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/..s/path1/
} {file://goo.test.net/..s/path1/}

test uri-5.24-2 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/.s
} {file://goo.test.net/.s}

test uri-5.25-2 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/.s/
} {file://goo.test.net/.s/}

test uri-5.26-2 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/path1/.s
} {file://goo.test.net/path1/.s}

test uri-5.27-2 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/path1/.s/
} {file://goo.test.net/path1/.s/}

test uri-5.28-2 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/path1/.s/path2
} {file://goo.test.net/path1/.s/path2}

test uri-5.29-2 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/path1/.s/path2/
} {file://goo.test.net/path1/.s/path2/}

test uri-5.30-2 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/.s/path1
} {file://goo.test.net/.s/path1}

test uri-5.31-2 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/.s/path1/
} {file://goo.test.net/.s/path1/}

test uri-5.32-2 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/s..
} {file://goo.test.net/s..}

test uri-5.33-2 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/s../
} {file://goo.test.net/s../}

test uri-5.34-2 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/path1/s..
} {file://goo.test.net/path1/s..}

test uri-5.35-2 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/path1/s../
} {file://goo.test.net/path1/s../}

test uri-5.36-2 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/path1/s../path2
} {file://goo.test.net/path1/s../path2}

test uri-5.37-2 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/path1/s../path2/
} {file://goo.test.net/path1/s../path2/}

test uri-5.38-2 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/s../path1
} {file://goo.test.net/s../path1}

test uri-5.39-2 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/s../path1/
} {file://goo.test.net/s../path1/}

test uri-5.40-2 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/s.
} {file://goo.test.net/s.}

test uri-5.41-2 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/s./
} {file://goo.test.net/s./}

test uri-5.42-2 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/path1/s.
} {file://goo.test.net/path1/s.}

test uri-5.43-2 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/path1/s./
} {file://goo.test.net/path1/s./}

test uri-5.44-2 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/path1/s./path2
} {file://goo.test.net/path1/s./path2}

test uri-5.45-2 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/path1/s./path2/
} {file://goo.test.net/path1/s./path2/}

test uri-5.46-2 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/s./path1
} {file://goo.test.net/s./path1}

test uri-5.47-2 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/s./path1/
} {file://goo.test.net/s./path1/}

test uri-5.48-2 {uri::canonicalize infinite loop, valid hostname on local network} {
    uri::canonicalize file://test-host/../path.html/resource
} {file://test-host/path.html/resource}

test uri-5.49-2 {uri::canonicalize infinite loop, valid hostname "9" on local network} {
    uri::canonicalize file://9/../path.html/resource
} {file://9/path.html/resource}

test uri-5.50-2 {uri::canonicalize infinite loop, valid hostname "0-9" on local network} {
    uri::canonicalize file://0-9/../path.html/resource
} {file://0-9/path.html/resource}

test uri-5.51-2 {uri::canonicalize infinite loop, valid hostname on local network, FQDN} {
    uri::canonicalize file://test-host./../path.html/resource
} {file://test-host./path.html/resource}

test uri-5.52-2 {uri::canonicalize infinite loop, valid hostname "9" on local network, FQDN} {
    uri::canonicalize file://9./../path.html/resource
} {file://9./path.html/resource}

test uri-5.53-2 {uri::canonicalize infinite loop, valid hostname "0-9" on local network, FQDN} {
    uri::canonicalize file://0-9./../path.html/resource
} {file://0-9./path.html/resource}

test uri-5.1-3 {uri::canonicalize} {
    uri::canonicalize file:///path1/./remove/../path2/resource
} file:///path1/path2/resource

test uri-5.2-3 {uri::canonicalize infinite loop} {
    uri::canonicalize file:///../path2/resource
} {file:///path2/resource}

test uri-5.3-3 {uri::canonicalize} {
    uri::canonicalize file:///./path1/./remove/../path2/../resource
} file:///path1/resource

test uri-5.4-3 {uri::canonicalize} {
    uri::canonicalize file:///./././path1/./remove/../path2/../resource
} file:///path1/resource

test uri-5.5-3 {uri::canonicalize} {
    uri::canonicalize file:///./././path1/./remove/path2/../../resource
} file:///path1/resource

test uri-5.6-3 {uri::canonicalize infinite loop} {
    uri::canonicalize file:///../../../path2/resource
} {file:///path2/resource}

test uri-5.7-3 {uri::canonicalize} {
    uri::canonicalize file:///path1/./remove/../path.html/resource
} file:///path1/path.html/resource

test uri-5.8-3 {uri::canonicalize infinite loop} {
    uri::canonicalize file:///../path.html/resource
} {file:///path.html/resource}

test uri-5.9-3 {uri::canonicalize} {
    uri::canonicalize file:///./path1/./remove/../path.html/../resource
} file:///path1/resource

test uri-5.10-3 {uri::canonicalize} {
    uri::canonicalize file:///./././path1/./remove/../path.html/../resource
} file:///path1/resource

test uri-5.11-3 {uri::canonicalize} {
    uri::canonicalize file:///./././path1/./remove/path.html/../../resource
} file:///path1/resource

test uri-5.12-3 {uri::canonicalize infinite loop} {
    uri::canonicalize file:///../../../path.html/resource
} {file:///path.html/resource}













test uri-5.16-3 {uri::canonicalize not ..s} {
    uri::canonicalize file:///..s
} {file:///..s}

test uri-5.17-3 {uri::canonicalize not ..s} {
    uri::canonicalize file:///..s/
} {file:///..s/}

test uri-5.18-3 {uri::canonicalize not ..s} {
    uri::canonicalize file:///path1/..s
} {file:///path1/..s}

test uri-5.19-3 {uri::canonicalize not ..s} {
    uri::canonicalize file:///path1/..s/
} {file:///path1/..s/}

test uri-5.20-3 {uri::canonicalize not ..s} {
    uri::canonicalize file:///path1/..s/path2
} {file:///path1/..s/path2}

test uri-5.21-3 {uri::canonicalize not ..s} {
    uri::canonicalize file:///path1/..s/path2/
} {file:///path1/..s/path2/}

test uri-5.22-3 {uri::canonicalize not ..s} {
    uri::canonicalize file:///..s/path1
} {file:///..s/path1}

test uri-5.23-3 {uri::canonicalize not ..s} {
    uri::canonicalize file:///..s/path1/
} {file:///..s/path1/}

test uri-5.24-3 {uri::canonicalize not .s} {
    uri::canonicalize file:///.s
} {file:///.s}

test uri-5.25-3 {uri::canonicalize not .s} {
    uri::canonicalize file:///.s/
} {file:///.s/}

test uri-5.26-3 {uri::canonicalize not .s} {
    uri::canonicalize file:///path1/.s
} {file:///path1/.s}

test uri-5.27-3 {uri::canonicalize not .s} {
    uri::canonicalize file:///path1/.s/
} {file:///path1/.s/}

test uri-5.28-3 {uri::canonicalize not .s} {
    uri::canonicalize file:///path1/.s/path2
} {file:///path1/.s/path2}

test uri-5.29-3 {uri::canonicalize not .s} {
    uri::canonicalize file:///path1/.s/path2/
} {file:///path1/.s/path2/}

test uri-5.30-3 {uri::canonicalize not .s} {
    uri::canonicalize file:///.s/path1
} {file:///.s/path1}

test uri-5.31-3 {uri::canonicalize not .s} {
    uri::canonicalize file:///.s/path1/
} {file:///.s/path1/}

test uri-5.32-3 {uri::canonicalize not s..} {
    uri::canonicalize file:///s..
} {file:///s..}

test uri-5.33-3 {uri::canonicalize not s..} {
    uri::canonicalize file:///s../
} {file:///s../}

test uri-5.34-3 {uri::canonicalize not s..} {
    uri::canonicalize file:///path1/s..
} {file:///path1/s..}

test uri-5.35-3 {uri::canonicalize not s..} {
    uri::canonicalize file:///path1/s../
} {file:///path1/s../}

test uri-5.36-3 {uri::canonicalize not s..} {
    uri::canonicalize file:///path1/s../path2
} {file:///path1/s../path2}

test uri-5.37-3 {uri::canonicalize not s..} {
    uri::canonicalize file:///path1/s../path2/
} {file:///path1/s../path2/}

test uri-5.38-3 {uri::canonicalize not s..} {
    uri::canonicalize file:///s../path1
} {file:///s../path1}

test uri-5.39-3 {uri::canonicalize not s..} {
    uri::canonicalize file:///s../path1/
} {file:///s../path1/}

test uri-5.40-3 {uri::canonicalize not s.} {
    uri::canonicalize file:///s.
} {file:///s.}

test uri-5.41-3 {uri::canonicalize not s.} {
    uri::canonicalize file:///s./
} {file:///s./}

test uri-5.42-3 {uri::canonicalize not s.} {
    uri::canonicalize file:///path1/s.
} {file:///path1/s.}

test uri-5.43-3 {uri::canonicalize not s.} {
    uri::canonicalize file:///path1/s./
} {file:///path1/s./}

test uri-5.44-3 {uri::canonicalize not s.} {
    uri::canonicalize file:///path1/s./path2
} {file:///path1/s./path2}

test uri-5.45-3 {uri::canonicalize not s.} {
    uri::canonicalize file:///path1/s./path2/
} {file:///path1/s./path2/}

test uri-5.46-3 {uri::canonicalize not s.} {
    uri::canonicalize file:///s./path1
} {file:///s./path1}

test uri-5.47-3 {uri::canonicalize not s.} {
    uri::canonicalize file:///s./path1/
} {file:///s./path1/}

# There are no counterparts uri-5.48-3 to uri-5.53-3 for the tests
# uri-5.48-* to uri-5.53-*, *=0,1,2 because these tests try different hosts.


# -------------------------------------------------------------------------

test uri-6.0 {uri::canonicalize} {
    uri::canonicalize telnet://goo.test.net/
} telnet://goo.test.net/

# -------------------------------------------------------------------------

test uri-7.0 {uri::split & uri::join with unusual fragment including pseudo-query} {

    set ls [uri::split http://tcl.apache.org/websh/faq.ws3\#generic?foo=bar]




    eval uri::join $ls
} {http://tcl.apache.org/websh/faq.ws3#generic?foo=bar}

# -------------------------------------------------------------------------

test uri-8.0 {uri::split bug #676976, ill. char in scheme} -body {






    uri::split ht,tp://tcl.apache.org/websh
} -returnCodes error -result {{invalid url} ,tp://tcl.apache.org/websh ht,tp://tcl.apache.org/websh}

# -------------------------------------------------------------------------

test uri-9.0 {uri::split bug #936064, user information} {

    dictsort [uri::split http://foo:[email protected]:80/bla/]
} {fragment {} host baz.com path bla/ port 80 pwd bar query {} scheme http user foo}






# -------------------------------------------------------------------------

test uri-10.0 {uri::split bug #3235340, fragments after queries} {

    dictsort [uri::split  http://baz.com/foo?bar=baz#quux]




} {fragment quux host baz.com path foo port {} pwd {} query bar=baz scheme http user {}}


test uri-10.1 {uri::join bug #3235340, fragments after queries} {






    uri::join fragment quux host baz.com path foo port {} pwd {} query bar=baz scheme http user {}
} {http://baz.com/foo?bar=baz#quux}

# -------------------------------------------------------------------------

test uri-11.0 {uri::split, case-insensitive schemata, ticket dc50cc65ea} {

    dictsort [uri::split hTTp://foo:[email protected]:80/bla/]
} {fragment {} host baz.com path bla/ port 80 pwd bar query {} scheme http user foo}






# -------------------------------------------------------------------------

test uri-12.0 {uri::split, host-only without scheme, ticket cfb76ff494} {

    dictsort [uri::split www.test.de]
} {fragment {} host www.test.de path {} port {} pwd {} query {} scheme http user {}}

test uri-12.1 {uri::split, host-only without scheme, ticket cfb76ff494} {

    dictsort [uri::split http://www.test.de]
} {fragment {} host www.test.de path {} port {} pwd {} query {} scheme http user {}}











# -------------------------------------------------------------------------



test uri-13.0 {uri::isrelative rfc3986 Section 3.1} {
    ::uri::isrelative https://example.com/
} 0

test uri-13.1 {uri::isrelative rfc3986 Section 3.1} {
    ::uri::isrelative //example.com/







|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



>
>
>
>
>
>
>
>
>
>
>
>
|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



>
>
>
>
>
>
>
>
>
>
>
>
|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



>
>
>
>
>
>
>
>
>
>
>
>
|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|



|
|
>









|
>
|
>
>
>
>
|




|
>
>
>
>
>
>





|
>

|
>
>
>
>
>



|
>

>
>
>
>
|
>

|
>
>
>
>
>
>
|




|
>

|
>
>
>
>
>



|
>



|
>



>
>
>
>
>
>
>
>
>
>

>
>







1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
    set token [uri::geturl file://$file]
    removeFile __testdata
    string compare $data [set [subst $token](data)]
} 0

# -------------------------------------------------------------------------

test uri-5.1-2 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/path1/./remove/../path2/resource
} http://www.test.net/path1/path2/resource

test uri-5.2-2 {uri::canonicalize infinite loop} {
    uri::canonicalize http://www.test.net/../path2/resource
} {http://www.test.net/path2/resource}

test uri-5.3-2 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./path1/./remove/../path2/../resource
} http://www.test.net/path1/resource

test uri-5.4-2 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./././path1/./remove/../path2/../resource
} http://www.test.net/path1/resource

test uri-5.5-2 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./././path1/./remove/path2/../../resource
} http://www.test.net/path1/resource

test uri-5.6-2 {uri::canonicalize infinite loop} {
    uri::canonicalize http://www.test.net/../../../path2/resource
} {http://www.test.net/path2/resource}

test uri-5.7-2 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/path1/./remove/../path.html/resource
} http://www.test.net/path1/path.html/resource

test uri-5.8-2 {uri::canonicalize infinite loop} {
    uri::canonicalize http://www.test.net/../path.html/resource
} {http://www.test.net/path.html/resource}

test uri-5.9-2 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./path1/./remove/../path.html/../resource
} http://www.test.net/path1/resource

test uri-5.10-2 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./././path1/./remove/../path.html/../resource
} http://www.test.net/path1/resource

test uri-5.11-2 {uri::canonicalize} {
    uri::canonicalize http://www.test.net/./././path1/./remove/path.html/../../resource
} http://www.test.net/path1/resource

test uri-5.12-2 {uri::canonicalize infinite loop} {
    uri::canonicalize http://www.test.net/../../../path.html/resource
} {http://www.test.net/path.html/resource}

test uri-5.13-2 {uri::canonicalize} {
    uri::canonicalize http://www.eldritchpress.org/jc/../help.html
} {http://www.eldritchpress.org/help.html}

test uri-5.14-2 {uri::canonicalize trailing ..} {
    uri::canonicalize http://www.example.com/foo/bar/..
} {http://www.example.com/foo/}

test uri-5.15-2 {uri::canonicalize trailing ..} {
    uri::canonicalize http://www.example.com/..
} {http://www.example.com/}

test uri-5.16-2 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/..s
} {http://www.example.com/..s}

test uri-5.17-2 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/..s/
} {http://www.example.com/..s/}

test uri-5.18-2 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/path1/..s
} {http://www.example.com/path1/..s}

test uri-5.19-2 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/path1/..s/
} {http://www.example.com/path1/..s/}

test uri-5.20-2 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/path1/..s/path2
} {http://www.example.com/path1/..s/path2}

test uri-5.21-2 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/path1/..s/path2/
} {http://www.example.com/path1/..s/path2/}

test uri-5.22-2 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/..s/path1
} {http://www.example.com/..s/path1}

test uri-5.23-2 {uri::canonicalize not ..s} {
    uri::canonicalize http://www.example.com/..s/path1/
} {http://www.example.com/..s/path1/}

test uri-5.24-2 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/.s
} {http://www.example.com/.s}

test uri-5.25-2 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/.s/
} {http://www.example.com/.s/}

test uri-5.26-2 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/path1/.s
} {http://www.example.com/path1/.s}

test uri-5.27-2 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/path1/.s/
} {http://www.example.com/path1/.s/}

test uri-5.28-2 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/path1/.s/path2
} {http://www.example.com/path1/.s/path2}

test uri-5.29-2 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/path1/.s/path2/
} {http://www.example.com/path1/.s/path2/}

test uri-5.30-2 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/.s/path1
} {http://www.example.com/.s/path1}

test uri-5.31-2 {uri::canonicalize not .s} {
    uri::canonicalize http://www.example.com/.s/path1/
} {http://www.example.com/.s/path1/}

test uri-5.32-2 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/s..
} {http://www.example.com/s..}

test uri-5.33-2 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/s../
} {http://www.example.com/s../}

test uri-5.34-2 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/path1/s..
} {http://www.example.com/path1/s..}

test uri-5.35-2 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/path1/s../
} {http://www.example.com/path1/s../}

test uri-5.36-2 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/path1/s../path2
} {http://www.example.com/path1/s../path2}

test uri-5.37-2 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/path1/s../path2/
} {http://www.example.com/path1/s../path2/}

test uri-5.38-2 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/s../path1
} {http://www.example.com/s../path1}

test uri-5.39-2 {uri::canonicalize not s..} {
    uri::canonicalize http://www.example.com/s../path1/
} {http://www.example.com/s../path1/}

test uri-5.40-2 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/s.
} {http://www.example.com/s.}

test uri-5.41-2 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/s./
} {http://www.example.com/s./}

test uri-5.42-2 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/path1/s.
} {http://www.example.com/path1/s.}

test uri-5.43-2 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/path1/s./
} {http://www.example.com/path1/s./}

test uri-5.44-2 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/path1/s./path2
} {http://www.example.com/path1/s./path2}

test uri-5.45-2 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/path1/s./path2/
} {http://www.example.com/path1/s./path2/}

test uri-5.46-2 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/s./path1
} {http://www.example.com/s./path1}

test uri-5.47-2 {uri::canonicalize not s.} {
    uri::canonicalize http://www.example.com/s./path1/
} {http://www.example.com/s./path1/}

test uri-5.48-2 {uri::canonicalize infinite loop, valid hostname on local network} {
    uri::canonicalize http://test-host/../path.html/resource
} {http://test-host/path.html/resource}

test uri-5.49-2 {uri::canonicalize infinite loop, valid hostname "9" on local network} {
    uri::canonicalize http://9/../path.html/resource
} {http://9/path.html/resource}

test uri-5.50-2 {uri::canonicalize infinite loop, valid hostname "0-9" on local network} {
    uri::canonicalize http://0-9/../path.html/resource
} {http://0-9/path.html/resource}

test uri-5.51-2 {uri::canonicalize infinite loop, valid hostname on local network, FQDN} {
    uri::canonicalize http://test-host./../path.html/resource
} {http://test-host./path.html/resource}

test uri-5.52-2 {uri::canonicalize infinite loop, valid hostname "9" on local network, FQDN} {
    uri::canonicalize http://9./../path.html/resource
} {http://9./path.html/resource}

test uri-5.53-2 {uri::canonicalize infinite loop, valid hostname "0-9" on local network, FQDN} {
    uri::canonicalize http://0-9./../path.html/resource
} {http://0-9./path.html/resource}

test uri-5.1-3 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/path1/./remove/../path2/resource
} ftp://ftp.test.net/path1/path2/resource

test uri-5.2-3 {uri::canonicalize infinite loop} {
    uri::canonicalize ftp://ftp.test.net/../path2/resource
} {ftp://ftp.test.net/path2/resource}

test uri-5.3-3 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./path1/./remove/../path2/../resource
} ftp://ftp.test.net/path1/resource

test uri-5.4-3 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./././path1/./remove/../path2/../resource
} ftp://ftp.test.net/path1/resource

test uri-5.5-3 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./././path1/./remove/path2/../../resource
} ftp://ftp.test.net/path1/resource

test uri-5.6-3 {uri::canonicalize infinite loop} {
    uri::canonicalize ftp://ftp.test.net/../../../path2/resource
} {ftp://ftp.test.net/path2/resource}

test uri-5.7-3 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/path1/./remove/../path.html/resource
} ftp://ftp.test.net/path1/path.html/resource

test uri-5.8-3 {uri::canonicalize infinite loop} {
    uri::canonicalize ftp://ftp.test.net/../path.html/resource
} {ftp://ftp.test.net/path.html/resource}

test uri-5.9-3 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./path1/./remove/../path.html/../resource
} ftp://ftp.test.net/path1/resource

test uri-5.10-3 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./././path1/./remove/../path.html/../resource
} ftp://ftp.test.net/path1/resource

test uri-5.11-3 {uri::canonicalize} {
    uri::canonicalize ftp://ftp.test.net/./././path1/./remove/path.html/../../resource
} ftp://ftp.test.net/path1/resource

test uri-5.12-3 {uri::canonicalize infinite loop} {
    uri::canonicalize ftp://ftp.test.net/../../../path.html/resource
} {ftp://ftp.test.net/path.html/resource}

test uri-5.13-3 {uri::canonicalize} {
    uri::canonicalize ftp://www.eldritchpress.org/jc/../help.html
} {ftp://www.eldritchpress.org/help.html}

test uri-5.14-3 {uri::canonicalize trailing ..} {
    uri::canonicalize ftp://www.example.com/foo/bar/..
} {ftp://www.example.com/foo/}

test uri-5.15-3 {uri::canonicalize trailing ..} {
    uri::canonicalize ftp://www.example.com/..
} {ftp://www.example.com/}

test uri-5.16-3 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/..s
} {ftp://ftp.test.net/..s}

test uri-5.17-3 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/..s/
} {ftp://ftp.test.net/..s/}

test uri-5.18-3 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/path1/..s
} {ftp://ftp.test.net/path1/..s}

test uri-5.19-3 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/path1/..s/
} {ftp://ftp.test.net/path1/..s/}

test uri-5.20-3 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/path1/..s/path2
} {ftp://ftp.test.net/path1/..s/path2}

test uri-5.21-3 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/path1/..s/path2/
} {ftp://ftp.test.net/path1/..s/path2/}

test uri-5.22-3 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/..s/path1
} {ftp://ftp.test.net/..s/path1}

test uri-5.23-3 {uri::canonicalize not ..s} {
    uri::canonicalize ftp://ftp.test.net/..s/path1/
} {ftp://ftp.test.net/..s/path1/}

test uri-5.24-3 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/.s
} {ftp://ftp.test.net/.s}

test uri-5.25-3 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/.s/
} {ftp://ftp.test.net/.s/}

test uri-5.26-3 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/path1/.s
} {ftp://ftp.test.net/path1/.s}

test uri-5.27-3 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/path1/.s/
} {ftp://ftp.test.net/path1/.s/}

test uri-5.28-3 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/path1/.s/path2
} {ftp://ftp.test.net/path1/.s/path2}

test uri-5.29-3 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/path1/.s/path2/
} {ftp://ftp.test.net/path1/.s/path2/}

test uri-5.30-3 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/.s/path1
} {ftp://ftp.test.net/.s/path1}

test uri-5.31-3 {uri::canonicalize not .s} {
    uri::canonicalize ftp://ftp.test.net/.s/path1/
} {ftp://ftp.test.net/.s/path1/}

test uri-5.32-3 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/s..
} {ftp://ftp.test.net/s..}

test uri-5.33-3 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/s../
} {ftp://ftp.test.net/s../}

test uri-5.34-3 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/path1/s..
} {ftp://ftp.test.net/path1/s..}

test uri-5.35-3 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/path1/s../
} {ftp://ftp.test.net/path1/s../}

test uri-5.36-3 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/path1/s../path2
} {ftp://ftp.test.net/path1/s../path2}

test uri-5.37-3 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/path1/s../path2/
} {ftp://ftp.test.net/path1/s../path2/}

test uri-5.38-3 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/s../path1
} {ftp://ftp.test.net/s../path1}

test uri-5.39-3 {uri::canonicalize not s..} {
    uri::canonicalize ftp://ftp.test.net/s../path1/
} {ftp://ftp.test.net/s../path1/}

test uri-5.40-3 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/s.
} {ftp://ftp.test.net/s.}

test uri-5.41-3 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/s./
} {ftp://ftp.test.net/s./}

test uri-5.42-3 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/path1/s.
} {ftp://ftp.test.net/path1/s.}

test uri-5.43-3 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/path1/s./
} {ftp://ftp.test.net/path1/s./}

test uri-5.44-3 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/path1/s./path2
} {ftp://ftp.test.net/path1/s./path2}

test uri-5.45-3 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/path1/s./path2/
} {ftp://ftp.test.net/path1/s./path2/}

test uri-5.46-3 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/s./path1
} {ftp://ftp.test.net/s./path1}

test uri-5.47-3 {uri::canonicalize not s.} {
    uri::canonicalize ftp://ftp.test.net/s./path1/
} {ftp://ftp.test.net/s./path1/}

test uri-5.48-3 {uri::canonicalize infinite loop, valid hostname on local network} {
    uri::canonicalize ftp://test-host/../path.html/resource
} {ftp://test-host/path.html/resource}

test uri-5.49-3 {uri::canonicalize infinite loop, valid hostname "9" on local network} {
    uri::canonicalize ftp://9/../path.html/resource
} {ftp://9/path.html/resource}

test uri-5.50-3 {uri::canonicalize infinite loop, valid hostname "0-9" on local network} {
    uri::canonicalize ftp://0-9/../path.html/resource
} {ftp://0-9/path.html/resource}

test uri-5.51-3 {uri::canonicalize infinite loop, valid hostname on local network, FQDN} {
    uri::canonicalize ftp://test-host./../path.html/resource
} {ftp://test-host./path.html/resource}

test uri-5.52-3 {uri::canonicalize infinite loop, valid hostname "9" on local network, FQDN} {
    uri::canonicalize ftp://9./../path.html/resource
} {ftp://9./path.html/resource}

test uri-5.53-3 {uri::canonicalize infinite loop, valid hostname "0-9" on local network, FQDN} {
    uri::canonicalize ftp://0-9./../path.html/resource
} {ftp://0-9./path.html/resource}

test uri-5.1-4 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/path1/./remove/../path2/resource
} file://goo.test.net/path1/path2/resource

test uri-5.2-4 {uri::canonicalize infinite loop} {
    uri::canonicalize file://goo.test.net/../path2/resource
} {file://goo.test.net/path2/resource}

test uri-5.3-4 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./path1/./remove/../path2/../resource
} file://goo.test.net/path1/resource

test uri-5.4-4 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./././path1/./remove/../path2/../resource
} file://goo.test.net/path1/resource

test uri-5.5-4 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./././path1/./remove/path2/../../resource
} file://goo.test.net/path1/resource

test uri-5.6-4 {uri::canonicalize infinite loop} {
    uri::canonicalize file://goo.test.net/../../../path2/resource
} {file://goo.test.net/path2/resource}

test uri-5.7-4 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/path1/./remove/../path.html/resource
} file://goo.test.net/path1/path.html/resource

test uri-5.8-4 {uri::canonicalize infinite loop} {
    uri::canonicalize file://goo.test.net/../path.html/resource
} {file://goo.test.net/path.html/resource}

test uri-5.9-4 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./path1/./remove/../path.html/../resource
} file://goo.test.net/path1/resource

test uri-5.10-4 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./././path1/./remove/../path.html/../resource
} file://goo.test.net/path1/resource

test uri-5.11-4 {uri::canonicalize} {
    uri::canonicalize file://goo.test.net/./././path1/./remove/path.html/../../resource
} file://goo.test.net/path1/resource

test uri-5.12-4 {uri::canonicalize infinite loop} {
    uri::canonicalize file://goo.test.net/../../../path.html/resource
} {file://goo.test.net/path.html/resource}

test uri-5.13-4 {uri::canonicalize} {
    uri::canonicalize file://www.eldritchpress.org/jc/../help.html
} {file://www.eldritchpress.org/help.html}

test uri-5.14-4 {uri::canonicalize trailing ..} {
    uri::canonicalize file://www.example.com/foo/bar/..
} {file://www.example.com/foo/}

test uri-5.15-4 {uri::canonicalize trailing ..} {
    uri::canonicalize file://www.example.com/..
} {file://www.example.com/}

test uri-5.16-4 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/..s
} {file://goo.test.net/..s}

test uri-5.17-4 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/..s/
} {file://goo.test.net/..s/}

test uri-5.18-4 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/path1/..s
} {file://goo.test.net/path1/..s}

test uri-5.19-4 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/path1/..s/
} {file://goo.test.net/path1/..s/}

test uri-5.20-4 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/path1/..s/path2
} {file://goo.test.net/path1/..s/path2}

test uri-5.21-4 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/path1/..s/path2/
} {file://goo.test.net/path1/..s/path2/}

test uri-5.22-4 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/..s/path1
} {file://goo.test.net/..s/path1}

test uri-5.23-4 {uri::canonicalize not ..s} {
    uri::canonicalize file://goo.test.net/..s/path1/
} {file://goo.test.net/..s/path1/}

test uri-5.24-4 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/.s
} {file://goo.test.net/.s}

test uri-5.25-4 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/.s/
} {file://goo.test.net/.s/}

test uri-5.26-4 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/path1/.s
} {file://goo.test.net/path1/.s}

test uri-5.27-4 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/path1/.s/
} {file://goo.test.net/path1/.s/}

test uri-5.28-4 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/path1/.s/path2
} {file://goo.test.net/path1/.s/path2}

test uri-5.29-4 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/path1/.s/path2/
} {file://goo.test.net/path1/.s/path2/}

test uri-5.30-4 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/.s/path1
} {file://goo.test.net/.s/path1}

test uri-5.31-4 {uri::canonicalize not .s} {
    uri::canonicalize file://goo.test.net/.s/path1/
} {file://goo.test.net/.s/path1/}

test uri-5.32-4 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/s..
} {file://goo.test.net/s..}

test uri-5.33-4 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/s../
} {file://goo.test.net/s../}

test uri-5.34-4 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/path1/s..
} {file://goo.test.net/path1/s..}

test uri-5.35-4 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/path1/s../
} {file://goo.test.net/path1/s../}

test uri-5.36-4 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/path1/s../path2
} {file://goo.test.net/path1/s../path2}

test uri-5.37-4 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/path1/s../path2/
} {file://goo.test.net/path1/s../path2/}

test uri-5.38-4 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/s../path1
} {file://goo.test.net/s../path1}

test uri-5.39-4 {uri::canonicalize not s..} {
    uri::canonicalize file://goo.test.net/s../path1/
} {file://goo.test.net/s../path1/}

test uri-5.40-4 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/s.
} {file://goo.test.net/s.}

test uri-5.41-4 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/s./
} {file://goo.test.net/s./}

test uri-5.42-4 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/path1/s.
} {file://goo.test.net/path1/s.}

test uri-5.43-4 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/path1/s./
} {file://goo.test.net/path1/s./}

test uri-5.44-4 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/path1/s./path2
} {file://goo.test.net/path1/s./path2}

test uri-5.45-4 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/path1/s./path2/
} {file://goo.test.net/path1/s./path2/}

test uri-5.46-4 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/s./path1
} {file://goo.test.net/s./path1}

test uri-5.47-4 {uri::canonicalize not s.} {
    uri::canonicalize file://goo.test.net/s./path1/
} {file://goo.test.net/s./path1/}

test uri-5.48-4 {uri::canonicalize infinite loop, valid hostname on local network} {
    uri::canonicalize file://test-host/../path.html/resource
} {file://test-host/path.html/resource}

test uri-5.49-4 {uri::canonicalize infinite loop, valid hostname "9" on local network} {
    uri::canonicalize file://9/../path.html/resource
} {file://9/path.html/resource}

test uri-5.50-4 {uri::canonicalize infinite loop, valid hostname "0-9" on local network} {
    uri::canonicalize file://0-9/../path.html/resource
} {file://0-9/path.html/resource}

test uri-5.51-4 {uri::canonicalize infinite loop, valid hostname on local network, FQDN} {
    uri::canonicalize file://test-host./../path.html/resource
} {file://test-host./path.html/resource}

test uri-5.52-4 {uri::canonicalize infinite loop, valid hostname "9" on local network, FQDN} {
    uri::canonicalize file://9./../path.html/resource
} {file://9./path.html/resource}

test uri-5.53-4 {uri::canonicalize infinite loop, valid hostname "0-9" on local network, FQDN} {
    uri::canonicalize file://0-9./../path.html/resource
} {file://0-9./path.html/resource}

test uri-5.1-5 {uri::canonicalize} {
    uri::canonicalize file:///path1/./remove/../path2/resource
} file:///path1/path2/resource

test uri-5.2-5 {uri::canonicalize infinite loop} {
    uri::canonicalize file:///../path2/resource
} {file:///path2/resource}

test uri-5.3-5 {uri::canonicalize} {
    uri::canonicalize file:///./path1/./remove/../path2/../resource
} file:///path1/resource

test uri-5.4-5 {uri::canonicalize} {
    uri::canonicalize file:///./././path1/./remove/../path2/../resource
} file:///path1/resource

test uri-5.5-5 {uri::canonicalize} {
    uri::canonicalize file:///./././path1/./remove/path2/../../resource
} file:///path1/resource

test uri-5.6-5 {uri::canonicalize infinite loop} {
    uri::canonicalize file:///../../../path2/resource
} {file:///path2/resource}

test uri-5.7-5 {uri::canonicalize} {
    uri::canonicalize file:///path1/./remove/../path.html/resource
} file:///path1/path.html/resource

test uri-5.8-5 {uri::canonicalize infinite loop} {
    uri::canonicalize file:///../path.html/resource
} {file:///path.html/resource}

test uri-5.9-5 {uri::canonicalize} {
    uri::canonicalize file:///./path1/./remove/../path.html/../resource
} file:///path1/resource

test uri-5.10-5 {uri::canonicalize} {
    uri::canonicalize file:///./././path1/./remove/../path.html/../resource
} file:///path1/resource

test uri-5.11-5 {uri::canonicalize} {
    uri::canonicalize file:///./././path1/./remove/path.html/../../resource
} file:///path1/resource

test uri-5.12-5 {uri::canonicalize infinite loop} {
    uri::canonicalize file:///../../../path.html/resource
} {file:///path.html/resource}

test uri-5.13-5 {uri::canonicalize} {
    uri::canonicalize file:///jc/../help.html
} {file:///help.html}

test uri-5.14-5 {uri::canonicalize trailing ..} {
    uri::canonicalize file:///foo/bar/..
} {file:///foo/}

test uri-5.15-5 {uri::canonicalize trailing ..} {
    uri::canonicalize file:///..
} {file:///}

test uri-5.16-5 {uri::canonicalize not ..s} {
    uri::canonicalize file:///..s
} {file:///..s}

test uri-5.17-5 {uri::canonicalize not ..s} {
    uri::canonicalize file:///..s/
} {file:///..s/}

test uri-5.18-5 {uri::canonicalize not ..s} {
    uri::canonicalize file:///path1/..s
} {file:///path1/..s}

test uri-5.19-5 {uri::canonicalize not ..s} {
    uri::canonicalize file:///path1/..s/
} {file:///path1/..s/}

test uri-5.20-5 {uri::canonicalize not ..s} {
    uri::canonicalize file:///path1/..s/path2
} {file:///path1/..s/path2}

test uri-5.21-5 {uri::canonicalize not ..s} {
    uri::canonicalize file:///path1/..s/path2/
} {file:///path1/..s/path2/}

test uri-5.22-5 {uri::canonicalize not ..s} {
    uri::canonicalize file:///..s/path1
} {file:///..s/path1}

test uri-5.23-5 {uri::canonicalize not ..s} {
    uri::canonicalize file:///..s/path1/
} {file:///..s/path1/}

test uri-5.24-5 {uri::canonicalize not .s} {
    uri::canonicalize file:///.s
} {file:///.s}

test uri-5.25-5 {uri::canonicalize not .s} {
    uri::canonicalize file:///.s/
} {file:///.s/}

test uri-5.26-5 {uri::canonicalize not .s} {
    uri::canonicalize file:///path1/.s
} {file:///path1/.s}

test uri-5.27-5 {uri::canonicalize not .s} {
    uri::canonicalize file:///path1/.s/
} {file:///path1/.s/}

test uri-5.28-5 {uri::canonicalize not .s} {
    uri::canonicalize file:///path1/.s/path2
} {file:///path1/.s/path2}

test uri-5.29-5 {uri::canonicalize not .s} {
    uri::canonicalize file:///path1/.s/path2/
} {file:///path1/.s/path2/}

test uri-5.30-5 {uri::canonicalize not .s} {
    uri::canonicalize file:///.s/path1
} {file:///.s/path1}

test uri-5.31-5 {uri::canonicalize not .s} {
    uri::canonicalize file:///.s/path1/
} {file:///.s/path1/}

test uri-5.32-5 {uri::canonicalize not s..} {
    uri::canonicalize file:///s..
} {file:///s..}

test uri-5.33-5 {uri::canonicalize not s..} {
    uri::canonicalize file:///s../
} {file:///s../}

test uri-5.34-5 {uri::canonicalize not s..} {
    uri::canonicalize file:///path1/s..
} {file:///path1/s..}

test uri-5.35-5 {uri::canonicalize not s..} {
    uri::canonicalize file:///path1/s../
} {file:///path1/s../}

test uri-5.36-5 {uri::canonicalize not s..} {
    uri::canonicalize file:///path1/s../path2
} {file:///path1/s../path2}

test uri-5.37-5 {uri::canonicalize not s..} {
    uri::canonicalize file:///path1/s../path2/
} {file:///path1/s../path2/}

test uri-5.38-5 {uri::canonicalize not s..} {
    uri::canonicalize file:///s../path1
} {file:///s../path1}

test uri-5.39-5 {uri::canonicalize not s..} {
    uri::canonicalize file:///s../path1/
} {file:///s../path1/}

test uri-5.40-5 {uri::canonicalize not s.} {
    uri::canonicalize file:///s.
} {file:///s.}

test uri-5.41-5 {uri::canonicalize not s.} {
    uri::canonicalize file:///s./
} {file:///s./}

test uri-5.42-5 {uri::canonicalize not s.} {
    uri::canonicalize file:///path1/s.
} {file:///path1/s.}

test uri-5.43-5 {uri::canonicalize not s.} {
    uri::canonicalize file:///path1/s./
} {file:///path1/s./}

test uri-5.44-5 {uri::canonicalize not s.} {
    uri::canonicalize file:///path1/s./path2
} {file:///path1/s./path2}

test uri-5.45-5 {uri::canonicalize not s.} {
    uri::canonicalize file:///path1/s./path2/
} {file:///path1/s./path2/}

test uri-5.46-5 {uri::canonicalize not s.} {
    uri::canonicalize file:///s./path1
} {file:///s./path1}

test uri-5.47-5 {uri::canonicalize not s.} {
    uri::canonicalize file:///s./path1/
} {file:///s./path1/}

# There are no counterparts uri-5.48-5 to uri-5.53-5 for the tests
# uri-5.48-* to uri-5.53-*, *=2,3,4 because these tests try different
# hosts, while the tests *=5 are for the file scheme without a host.

# -------------------------------------------------------------------------

test uri-6.0 {uri::canonicalize} {
    uri::canonicalize telnet://goo.test.net/
} telnet://goo.test.net/

# -------------------------------------------------------------------------

test uri-7.0-0 {uri::split & uri::join with unusual fragment including pseudo-query} {
    ::uri::setQuirkOption NoInitialSlash 0
    eval uri::join [uri::split http://tcl.apache.org/websh/faq.ws3\#generic?foo=bar]
} {http://tcl.apache.org/websh/faq.ws3#generic?foo=bar}

test uri-7.0-1 {uri::split & uri::join with unusual fragment including pseudo-query} {
    ::uri::setQuirkOption NoInitialSlash 1
    eval uri::join [uri::split http://tcl.apache.org/websh/faq.ws3\#generic?foo=bar]
} {http://tcl.apache.org/websh/faq.ws3#generic?foo=bar}

# -------------------------------------------------------------------------

test uri-8.0-0 {uri::split bug #676976, ill. char in scheme} -body {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::split ht,tp://tcl.apache.org/websh
} -returnCodes error -result {{invalid url} ,tp://tcl.apache.org/websh ht,tp://tcl.apache.org/websh}

test uri-8.0-1 {uri::split bug #676976, ill. char in scheme} -body {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::split ht,tp://tcl.apache.org/websh
} -returnCodes error -result {{invalid url} ,tp://tcl.apache.org/websh ht,tp://tcl.apache.org/websh}

# -------------------------------------------------------------------------

test uri-9.0-0 {uri::split bug #936064, user information} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://foo:[email protected]:80/bla/]
} {fragment {} host baz.com path /bla/ port 80 pwd bar query {} scheme http user foo}

test uri-9.0-1 {uri::split bug #936064, user information} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://foo:[email protected]:80/bla/]
} {fragment {} host baz.com path bla/ pbare 0 port 80 pwd bar query {} scheme http user foo}

# -------------------------------------------------------------------------

test uri-10.0-0 {uri::split bug #3235340, fragments after queries} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split  http://baz.com/foo?bar=baz#quux]
} {fragment quux host baz.com path /foo port {} pwd {} query bar=baz scheme http user {}}

test uri-10.1-0 {uri::join bug #3235340, fragments after queries - test differs from 10.1-1} {
    ::uri::setQuirkOption NoInitialSlash 0
    uri::join fragment quux host baz.com path /foo port {} pwd {} query bar=baz scheme http user {}
} {http://baz.com/foo?bar=baz#quux}

test uri-10.0-1 {uri::split bug #3235340, fragments after queries} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split  http://baz.com/foo?bar=baz#quux]
} {fragment quux host baz.com path foo pbare 0 port {} pwd {} query bar=baz scheme http user {}}

test uri-10.1-1 {uri::join bug #3235340, fragments after queries - test differs from 10.1-0} {
    ::uri::setQuirkOption NoInitialSlash 1
    uri::join fragment quux host baz.com path foo pbare 0 port {} pwd {} query bar=baz scheme http user {}
} {http://baz.com/foo?bar=baz#quux}

# -------------------------------------------------------------------------

test uri-11.0-0 {uri::split, case-insensitive schemata, ticket dc50cc65ea} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split hTTp://foo:[email protected]:80/bla/]
} {fragment {} host baz.com path /bla/ port 80 pwd bar query {} scheme http user foo}

test uri-11.0-1 {uri::split, case-insensitive schemata, ticket dc50cc65ea} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split hTTp://foo:[email protected]:80/bla/]
} {fragment {} host baz.com path bla/ pbare 0 port 80 pwd bar query {} scheme http user foo}

# -------------------------------------------------------------------------

test uri-12.0-0 {uri::split, host-only without scheme, ticket cfb76ff494} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split www.test.de]
} {fragment {} host www.test.de path {} port {} pwd {} query {} scheme http user {}}

test uri-12.1-0 {uri::split, host-only without scheme, ticket cfb76ff494} {
    ::uri::setQuirkOption NoInitialSlash 0
    dictsort [uri::split http://www.test.de]
} {fragment {} host www.test.de path {} port {} pwd {} query {} scheme http user {}}

test uri-12.0-1 {uri::split, host-only without scheme, ticket cfb76ff494} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split www.test.de]
} {fragment {} host www.test.de path {} pbare 1 port {} pwd {} query {} scheme http user {}}

test uri-12.1-1 {uri::split, host-only without scheme, ticket cfb76ff494} {
    ::uri::setQuirkOption NoInitialSlash 1
    dictsort [uri::split http://www.test.de]
} {fragment {} host www.test.de path {} pbare 1 port {} pwd {} query {} scheme http user {}}

# -------------------------------------------------------------------------

::uri::setQuirkOption NoInitialSlash $BaseValue(NoInitialSlash)

test uri-13.0 {uri::isrelative rfc3986 Section 3.1} {
    ::uri::isrelative https://example.com/
} 0

test uri-13.1 {uri::isrelative rfc3986 Section 3.1} {
    ::uri::isrelative //example.com/
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550




1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564




1565
1566
















1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
# -------------------------------------------------------------------------
# More tests on uri::resolve - scheme-relative url with authority

test uri-14.0 {uri::resolve - scheme-relative url with authority, rfc3986 4.2} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com/dir/dir22?a=b&c=d#g
}  http://www.bar.com/dir/dir22?a=b&c=d#g

test uri-14.1 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname on local network} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //test-host
}  http://test-host/

test uri-14.2 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "9" on local network} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //9
}  http://9/

test uri-14.3 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "0-9" on local network} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //0-9
}  http://0-9/

test uri-14.4 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, FQDN} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com./dir/dir22?a=b&c=d#g
}  http://www.bar.com./dir/dir22?a=b&c=d#g

test uri-14.5 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname on local network, FQDN} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //test-host.
}  http://test-host./

test uri-14.6 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "9" on local network, FQDN} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //9.
}  http://9./

test uri-14.7 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "0-9" on local network, FQDN} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //0-9.
}  http://0-9./

test uri-14.8 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com:8080/dir/dir22?a=b&c=d#g
}  http://www.bar.com:8080/dir/dir22?a=b&c=d#g





test uri-14.9 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname on local network, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //test-host:8080
}  http://test-host:8080/

test uri-14.10 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "9" on local network, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //9:8080
}  http://9:8080/

test uri-14.11 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "0-9" on local network, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //0-9:8080
}  http://0-9:8080/

test uri-14.12 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, FQDN, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com.:8080/dir/dir22?a=b&c=d#g




}  http://www.bar.com.:8080/dir/dir22?a=b&c=d#g

















test uri-14.13 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname on local network, FQDN, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //test-host.:8080
}  http://test-host.:8080/

test uri-14.14 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "9" on local network, FQDN, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //9.:8080
}  http://9.:8080/

test uri-14.15 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "0-9" on local network, FQDN, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //0-9.:8080
}  http://0-9.:8080/

# -------------------------------------------------------------------------

test uri-15.0 {uri::resolve - scheme-relative url with authority, rfc3986 4.2} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com/dir/dir22?a=b&c=d#g
}  http://www.bar.com/dir/dir22?a=b&c=d#g








<
<
<
<
<
<
<
<
<
<
<
<




<
<
<
<
<
<
<
<
<
<
<
<




>
>
>
>
|
|
|

|
|
|

|
|
|

|
|
>
>
>
>
|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|



|



|







2304
2305
2306
2307
2308
2309
2310












2311
2312
2313
2314












2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
# -------------------------------------------------------------------------
# More tests on uri::resolve - scheme-relative url with authority

test uri-14.0 {uri::resolve - scheme-relative url with authority, rfc3986 4.2} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com/dir/dir22?a=b&c=d#g
}  http://www.bar.com/dir/dir22?a=b&c=d#g













test uri-14.4 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, FQDN} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com./dir/dir22?a=b&c=d#g
}  http://www.bar.com./dir/dir22?a=b&c=d#g













test uri-14.8 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com:8080/dir/dir22?a=b&c=d#g
}  http://www.bar.com:8080/dir/dir22?a=b&c=d#g

test uri-14.12 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, FQDN, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com.:8080/dir/dir22?a=b&c=d#g
}  http://www.bar.com.:8080/dir/dir22?a=b&c=d#g

test uri-14.1 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname on local network} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //test-host
}  http://test-host

test uri-14.2 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "9" on local network} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //9
}  http://9

test uri-14.3 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "0-9" on local network} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //0-9
}  http://0-9

test uri-14.5 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname on local network, FQDN} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //test-host.
}  http://test-host.

test uri-14.6 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "9" on local network, FQDN} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //9.
}  http://9.

test uri-14.7 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "0-9" on local network, FQDN} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //0-9.
}  http://0-9.

test uri-14.9 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname on local network, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //test-host:8080
}  http://test-host:8080

test uri-14.10 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "9" on local network, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //9:8080
}  http://9:8080

test uri-14.11 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "0-9" on local network, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //0-9:8080
}  http://0-9:8080

test uri-14.13 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname on local network, FQDN, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //test-host.:8080
}  http://test-host.:8080

test uri-14.14 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "9" on local network, FQDN, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //9.:8080
}  http://9.:8080

test uri-14.15 {uri::resolve - scheme-relative url with authority, rfc3986 4.2, valid hostname "0-9" on local network, FQDN, port} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //0-9.:8080
}  http://0-9.:8080

# -------------------------------------------------------------------------

test uri-15.0 {uri::resolve - scheme-relative url with authority, rfc3986 4.2} {
    uri::resolve http://www.foo.com/path/path2?query=url?otherquery#f //www.bar.com/dir/dir22?a=b&c=d#g
}  http://www.bar.com/dir/dir22?a=b&c=d#g