Compare commits

...
6 changed files with 158 additions and 150 deletions
+17 -17
View File
@@ -9,23 +9,23 @@
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
tcl::idna \- Support for normalization of Internationalized Domain Names
http::idna \- Support for normalization of Internationalized Domain Names
.SH SYNOPSIS
.nf
package require tcl::idna 1.0
package require http::idna 1.0
\fBtcl::idna decode\fR \fIhostname\fR
\fBtcl::idna encode\fR \fIhostname\fR
\fBtcl::idna puny decode\fR \fIstring\fR ?\fIcase\fR?
\fBtcl::idna puny encode\fR \fIstring\fR ?\fIcase\fR?
\fBtcl::idna version\fR
\fBhttp::idna decode\fR \fIhostname\fR
\fBhttp::idna encode\fR \fIhostname\fR
\fBhttp::idna puny decode\fR \fIstring\fR ?\fIcase\fR?
\fBhttp::idna puny encode\fR \fIstring\fR ?\fIcase\fR?
\fBhttp::idna version\fR
.fi
.SH DESCRIPTION
This package provides an implementation of the punycode scheme used in
Internationalised Domain Names, and some access commands. (See RFC 3492 for a
description of punycode.)
.TP
\fBtcl::idna decode\fR \fIhostname\fR
\fBhttp::idna decode\fR \fIhostname\fR
.
This command takes the name of a host that potentially contains
punycode-encoded character sequences, \fIhostname\fR, and returns the hostname
@@ -33,19 +33,19 @@ as might be displayed to the user. Note that there are often UNICODE
characters that have extremely similar glyphs, so care should be taken with
displaying hostnames to users.
.TP
\fBtcl::idna encode\fR \fIhostname\fR
\fBhttp::idna encode\fR \fIhostname\fR
.
This command takes the name of a host as might be displayed to the user,
\fIhostname\fR, and returns the version of the hostname with characters not
permitted in basic hostnames encoded with punycode.
.TP
\fBtcl::idna puny\fR \fIsubcommand ...\fR
\fBhttp::idna puny\fR \fIsubcommand ...\fR
.
This command provides direct access to the basic punycode encoder and
decoder. It supports two \fIsubcommand\fRs:
.RS
.TP
\fBtcl::idna puny decode\fR \fIstring\fR ?\fIcase\fR?
\fBhttp::idna puny decode\fR \fIstring\fR ?\fIcase\fR?
.
This command decodes the punycode-encoded string, \fIstring\fR, and returns
the result. If \fIcase\fR is provided, it is a boolean to make the case be
@@ -53,7 +53,7 @@ folded to upper case (if \fIcase\fR is true) or lower case (if \fIcase\fR is
false) during the decoding process; if omitted, no case transformation is
applied.
.TP
\fBtcl::idna puny encode\fR \fIstring\fR ?\fIcase\fR?
\fBhttp::idna puny encode\fR \fIstring\fR ?\fIcase\fR?
.
This command encodes the string, \fIstring\fR, and returns the
punycode-encoded version of the string. If \fIcase\fR is provided, it is a
@@ -62,19 +62,19 @@ lower case (if \fIcase\fR is false) during the encoding process; if omitted,
no case transformation is applied.
.RE
.TP
\fBtcl::idna version\fR
\fBhttp::idna version\fR
.
This returns the version of the \fBtcl::idna\fR package.
This returns the version of the \fBhttp::idna\fR package.
.SH "EXAMPLE"
.PP
This is an example of how punycoding of a string works:
.PP
.CS
package require tcl::idna
package require http::idna
puts [\fBtcl::idna puny encode\fR "abc\(->def"]
puts [\fBhttp::idna puny encode\fR "abc\(->def"]
# prints: \fIabcdef-kn2c\fR
puts [\fBtcl::idna puny decode\fR "abcdef-kn2c"]
puts [\fBhttp::idna puny decode\fR "abcdef-kn2c"]
# prints: \fIabc\(->def\fR
.CE
'\" TODO: show how it handles a real domain name
+15 -15
View File
@@ -11,7 +11,7 @@
package require Tcl 8.6
package require http 2.8.4
package require sqlite3
package require tcl::idna 1.0
package require http::idna 1.0.0
#
# Configuration for the cookiejar package, plus basic support procedures.
@@ -54,7 +54,7 @@ namespace eval [info object namespace ::http::cookiejar] {
# Keep this in sync with pkgIndex.tcl and with the install directories in
# Makefiles
variable version 0.1
variable version 0.1.0
variable domainlist \
http://publicsuffix.org/list/effective_tld_names.dat
@@ -82,10 +82,10 @@ namespace eval [info object namespace ::http::cookiejar] {
proc locn {secure domain path {key ""}} {
if {$key eq ""} {
format "%s://%s%s" [expr {$secure?"https":"http"}] \
[::tcl::idna encode $domain] $path
[::http::idna encode $domain] $path
} else {
format "%s://%s%s?%s" \
[expr {$secure?"https":"http"}] [::tcl::idna encode $domain] \
[expr {$secure?"https":"http"}] [::http::idna encode $domain] \
$path $key
}
}
@@ -397,8 +397,8 @@ package provide cookiejar \
continue
} elseif {[string match !* $line]} {
set line [string range $line 1 end]
set idna [string tolower [::tcl::idna encode $line]]
set utf [::tcl::idna decode [string tolower $line]]
set idna [string tolower [::http::idna encode $line]]
set utf [::http::idna decode [string tolower $line]]
db eval {
INSERT OR REPLACE INTO domains (domain, forbidden)
VALUES ($utf, 0);
@@ -412,8 +412,8 @@ package provide cookiejar \
} else {
if {[string match {\*.*} $line]} {
set line [string range $line 2 end]
set idna [string tolower [::tcl::idna encode $line]]
set utf [::tcl::idna decode [string tolower $line]]
set idna [string tolower [::http::idna encode $line]]
set utf [::http::idna decode [string tolower $line]]
db eval {
INSERT OR REPLACE INTO forbiddenSuper (domain)
VALUES ($utf);
@@ -425,8 +425,8 @@ package provide cookiejar \
}
}
} else {
set idna [string tolower [::tcl::idna encode $line]]
set utf [::tcl::idna decode [string tolower $line]]
set idna [string tolower [::http::idna encode $line]]
set utf [::http::idna decode [string tolower $line]]
}
db eval {
INSERT OR REPLACE INTO domains (domain, forbidden)
@@ -439,9 +439,9 @@ package provide cookiejar \
}
}
}
if {$utf ne [::tcl::idna decode [string tolower $idna]]} {
if {$utf ne [::http::idna decode [string tolower $idna]]} {
log warn "mismatch in IDNA handling for %s (%d, %s, %s)" \
$idna $line $utf [::tcl::idna decode $idna]
$idna $line $utf [::http::idna decode $idna]
}
}
@@ -518,7 +518,7 @@ package provide cookiejar \
set result {}
set paths [splitPath $path]
if {[regexp {[^0-9.]} $host]} {
set domains [splitDomain [string tolower [::tcl::idna encode $host]]]
set domains [splitDomain [string tolower [::http::idna encode $host]]]
} else {
# Ugh, it's a numeric domain! Restrict it to just itself...
set domains [list $host]
@@ -704,7 +704,7 @@ package provide cookiejar \
forward Database db
method lookup {{host ""} {key ""}} {
set host [string tolower [::tcl::idna encode $host]]
set host [string tolower [::http::idna encode $host]]
db transaction {
if {$host eq ""} {
set result {}
@@ -712,7 +712,7 @@ package provide cookiejar \
SELECT DISTINCT domain FROM cookies
ORDER BY domain
} {
lappend result [::tcl::idna decode [string tolower $domain]]
lappend result [::http::idna decode [string tolower $domain]]
}
return $result
} elseif {$key eq ""} {
+4 -4
View File
@@ -12,16 +12,16 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
namespace eval ::tcl::idna {
namespace eval ::http::idna {
namespace ensemble create -command puny -map {
encode punyencode
decode punydecode
}
namespace ensemble create -command ::tcl::idna -map {
namespace ensemble create -command ::http::idna -map {
encode IDNAencode
decode IDNAdecode
puny puny
version {::apply {{} {package present tcl::idna} ::}}
version {::apply {{} {package present http::idna} ::}}
}
proc IDNAencode hostname {
@@ -284,7 +284,7 @@ namespace eval ::tcl::idna {
}
}
package provide tcl::idna 1.0
package provide http::idna 1.0.0
# Local variables:
# mode: tcl
+2 -2
View File
@@ -1,4 +1,4 @@
if {![package vsatisfies [package provide Tcl] 8.6-]} {return}
package ifneeded http 2.9.1 [list tclPkgSetup $dir http 2.9.1 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}]
package ifneeded cookiejar 0.1 [list source [file join $dir cookiejar.tcl]]
package ifneeded tcl::idna 1.0 [list source [file join $dir idna.tcl]]
package ifneeded cookiejar 0.1.0 [list source [file join $dir cookiejar.tcl]]
package ifneeded http::idna 1.0.0 [list source [file join $dir idna.tcl]]
+111 -111
View File
@@ -670,116 +670,116 @@ test http-7.4 {http::formatQuery} -setup {
http::config -urlencoding $enc
} -result {%3F}
package require -exact tcl::idna 1.0
package require -exact http::idna 1.0
test http-idna-1.1 {IDNA package: basics} -returnCodes error -body {
::tcl::idna
} -result {wrong # args: should be "::tcl::idna subcommand ?arg ...?"}
::http::idna
} -result {wrong # args: should be "::http::idna subcommand ?arg ...?"}
test http-idna-1.2 {IDNA package: basics} -returnCodes error -body {
::tcl::idna ?
::http::idna ?
} -result {unknown or ambiguous subcommand "?": must be decode, encode, puny, or version}
test http-idna-1.3 {IDNA package: basics} -body {
::tcl::idna version
::http::idna version
} -result 1.0
test http-idna-1.4 {IDNA package: basics} -returnCodes error -body {
::tcl::idna version what
} -result {wrong # args: should be "::tcl::idna version"}
::http::idna version what
} -result {wrong # args: should be "::http::idna version"}
test http-idna-1.5 {IDNA package: basics} -returnCodes error -body {
::tcl::idna puny
} -result {wrong # args: should be "::tcl::idna puny subcommand ?arg ...?"}
::http::idna puny
} -result {wrong # args: should be "::http::idna puny subcommand ?arg ...?"}
test http-idna-1.6 {IDNA package: basics} -returnCodes error -body {
::tcl::idna puny ?
::http::idna puny ?
} -result {unknown or ambiguous subcommand "?": must be decode, or encode}
test http-idna-1.7 {IDNA package: basics} -returnCodes error -body {
::tcl::idna puny encode
} -result {wrong # args: should be "::tcl::idna puny encode string ?case?"}
::http::idna puny encode
} -result {wrong # args: should be "::http::idna puny encode string ?case?"}
test http-idna-1.8 {IDNA package: basics} -returnCodes error -body {
::tcl::idna puny encode a b c
} -result {wrong # args: should be "::tcl::idna puny encode string ?case?"}
::http::idna puny encode a b c
} -result {wrong # args: should be "::http::idna puny encode string ?case?"}
test http-idna-1.9 {IDNA package: basics} -returnCodes error -body {
::tcl::idna puny decode
} -result {wrong # args: should be "::tcl::idna puny decode string ?case?"}
::http::idna puny decode
} -result {wrong # args: should be "::http::idna puny decode string ?case?"}
test http-idna-1.10 {IDNA package: basics} -returnCodes error -body {
::tcl::idna puny decode a b c
} -result {wrong # args: should be "::tcl::idna puny decode string ?case?"}
::http::idna puny decode a b c
} -result {wrong # args: should be "::http::idna puny decode string ?case?"}
test http-idna-1.11 {IDNA package: basics} -returnCodes error -body {
::tcl::idna decode
} -result {wrong # args: should be "::tcl::idna decode hostname"}
::http::idna decode
} -result {wrong # args: should be "::http::idna decode hostname"}
test http-idna-1.12 {IDNA package: basics} -returnCodes error -body {
::tcl::idna encode
} -result {wrong # args: should be "::tcl::idna encode hostname"}
::http::idna encode
} -result {wrong # args: should be "::http::idna encode hostname"}
test http-idna-2.1 {puny encode: functional test} {
::tcl::idna puny encode abc
::http::idna puny encode abc
} abc-
test http-idna-2.2 {puny encode: functional test} {
::tcl::idna puny encode a\u20acb\u20acc
::http::idna puny encode a\u20acb\u20acc
} abc-k50ab
test http-idna-2.3 {puny encode: functional test} {
::tcl::idna puny encode ABC
::http::idna puny encode ABC
} ABC-
test http-idna-2.4 {puny encode: functional test} {
::tcl::idna puny encode A\u20ACB\u20ACC
::http::idna puny encode A\u20ACB\u20ACC
} ABC-k50ab
test http-idna-2.5 {puny encode: functional test} {
::tcl::idna puny encode ABC 0
::http::idna puny encode ABC 0
} abc-
test http-idna-2.6 {puny encode: functional test} {
::tcl::idna puny encode A\u20ACB\u20ACC 0
::http::idna puny encode A\u20ACB\u20ACC 0
} abc-k50ab
test http-idna-2.7 {puny encode: functional test} {
::tcl::idna puny encode ABC 1
::http::idna puny encode ABC 1
} ABC-
test http-idna-2.8 {puny encode: functional test} {
::tcl::idna puny encode A\u20ACB\u20ACC 1
::http::idna puny encode A\u20ACB\u20ACC 1
} ABC-k50ab
test http-idna-2.9 {puny encode: functional test} {
::tcl::idna puny encode abc 0
::http::idna puny encode abc 0
} abc-
test http-idna-2.10 {puny encode: functional test} {
::tcl::idna puny encode a\u20ACb\u20ACc 0
::http::idna puny encode a\u20ACb\u20ACc 0
} abc-k50ab
test http-idna-2.11 {puny encode: functional test} {
::tcl::idna puny encode abc 1
::http::idna puny encode abc 1
} ABC-
test http-idna-2.12 {puny encode: functional test} {
::tcl::idna puny encode a\u20ACb\u20ACc 1
::http::idna puny encode a\u20ACb\u20ACc 1
} ABC-k50ab
test http-idna-2.13 {puny encode: edge cases} {
::tcl::idna puny encode ""
::http::idna puny encode ""
} ""
test http-idna-2.14-A {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+0644 u+064A u+0647 u+0645 u+0627 u+0628 u+062A u+0643 u+0644
u+0645 u+0648 u+0634 u+0639 u+0631 u+0628 u+064A u+061F
}]] ""]
} egbpdaj6bu4bxfgehfvwxn
test http-idna-2.14-B {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+4ED6 u+4EEC u+4E3A u+4EC0 u+4E48 u+4E0D u+8BF4 u+4E2D u+6587
}]] ""]
} ihqwcrb4cv8a8dqg056pqjye
test http-idna-2.14-C {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+4ED6 u+5011 u+7232 u+4EC0 u+9EBD u+4E0D u+8AAA u+4E2D u+6587
}]] ""]
} ihqwctvzc91f659drss3x8bo0yb
test http-idna-2.14-D {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+0050 u+0072 u+006F u+010D u+0070 u+0072 u+006F u+0073 u+0074
u+011B u+006E u+0065 u+006D u+006C u+0075 u+0076 u+00ED u+010D
u+0065 u+0073 u+006B u+0079
}]] ""]
} Proprostnemluvesky-uyb24dma41a
test http-idna-2.14-E {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+05DC u+05DE u+05D4 u+05D4 u+05DD u+05E4 u+05E9 u+05D5 u+05D8
u+05DC u+05D0 u+05DE u+05D3 u+05D1 u+05E8 u+05D9 u+05DD u+05E2
u+05D1 u+05E8 u+05D9 u+05EA
}]] ""]
} 4dbcagdahymbxekheh6e0a7fei0b
test http-idna-2.14-F {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+092F u+0939 u+0932 u+094B u+0917 u+0939 u+093F u+0928 u+094D
u+0926 u+0940 u+0915 u+094D u+092F u+094B u+0902 u+0928 u+0939
u+0940 u+0902 u+092C u+094B u+0932 u+0938 u+0915 u+0924 u+0947
@@ -787,20 +787,20 @@ test http-idna-2.14-F {puny encode: examples from RFC 3492} {
}]] ""]
} i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd
test http-idna-2.14-G {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+306A u+305C u+307F u+3093 u+306A u+65E5 u+672C u+8A9E u+3092
u+8A71 u+3057 u+3066 u+304F u+308C u+306A u+3044 u+306E u+304B
}]] ""]
} n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa
test http-idna-2.14-H {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+C138 u+ACC4 u+C758 u+BAA8 u+B4E0 u+C0AC u+B78C u+B4E4 u+C774
u+D55C u+AD6D u+C5B4 u+B97C u+C774 u+D574 u+D55C u+B2E4 u+BA74
u+C5BC u+B9C8 u+B098 u+C88B u+C744 u+AE4C
}]] ""]
} 989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c
test http-idna-2.14-I {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+043F u+043E u+0447 u+0435 u+043C u+0443 u+0436 u+0435 u+043E
u+043D u+0438 u+043D u+0435 u+0433 u+043E u+0432 u+043E u+0440
u+044F u+0442 u+043F u+043E u+0440 u+0443 u+0441 u+0441 u+043A
@@ -808,7 +808,7 @@ test http-idna-2.14-I {puny encode: examples from RFC 3492} {
}]] ""]
} b1abfaaepdrnnbgefbadotcwatmq2g4l
test http-idna-2.14-J {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+0050 u+006F u+0072 u+0071 u+0075 u+00E9 u+006E u+006F u+0070
u+0075 u+0065 u+0064 u+0065 u+006E u+0073 u+0069 u+006D u+0070
u+006C u+0065 u+006D u+0065 u+006E u+0074 u+0065 u+0068 u+0061
@@ -817,7 +817,7 @@ test http-idna-2.14-J {puny encode: examples from RFC 3492} {
}]] ""]
} PorqunopuedensimplementehablarenEspaol-fmd56a
test http-idna-2.14-K {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+0054 u+1EA1 u+0069 u+0073 u+0061 u+006F u+0068 u+1ECD u+006B
u+0068 u+00F4 u+006E u+0067 u+0074 u+0068 u+1EC3 u+0063 u+0068
u+1EC9 u+006E u+00F3 u+0069 u+0074 u+0069 u+1EBF u+006E u+0067
@@ -825,135 +825,135 @@ test http-idna-2.14-K {puny encode: examples from RFC 3492} {
}]] ""]
} TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g
test http-idna-2.14-L {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+0033 u+5E74 u+0042 u+7D44 u+91D1 u+516B u+5148 u+751F
}]] ""]
} 3B-ww4c5e180e575a65lsy2b
test http-idna-2.14-M {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+5B89 u+5BA4 u+5948 u+7F8E u+6075 u+002D u+0077 u+0069 u+0074
u+0068 u+002D u+0053 u+0055 u+0050 u+0045 u+0052 u+002D u+004D
u+004F u+004E u+004B u+0045 u+0059 u+0053
}]] ""]
} -with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n
test http-idna-2.14-N {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+0048 u+0065 u+006C u+006C u+006F u+002D u+0041 u+006E u+006F
u+0074 u+0068 u+0065 u+0072 u+002D u+0057 u+0061 u+0079 u+002D
u+305D u+308C u+305E u+308C u+306E u+5834 u+6240
}]] ""]
} Hello-Another-Way--fc4qua05auwb3674vfr0b
test http-idna-2.14-O {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+3072 u+3068 u+3064 u+5C4B u+6839 u+306E u+4E0B u+0032
}]] ""]
} 2-u9tlzr9756bt3uc0v
test http-idna-2.14-P {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+004D u+0061 u+006A u+0069 u+3067 u+004B u+006F u+0069 u+3059
u+308B u+0035 u+79D2 u+524D
}]] ""]
} MajiKoi5-783gue6qz075azm5e
test http-idna-2.14-Q {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+30D1 u+30D5 u+30A3 u+30FC u+0064 u+0065 u+30EB u+30F3 u+30D0
}]] ""]
} de-jg4avhby1noc0d
test http-idna-2.14-R {puny encode: examples from RFC 3492} {
::tcl::idna puny encode [join [subst [string map {u+ \\u} {
::http::idna puny encode [join [subst [string map {u+ \\u} {
u+305D u+306E u+30B9 u+30D4 u+30FC u+30C9 u+3067
}]] ""]
} d9juau41awczczp
test http-idna-2.14-S {puny encode: examples from RFC 3492} {
::tcl::idna puny encode {-> $1.00 <-}
::http::idna puny encode {-> $1.00 <-}
} {-> $1.00 <--}
test http-idna-3.1 {puny decode: functional test} {
::tcl::idna puny decode abc-
::http::idna puny decode abc-
} abc
test http-idna-3.2 {puny decode: functional test} {
::tcl::idna puny decode abc-k50ab
::http::idna puny decode abc-k50ab
} a\u20acb\u20acc
test http-idna-3.3 {puny decode: functional test} {
::tcl::idna puny decode ABC-
::http::idna puny decode ABC-
} ABC
test http-idna-3.4 {puny decode: functional test} {
::tcl::idna puny decode ABC-k50ab
::http::idna puny decode ABC-k50ab
} A\u20ACB\u20ACC
test http-idna-3.5 {puny decode: functional test} {
::tcl::idna puny decode ABC-K50AB
::http::idna puny decode ABC-K50AB
} A\u20ACB\u20ACC
test http-idna-3.6 {puny decode: functional test} {
::tcl::idna puny decode abc-K50AB
::http::idna puny decode abc-K50AB
} a\u20ACb\u20ACc
test http-idna-3.7 {puny decode: functional test} {
::tcl::idna puny decode ABC- 0
::http::idna puny decode ABC- 0
} abc
test http-idna-3.8 {puny decode: functional test} {
::tcl::idna puny decode ABC-K50AB 0
::http::idna puny decode ABC-K50AB 0
} a\u20ACb\u20ACc
test http-idna-3.9 {puny decode: functional test} {
::tcl::idna puny decode ABC- 1
::http::idna puny decode ABC- 1
} ABC
test http-idna-3.10 {puny decode: functional test} {
::tcl::idna puny decode ABC-K50AB 1
::http::idna puny decode ABC-K50AB 1
} A\u20ACB\u20ACC
test http-idna-3.11 {puny decode: functional test} {
::tcl::idna puny decode abc- 0
::http::idna puny decode abc- 0
} abc
test http-idna-3.12 {puny decode: functional test} {
::tcl::idna puny decode abc-k50ab 0
::http::idna puny decode abc-k50ab 0
} a\u20ACb\u20ACc
test http-idna-3.13 {puny decode: functional test} {
::tcl::idna puny decode abc- 1
::http::idna puny decode abc- 1
} ABC
test http-idna-3.14 {puny decode: functional test} {
::tcl::idna puny decode abc-k50ab 1
::http::idna puny decode abc-k50ab 1
} A\u20ACB\u20ACC
test http-idna-3.15 {puny decode: edge cases and errors} {
# Is this case actually correct?
binary encode hex [encoding convertto utf-8 [::tcl::idna puny decode abc]]
binary encode hex [encoding convertto utf-8 [::http::idna puny decode abc]]
} c282c281c280
test http-idna-3.16 {puny decode: edge cases and errors} -returnCodes error -body {
::tcl::idna puny decode abc!
::http::idna puny decode abc!
} -result {bad decode character "!"}
test http-idna-3.17 {puny decode: edge cases and errors} {
catch {::tcl::idna puny decode abc!} -> opt
catch {::http::idna puny decode abc!} -> opt
dict get $opt -errorcode
} {PUNYCODE BAD_INPUT CHAR}
test http-idna-3.18 {puny decode: edge cases and errors} {
::tcl::idna puny decode ""
::http::idna puny decode ""
} {}
# A helper so we don't get lots of crap in failures
proc hexify s {lmap c [split $s ""] {format u+%04X [scan $c %c]}}
test http-idna-3.19-A {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode egbpdaj6bu4bxfgehfvwxn]
hexify [::http::idna puny decode egbpdaj6bu4bxfgehfvwxn]
} [list {*}{
u+0644 u+064A u+0647 u+0645 u+0627 u+0628 u+062A u+0643 u+0644
u+0645 u+0648 u+0634 u+0639 u+0631 u+0628 u+064A u+061F
}]
test http-idna-3.19-B {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode ihqwcrb4cv8a8dqg056pqjye]
hexify [::http::idna puny decode ihqwcrb4cv8a8dqg056pqjye]
} {u+4ED6 u+4EEC u+4E3A u+4EC0 u+4E48 u+4E0D u+8BF4 u+4E2D u+6587}
test http-idna-3.19-C {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode ihqwctvzc91f659drss3x8bo0yb]
hexify [::http::idna puny decode ihqwctvzc91f659drss3x8bo0yb]
} {u+4ED6 u+5011 u+7232 u+4EC0 u+9EBD u+4E0D u+8AAA u+4E2D u+6587}
test http-idna-3.19-D {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode Proprostnemluvesky-uyb24dma41a]
hexify [::http::idna puny decode Proprostnemluvesky-uyb24dma41a]
} [list {*}{
u+0050 u+0072 u+006F u+010D u+0070 u+0072 u+006F u+0073 u+0074
u+011B u+006E u+0065 u+006D u+006C u+0075 u+0076 u+00ED u+010D
u+0065 u+0073 u+006B u+0079
}]
test http-idna-3.19-E {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode 4dbcagdahymbxekheh6e0a7fei0b]
hexify [::http::idna puny decode 4dbcagdahymbxekheh6e0a7fei0b]
} [list {*}{
u+05DC u+05DE u+05D4 u+05D4 u+05DD u+05E4 u+05E9 u+05D5 u+05D8
u+05DC u+05D0 u+05DE u+05D3 u+05D1 u+05E8 u+05D9 u+05DD u+05E2
u+05D1 u+05E8 u+05D9 u+05EA
}]
test http-idna-3.19-F {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode \
hexify [::http::idna puny decode \
i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd]
} [list {*}{
u+092F u+0939 u+0932 u+094B u+0917 u+0939 u+093F u+0928 u+094D
@@ -962,13 +962,13 @@ test http-idna-3.19-F {puny decode: examples from RFC 3492} {
u+0939 u+0948 u+0902
}]
test http-idna-3.19-G {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa]
hexify [::http::idna puny decode n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa]
} [list {*}{
u+306A u+305C u+307F u+3093 u+306A u+65E5 u+672C u+8A9E u+3092
u+8A71 u+3057 u+3066 u+304F u+308C u+306A u+3044 u+306E u+304B
}]
test http-idna-3.19-H {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode \
hexify [::http::idna puny decode \
989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c]
} [list {*}{
u+C138 u+ACC4 u+C758 u+BAA8 u+B4E0 u+C0AC u+B78C u+B4E4 u+C774
@@ -976,7 +976,7 @@ test http-idna-3.19-H {puny decode: examples from RFC 3492} {
u+C5BC u+B9C8 u+B098 u+C88B u+C744 u+AE4C
}]
test http-idna-3.19-I {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode b1abfaaepdrnnbgefbadotcwatmq2g4l]
hexify [::http::idna puny decode b1abfaaepdrnnbgefbadotcwatmq2g4l]
} [list {*}{
u+043F u+043E u+0447 u+0435 u+043C u+0443 u+0436 u+0435 u+043E
u+043D u+0438 u+043D u+0435 u+0433 u+043E u+0432 u+043E u+0440
@@ -984,7 +984,7 @@ test http-idna-3.19-I {puny decode: examples from RFC 3492} {
u+0438
}]
test http-idna-3.19-J {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode \
hexify [::http::idna puny decode \
PorqunopuedensimplementehablarenEspaol-fmd56a]
} [list {*}{
u+0050 u+006F u+0072 u+0071 u+0075 u+00E9 u+006E u+006F u+0070
@@ -994,7 +994,7 @@ test http-idna-3.19-J {puny decode: examples from RFC 3492} {
u+0061 u+00F1 u+006F u+006C
}]
test http-idna-3.19-K {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode \
hexify [::http::idna puny decode \
TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g]
} [list {*}{
u+0054 u+1EA1 u+0069 u+0073 u+0061 u+006F u+0068 u+1ECD u+006B
@@ -1003,70 +1003,70 @@ test http-idna-3.19-K {puny decode: examples from RFC 3492} {
u+0056 u+0069 u+1EC7 u+0074
}]
test http-idna-3.19-L {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode 3B-ww4c5e180e575a65lsy2b]
hexify [::http::idna puny decode 3B-ww4c5e180e575a65lsy2b]
} {u+0033 u+5E74 u+0042 u+7D44 u+91D1 u+516B u+5148 u+751F}
test http-idna-3.19-M {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode -with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n]
hexify [::http::idna puny decode -with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n]
} [list {*}{
u+5B89 u+5BA4 u+5948 u+7F8E u+6075 u+002D u+0077 u+0069 u+0074
u+0068 u+002D u+0053 u+0055 u+0050 u+0045 u+0052 u+002D u+004D
u+004F u+004E u+004B u+0045 u+0059 u+0053
}]
test http-idna-3.19-N {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode Hello-Another-Way--fc4qua05auwb3674vfr0b]
hexify [::http::idna puny decode Hello-Another-Way--fc4qua05auwb3674vfr0b]
} [list {*}{
u+0048 u+0065 u+006C u+006C u+006F u+002D u+0041 u+006E u+006F
u+0074 u+0068 u+0065 u+0072 u+002D u+0057 u+0061 u+0079 u+002D
u+305D u+308C u+305E u+308C u+306E u+5834 u+6240
}]
test http-idna-3.19-O {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode 2-u9tlzr9756bt3uc0v]
hexify [::http::idna puny decode 2-u9tlzr9756bt3uc0v]
} {u+3072 u+3068 u+3064 u+5C4B u+6839 u+306E u+4E0B u+0032}
test http-idna-3.19-P {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode MajiKoi5-783gue6qz075azm5e]
hexify [::http::idna puny decode MajiKoi5-783gue6qz075azm5e]
} [list {*}{
u+004D u+0061 u+006A u+0069 u+3067 u+004B u+006F u+0069 u+3059
u+308B u+0035 u+79D2 u+524D
}]
test http-idna-3.19-Q {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode de-jg4avhby1noc0d]
hexify [::http::idna puny decode de-jg4avhby1noc0d]
} {u+30D1 u+30D5 u+30A3 u+30FC u+0064 u+0065 u+30EB u+30F3 u+30D0}
test http-idna-3.19-R {puny decode: examples from RFC 3492} {
hexify [::tcl::idna puny decode d9juau41awczczp]
hexify [::http::idna puny decode d9juau41awczczp]
} {u+305D u+306E u+30B9 u+30D4 u+30FC u+30C9 u+3067}
test http-idna-3.19-S {puny decode: examples from RFC 3492} {
::tcl::idna puny decode {-> $1.00 <--}
::http::idna puny decode {-> $1.00 <--}
} {-> $1.00 <-}
rename hexify ""
test http-idna-4.1 {IDNA encoding} {
::tcl::idna encode abc.def
::http::idna encode abc.def
} abc.def
test http-idna-4.2 {IDNA encoding} {
::tcl::idna encode a\u20acb\u20acc.def
::http::idna encode a\u20acb\u20acc.def
} xn--abc-k50ab.def
test http-idna-4.3 {IDNA encoding} {
::tcl::idna encode def.a\u20acb\u20acc
::http::idna encode def.a\u20acb\u20acc
} def.xn--abc-k50ab
test http-idna-4.4 {IDNA encoding} {
::tcl::idna encode ABC.DEF
::http::idna encode ABC.DEF
} ABC.DEF
test http-idna-4.5 {IDNA encoding} {
::tcl::idna encode A\u20acB\u20acC.def
::http::idna encode A\u20acB\u20acC.def
} xn--ABC-k50ab.def
test http-idna-4.6 {IDNA encoding: invalid edge case} {
# Should this be an error?
::tcl::idna encode abc..def
::http::idna encode abc..def
} abc..def
test http-idna-4.7 {IDNA encoding: invalid char} -returnCodes error -body {
::tcl::idna encode abc.$.def
::http::idna encode abc.$.def
} -result {bad character "$" in DNS name}
test http-idna-4.7.1 {IDNA encoding: invalid char} {
catch {::tcl::idna encode abc.$.def} -> opt
catch {::http::idna encode abc.$.def} -> opt
dict get $opt -errorcode
} {IDNA INVALID_NAME_CHARACTER {$}}
test http-idna-4.8 {IDNA encoding: empty} {
::tcl::idna encode ""
::http::idna encode ""
} {}
set overlong www.[join [subst [string map {u+ \\u} {
u+C138 u+ACC4 u+C758 u+BAA8 u+B4E0 u+C0AC u+B78C u+B4E4 u+C774
@@ -1074,44 +1074,44 @@ set overlong www.[join [subst [string map {u+ \\u} {
u+C5BC u+B9C8 u+B098 u+C88B u+C744 u+AE4C
}]] ""].com
test http-idna-4.9 {IDNA encoding: max lengths from RFC 5890} -body {
::tcl::idna encode $overlong
::http::idna encode $overlong
} -returnCodes error -result "hostname part too long"
test http-idna-4.9.1 {IDNA encoding: max lengths from RFC 5890} {
catch {::tcl::idna encode $overlong} -> opt
catch {::http::idna encode $overlong} -> opt
dict get $opt -errorcode
} {IDNA OVERLONG_PART xn--989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c}
unset overlong
test http-idna-4.10 {IDNA encoding: edge cases} {
::tcl::idna encode pass\u00e9.example.com
::http::idna encode pass\u00e9.example.com
} xn--pass-epa.example.com
test http-idna-5.1 {IDNA decoding} {
::tcl::idna decode abc.def
::http::idna decode abc.def
} abc.def
test http-idna-5.2 {IDNA decoding} {
# Invalid entry that's just a wrapper
::tcl::idna decode xn--abc-.def
::http::idna decode xn--abc-.def
} abc.def
test http-idna-5.3 {IDNA decoding} {
# Invalid entry that's just a wrapper
::tcl::idna decode xn--abc-.xn--def-
::http::idna decode xn--abc-.xn--def-
} abc.def
test http-idna-5.4 {IDNA decoding} {
# Invalid entry that's just a wrapper
::tcl::idna decode XN--abc-.XN--def-
::http::idna decode XN--abc-.XN--def-
} abc.def
test http-idna-5.5 {IDNA decoding: error cases} -returnCodes error -body {
::tcl::idna decode xn--$$$.example.com
::http::idna decode xn--$$$.example.com
} -result {bad decode character "$"}
test http-idna-5.5.1 {IDNA decoding: error cases} {
catch {::tcl::idna decode xn--$$$.example.com} -> opt
catch {::http::idna decode xn--$$$.example.com} -> opt
dict get $opt -errorcode
} {PUNYCODE BAD_INPUT CHAR}
test http-idna-5.6 {IDNA decoding: error cases} -returnCodes error -body {
::tcl::idna decode xn--a-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.def
::http::idna decode xn--a-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.def
} -result {exceeded input data}
test http-idna-5.6.1 {IDNA decoding: error cases} {
catch {::tcl::idna decode xn--a-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.def} -> opt
catch {::http::idna decode xn--a-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.def} -> opt
dict get $opt -errorcode
} {PUNYCODE BAD_INPUT LENGTH}
+9 -1
View File
@@ -1014,7 +1014,7 @@ install-libraries: libraries
$(INSTALL_DATA_DIR) "$$i"; \
fi; \
done
@for i in opt0.4 encoding ../tcl8 ../tcl8/8.4 ../tcl8/8.4/platform ../tcl8/8.5 ../tcl8/8.6 ../tcl8/8.7; do \
@for i in opt0.4 encoding ../tcl8 ../tcl8/8.4 ../tcl8/8.4/platform ../tcl8/8.5 ../tcl8/8.6 ../tcl8/8.7 ../tcl8/8.7/http; do \
if [ ! -d "$(SCRIPT_INSTALL_DIR)"/$$i ] ; then \
echo "Making directory $(SCRIPT_INSTALL_DIR)/$$i"; \
$(INSTALL_DATA_DIR) "$(SCRIPT_INSTALL_DIR)"/$$i; \
@@ -1028,6 +1028,14 @@ install-libraries: libraries
@echo "Installing package http 2.9.1 as a Tcl Module"
@$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl \
"$(MODULE_INSTALL_DIR)"/tcl8/8.6/http-2.9.1.tm
@echo "Installing package cookiejar 0.1.0 as a Tcl Module"
@$(INSTALL_DATA) $(TOP_DIR)/library/http/cookiejar.tcl \
"$(MODULE_INSTALL_DIR)"/tcl8/8.7/cookiejar-0.1.0.tm
@$(INSTALL_DATA) $(TOP_DIR)/library/http/effective_tld_names.txt.gz \
"$(MODULE_INSTALL_DIR)"/tcl8/8.7/http/effective_tld_names.txt.gz
@echo "Installing package http::idna 1.0.0 as a Tcl Module"
@$(INSTALL_DATA) $(TOP_DIR)/library/http/idna.tcl \
"$(MODULE_INSTALL_DIR)"/tcl8/8.7/http/idna-1.0.0.tm
@echo "Installing package opt0.4 files to $(SCRIPT_INSTALL_DIR)/opt0.4/"
@for i in $(TOP_DIR)/library/opt/*.tcl; do \
$(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/opt0.4; \