diff options
-rw-r--r--[-rwxr-xr-x] | compat/zlib/win32/zlib1.dll | bin | 107520 -> 107520 bytes | |||
-rw-r--r--[-rwxr-xr-x] | compat/zlib/win64/zlib1.dll | bin | 112640 -> 112640 bytes | |||
-rwxr-xr-x[-rw-r--r--] | doc/GetCwd.3 | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | doc/GetVersion.3 | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | doc/lset.n | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | generic/tclStrToD.c | 0 | ||||
-rw-r--r-- | generic/tclStubLibTbl.c | 58 | ||||
-rwxr-xr-x[-rw-r--r--] | library/encoding/tis-620.enc | 0 | ||||
-rw-r--r-- | library/http/cookiejar.tcl | 727 | ||||
-rw-r--r-- | library/http/effective_tld_names.txt.gz | bin | 0 -> 39188 bytes | |||
-rw-r--r-- | library/http/http.tcl | 109 | ||||
-rw-r--r-- | library/http/idna.tcl | 289 | ||||
-rw-r--r-- | library/http/pkgIndex.tcl | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/af.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/af_za.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ar.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ar_in.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ar_jo.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ar_lb.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ar_sy.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/be.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/bg.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/bn.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/bn_in.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ca.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/cs.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/da.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/de.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/de_at.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/de_be.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/el.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_au.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_be.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_bw.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_ca.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_gb.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_hk.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_ie.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_in.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_nz.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_ph.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_sg.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_za.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/en_zw.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/eo.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_ar.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_bo.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_cl.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_co.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_cr.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_do.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_ec.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_gt.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_hn.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_mx.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_ni.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_pa.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_pe.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_pr.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_py.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_sv.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_uy.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/es_ve.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/et.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/eu.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/eu_es.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fa.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fa_in.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fa_ir.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fi.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fo.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fo_fo.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fr.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fr_be.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fr_ca.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/fr_ch.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ga.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ga_ie.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/gl.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/gl_es.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/gv.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/gv_gb.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/he.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/hi.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/hi_in.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/hr.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/hu.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/id.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/id_id.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/is.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/it.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/it_ch.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ja.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/kl.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/kl_gl.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ko.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ko_kr.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/kok.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/kok_in.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/kw.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/kw_gb.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/lt.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/lv.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/mk.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/mr.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/mr_in.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ms.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ms_my.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/mt.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/nb.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/nl.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/nl_be.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/nn.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/pl.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/pt.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/pt_br.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ro.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ru.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ru_ua.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/sh.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/sk.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/sl.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/sq.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/sr.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/sv.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/sw.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ta.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/ta_in.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/te.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/te_in.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/th.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/tr.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/uk.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/vi.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/zh.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/zh_cn.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/zh_hk.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/zh_sg.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/msgs/zh_tw.msg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/Africa/Asmara | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/America/Atikokan | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/America/Blanc-Sablon | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/America/Indiana/Petersburg | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/America/Indiana/Tell_City | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/America/Indiana/Vincennes | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/America/Indiana/Winamac | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/America/Moncton | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/America/North_Dakota/New_Salem | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/America/Resolute | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/Atlantic/Faroe | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/Australia/Eucla | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/Europe/Guernsey | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/Europe/Isle_of_Man | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/Europe/Jersey | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/Europe/Podgorica | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | library/tzdata/Europe/Volgograd | 0 | ||||
-rw-r--r-- | tests/http.test | 451 | ||||
-rw-r--r-- | tests/httpcookie.test | 853 | ||||
-rwxr-xr-x[-rw-r--r--] | tests/lsetComp.test | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | tests/notify.test | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | tests/tcltest.test | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | tools/encoding/ebcdic.txt | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | tools/encoding/tis-620.txt | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | win/buildall.vc.bat | 0 |
165 files changed, 2428 insertions, 61 deletions
diff --git a/compat/zlib/win32/zlib1.dll b/compat/zlib/win32/zlib1.dll Binary files differindex 9ea38d5..9ea38d5 100755..100644 --- a/compat/zlib/win32/zlib1.dll +++ b/compat/zlib/win32/zlib1.dll diff --git a/compat/zlib/win64/zlib1.dll b/compat/zlib/win64/zlib1.dll Binary files differindex bd1dbc6..bd1dbc6 100755..100644 --- a/compat/zlib/win64/zlib1.dll +++ b/compat/zlib/win64/zlib1.dll diff --git a/doc/GetCwd.3 b/doc/GetCwd.3 index 58abcde..58abcde 100644..100755 --- a/doc/GetCwd.3 +++ b/doc/GetCwd.3 diff --git a/doc/GetVersion.3 b/doc/GetVersion.3 index 89f63d5..89f63d5 100644..100755 --- a/doc/GetVersion.3 +++ b/doc/GetVersion.3 diff --git a/doc/lset.n b/doc/lset.n index 954bd30..954bd30 100644..100755 --- a/doc/lset.n +++ b/doc/lset.n diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 883e2ea..883e2ea 100644..100755 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c diff --git a/generic/tclStubLibTbl.c b/generic/tclStubLibTbl.c deleted file mode 100644 index 0391502..0000000 --- a/generic/tclStubLibTbl.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * tclStubLibTbl.c -- - * - * Stub object that will be statically linked into extensions that want - * to access Tcl. - * - * Copyright (c) 1998-1999 by Scriptics Corporation. - * Copyright (c) 1998 Paul Duffin. - * - * See the file "license.terms" for information on usage and redistribution of - * this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#include "tclInt.h" - -/* - *---------------------------------------------------------------------- - * - * TclInitStubTable -- - * - * Initialize the stub table, using the structure pointed at - * by the "version" argument. - * - * Results: - * Outputs the value of the "version" argument. - * - * Side effects: - * Sets the stub table pointers. - * - *---------------------------------------------------------------------- - */ -MODULE_SCOPE const char * -TclInitStubTable( - const char *version) /* points to the version field of a - TclStubInfoType structure variable. */ -{ - tclStubsPtr = ((const TclStubInfoType *) version)->stubs; - - if (tclStubsPtr->hooks) { - tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs; - tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs; - tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs; - } else { - tclPlatStubsPtr = NULL; - tclIntStubsPtr = NULL; - tclIntPlatStubsPtr = NULL; - } - - return version; -} - -/* - * Local Variables: - * mode: c - * c-basic-offset: 4 - * fill-column: 78 - * End: - */ diff --git a/library/encoding/tis-620.enc b/library/encoding/tis-620.enc index c233be5..c233be5 100644..100755 --- a/library/encoding/tis-620.enc +++ b/library/encoding/tis-620.enc diff --git a/library/http/cookiejar.tcl b/library/http/cookiejar.tcl new file mode 100644 index 0000000..1fc1ffe --- /dev/null +++ b/library/http/cookiejar.tcl @@ -0,0 +1,727 @@ +# cookiejar.tcl -- +# +# Implementation of an HTTP cookie storage engine using SQLite. The +# implementation is done as a TclOO class, and includes a punycode +# encoder and decoder (though only the encoder is currently used). +# +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. + +# Dependencies +package require Tcl 8.6 +package require http 2.8.4 +package require sqlite3 +package require tcl::idna 1.0 + +# +# Configuration for the cookiejar package, plus basic support procedures. +# + +# This is the class that we are creating +if {![llength [info commands ::http::cookiejar]]} { + ::oo::class create ::http::cookiejar +} + +namespace eval [info object namespace ::http::cookiejar] { + proc setInt {*var val} { + upvar 1 ${*var} var + if {[catch {incr dummy $val} msg]} { + return -code error $msg + } + set var $val + } + proc setInterval {trigger *var val} { + upvar 1 ${*var} var + if {![string is integer -strict $val] || $val < 1} { + return -code error "expected positive integer but got \"$val\"" + } + set var $val + {*}$trigger + } + proc setBool {*var val} { + upvar 1 ${*var} var + if {[catch {if {$val} {}} msg]} { + return -code error $msg + } + set var [expr {!!$val}] + } + + proc setLog {*var val} { + upvar 1 ${*var} var + set var [::tcl::prefix match -message "log level" \ + {debug info warn error} $val] + } + + # Keep this in sync with pkgIndex.tcl and with the install directories in + # Makefiles + variable version 0.1 + + variable domainlist \ + http://publicsuffix.org/list/effective_tld_names.dat + variable domainfile \ + [file join [file dirname [info script]] effective_tld_names.txt.gz] + # The list is directed to from http://publicsuffix.org/list/ + variable loglevel info + variable vacuumtrigger 200 + variable retainlimit 100 + variable offline false + variable purgeinterval 60000 + variable refreshinterval 10000000 + variable domaincache {} + + # Some support procedures, none particularly useful in general + namespace eval support { + # Set up a logger if the http package isn't actually loaded yet. + if {![llength [info commands ::http::Log]]} { + proc ::http::Log args { + # Do nothing by default... + } + } + + namespace export * + proc locn {secure domain path {key ""}} { + if {$key eq ""} { + format "%s://%s%s" [expr {$secure?"https":"http"}] \ + [::tcl::idna encode $domain] $path + } else { + format "%s://%s%s?%s" \ + [expr {$secure?"https":"http"}] [::tcl::idna encode $domain] \ + $path $key + } + } + proc splitDomain domain { + set pieces [split $domain "."] + for {set i [llength $pieces]} {[incr i -1] >= 0} {} { + lappend result [join [lrange $pieces $i end] "."] + } + return $result + } + proc splitPath path { + set pieces [split [string trimleft $path "/"] "/"] + for {set j -1} {$j < [llength $pieces]} {incr j} { + lappend result /[join [lrange $pieces 0 $j] "/"] + } + return $result + } + proc isoNow {} { + set ms [clock milliseconds] + set ts [expr {$ms / 1000}] + set ms [format %03d [expr {$ms % 1000}]] + clock format $ts -format "%Y%m%dT%H%M%S.${ms}Z" -gmt 1 + } + proc log {level msg args} { + namespace upvar [info object namespace ::http::cookiejar] \ + loglevel loglevel + set who [uplevel 1 self class] + set mth [uplevel 1 self method] + set map {debug 0 info 1 warn 2 error 3} + if {[string map $map $level] >= [string map $map $loglevel]} { + set msg [format $msg {*}$args] + set LVL [string toupper $level] + ::http::Log "[isoNow] $LVL $who $mth - $msg" + } + } + } +} + +# Now we have enough information to provide the package. +package provide cookiejar \ + [set [info object namespace ::http::cookiejar]::version] + +# The implementation of the cookiejar package +::oo::define ::http::cookiejar { + self { + method configure {{optionName "\u0000\u0000"} {optionValue "\u0000\u0000"}} { + set tbl { + -domainfile {domainfile set} + -domainlist {domainlist set} + -domainrefresh {refreshinterval setInterval} + -loglevel {loglevel setLog} + -offline {offline setBool} + -purgeold {purgeinterval setInterval} + -retain {retainlimit setInt} + -vacuumtrigger {vacuumtrigger setInt} + } + dict lappend tbl -domainrefresh [namespace code { + my IntervalTrigger PostponeRefresh + }] + dict lappend tbl -purgeold [namespace code { + my IntervalTrigger PostponePurge + }] + if {$optionName eq "\u0000\u0000"} { + return [dict keys $tbl] + } + set opt [::tcl::prefix match -message "option" \ + [dict keys $tbl] $optionName] + set setter [lassign [dict get $tbl $opt] varname] + namespace upvar [namespace current] $varname var + if {$optionValue ne "\u0000\u0000"} { + {*}$setter var $optionValue + } + return $var + } + + method IntervalTrigger {method} { + # TODO: handle subclassing + foreach obj [info class instances [self]] { + [info object namespace $obj]::my $method + } + } + } + + variable purgeTimer deletions refreshTimer + constructor {{path ""}} { + namespace import [info object namespace [self class]]::support::* + + if {$path eq ""} { + sqlite3 [namespace current]::db :memory: + set storeorigin "constructed cookie store in memory" + } else { + sqlite3 [namespace current]::db $path + db timeout 500 + set storeorigin "loaded cookie store from $path" + } + + set deletions 0 + db transaction { + db eval { + --;# Store the persistent cookies in this table. + --;# Deletion policy: once they expire, or if explicitly + --;# killed. + CREATE TABLE IF NOT EXISTS persistentCookies ( + id INTEGER PRIMARY KEY, + secure INTEGER NOT NULL, + domain TEXT NOT NULL COLLATE NOCASE, + path TEXT NOT NULL, + key TEXT NOT NULL, + value TEXT NOT NULL, + originonly INTEGER NOT NULL, + expiry INTEGER NOT NULL, + lastuse INTEGER NOT NULL, + creation INTEGER NOT NULL); + CREATE UNIQUE INDEX IF NOT EXISTS persistentUnique + ON persistentCookies (domain, path, key); + CREATE INDEX IF NOT EXISTS persistentLookup + ON persistentCookies (domain, path); + + --;# Store the session cookies in this table. + --;# Deletion policy: at cookiejar instance deletion, if + --;# explicitly killed, or if the number of session cookies is + --;# too large and the cookie has not been used recently. + CREATE TEMP TABLE sessionCookies ( + id INTEGER PRIMARY KEY, + secure INTEGER NOT NULL, + domain TEXT NOT NULL COLLATE NOCASE, + path TEXT NOT NULL, + key TEXT NOT NULL, + originonly INTEGER NOT NULL, + value TEXT NOT NULL, + lastuse INTEGER NOT NULL, + creation INTEGER NOT NULL); + CREATE UNIQUE INDEX sessionUnique + ON sessionCookies (domain, path, key); + CREATE INDEX sessionLookup ON sessionCookies (domain, path); + + --;# View to allow for simple looking up of a cookie. + --;# Deletion policy: NOT SUPPORTED via this view. + CREATE TEMP VIEW cookies AS + SELECT id, domain, ( + CASE originonly WHEN 1 THEN path ELSE '.' || path END + ) AS path, key, value, secure, 1 AS persistent + FROM persistentCookies + UNION + SELECT id, domain, ( + CASE originonly WHEN 1 THEN path ELSE '.' || path END + ) AS path, key, value, secure, 0 AS persistent + FROM sessionCookies; + + --;# Encoded domain permission policy; if forbidden is 1, no + --;# cookie may be ever set for the domain, and if forbidden + --;# is 0, cookies *may* be created for the domain (overriding + --;# the forbiddenSuper table). + --;# Deletion policy: normally not modified. + CREATE TABLE IF NOT EXISTS domains ( + domain TEXT PRIMARY KEY NOT NULL, + forbidden INTEGER NOT NULL); + + --;# Domains that may not have a cookie defined for direct + --;# child domains of them. + --;# Deletion policy: normally not modified. + CREATE TABLE IF NOT EXISTS forbiddenSuper ( + domain TEXT PRIMARY KEY); + + --;# When we last retrieved the domain list. + CREATE TABLE IF NOT EXISTS domainCacheMetadata ( + id INTEGER PRIMARY KEY, + retrievalDate INTEGER, + installDate INTEGER); + } + + set cookieCount "no" + db eval { + SELECT COUNT(*) AS cookieCount FROM persistentCookies + } + log info "%s with %s entries" $storeorigin $cookieCount + + my PostponePurge + + if {$path ne ""} { + if {[db exists {SELECT 1 FROM domains}]} { + my RefreshDomains + } else { + my InitDomainList + my PostponeRefresh + } + } else { + set data [my GetDomainListOffline metadata] + my InstallDomainData $data $metadata + my PostponeRefresh + } + } + } + + method PostponePurge {} { + namespace upvar [info object namespace [self class]] \ + purgeinterval interval + catch {after cancel $purgeTimer} + set purgeTimer [after $interval [namespace code {my PurgeCookies}]] + } + + method PostponeRefresh {} { + namespace upvar [info object namespace [self class]] \ + refreshinterval interval + catch {after cancel $refreshTimer} + set refreshTimer [after $interval [namespace code {my RefreshDomains}]] + } + + method RefreshDomains {} { + # TODO: domain list refresh policy + my PostponeRefresh + } + + method HttpGet {url {timeout 0} {maxRedirects 5}} { + for {set r 0} {$r < $maxRedirects} {incr r} { + set tok [::http::geturl $url -timeout $timeout] + try { + if {[::http::status $tok] eq "timeout"} { + return -code error "connection timed out" + } elseif {[::http::ncode $tok] == 200} { + return [::http::data $tok] + } elseif {[::http::ncode $tok] >= 400} { + return -code error [::http::error $tok] + } elseif {[dict exists [::http::meta $tok] Location]} { + set url [dict get [::http::meta $tok] Location] + continue + } + return -code error \ + "unexpected state: [::http::code $tok]" + } finally { + ::http::cleanup $tok + } + } + return -code error "too many redirects" + } + method GetDomainListOnline {metaVar} { + upvar 1 $metaVar meta + namespace upvar [info object namespace [self class]] \ + domainlist url domaincache cache + lassign $cache when data + if {$when > [clock seconds] - 3600} { + log debug "using cached value created at %s" \ + [clock format $when -format {%Y%m%dT%H%M%SZ} -gmt 1] + dict set meta retrievalDate $when + return $data + } + log debug "loading domain list from %s" $url + try { + set when [clock seconds] + set data [my HttpGet $url] + set cache [list $when $data] + # TODO: Should we use the Last-Modified header instead? + dict set meta retrievalDate $when + return $data + } on error msg { + log error "failed to fetch list of forbidden cookie domains from %s: %s" \ + $url $msg + return {} + } + } + method GetDomainListOffline {metaVar} { + upvar 1 $metaVar meta + namespace upvar [info object namespace [self class]] \ + domainfile filename + log debug "loading domain list from %s" $filename + try { + set f [open $filename] + try { + if {[string match *.gz $filename]} { + zlib push gunzip $f + } + fconfigure $f -encoding utf-8 + dict set meta retrievalDate [file mtime $filename] + return [read $f] + } finally { + close $f + } + } on error {msg opt} { + log error "failed to read list of forbidden cookie domains from %s: %s" \ + $filename $msg + return -options $opt $msg + } + } + method InitDomainList {} { + namespace upvar [info object namespace [self class]] \ + offline offline + if {!$offline} { + try { + set data [my GetDomainListOnline metadata] + if {[string length $data]} { + my InstallDomainData $data $metadata + return + } + } on error {} { + log warn "attempting to fall back to built in version" + } + } + set data [my GetDomainListOffline metadata] + my InstallDomainData $data $metadata + } + + method InstallDomainData {data meta} { + set n [db total_changes] + db transaction { + foreach line [split $data "\n"] { + if {[string trim $line] eq ""} { + continue + } elseif {[string match //* $line]} { + 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]] + db eval { + INSERT OR REPLACE INTO domains (domain, forbidden) + VALUES ($utf, 0); + } + if {$idna ne $utf} { + db eval { + INSERT OR REPLACE INTO domains (domain, forbidden) + VALUES ($idna, 0); + } + } + } 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]] + db eval { + INSERT OR REPLACE INTO forbiddenSuper (domain) + VALUES ($utf); + } + if {$idna ne $utf} { + db eval { + INSERT OR REPLACE INTO forbiddenSuper (domain) + VALUES ($idna); + } + } + } else { + set idna [string tolower [::tcl::idna encode $line]] + set utf [::tcl::idna decode [string tolower $line]] + } + db eval { + INSERT OR REPLACE INTO domains (domain, forbidden) + VALUES ($utf, 1); + } + if {$idna ne $utf} { + db eval { + INSERT OR REPLACE INTO domains (domain, forbidden) + VALUES ($idna, 1); + } + } + } + if {$utf ne [::tcl::idna decode [string tolower $idna]]} { + log warn "mismatch in IDNA handling for %s (%d, %s, %s)" \ + $idna $line $utf [::tcl::idna decode $idna] + } + } + + dict with meta { + set installDate [clock seconds] + db eval { + INSERT OR REPLACE INTO domainCacheMetadata + (id, retrievalDate, installDate) + VALUES (1, $retrievalDate, $installDate); + } + } + } + set n [expr {[db total_changes] - $n}] + log info "constructed domain info with %d entries" $n + } + + # This forces the rebuild of the domain data, loading it from + method forceLoadDomainData {} { + db transaction { + db eval { + DELETE FROM domains; + DELETE FROM forbiddenSuper; + INSERT OR REPLACE INTO domainCacheMetadata + (id, retrievalDate, installDate) + VALUES (1, -1, -1); + } + my InitDomainList + } + } + + destructor { + catch { + after cancel $purgeTimer + } + catch { + after cancel $refreshTimer + } + catch { + db close + } + return + } + + method GetCookiesForHostAndPath {listVar secure host path fullhost} { + upvar 1 $listVar result + log debug "check for cookies for %s" [locn $secure $host $path] + set exact [expr {$host eq $fullhost}] + db eval { + SELECT key, value FROM persistentCookies + WHERE domain = $host AND path = $path AND secure <= $secure + AND (NOT originonly OR domain = $fullhost) + AND originonly = $exact + } { + lappend result $key $value + db eval { + UPDATE persistentCookies SET lastuse = $now WHERE id = $id + } + } + set now [clock seconds] + db eval { + SELECT id, key, value FROM sessionCookies + WHERE domain = $host AND path = $path AND secure <= $secure + AND (NOT originonly OR domain = $fullhost) + AND originonly = $exact + } { + lappend result $key $value + db eval { + UPDATE sessionCookies SET lastuse = $now WHERE id = $id + } + } + } + + method getCookies {proto host path} { + set result {} + set paths [splitPath $path] + if {[regexp {[^0-9.]} $host]} { + set domains [splitDomain [string tolower [::tcl::idna encode $host]]] + } else { + # Ugh, it's a numeric domain! Restrict it to just itself... + set domains [list $host] + } + set secure [string equal -nocase $proto "https"] + # Open question: how to move these manipulations into the database + # engine (if that's where they *should* be). + # + # Suggestion from kbk: + #LENGTH(theColumn) <= LENGTH($queryStr) AND + #SUBSTR(theColumn, LENGTH($queryStr) LENGTH(theColumn)+1) = $queryStr + # + # However, we instead do most of the work in Tcl because that lets us + # do the splitting exactly right, and it's far easier to work with + # strings in Tcl than in SQL. + db transaction { + foreach domain $domains { + foreach p $paths { + my GetCookiesForHostAndPath result $secure $domain $p $host + } + } + return $result + } + } + + method BadDomain options { + if {![dict exists $options domain]} { + log error "no domain present in options" + return 0 + } + dict with options {} + if {$domain ne $origin} { + log debug "cookie domain varies from origin (%s, %s)" \ + $domain $origin + if {[string match .* $domain]} { + set dotd $domain + } else { + set dotd .$domain + } + if {![string equal -length [string length $dotd] \ + [string reverse $dotd] [string reverse $origin]]} { + log warn "bad cookie: domain not suffix of origin" + return 1 + } + } + if {![regexp {[^0-9.]} $domain]} { + if {$domain eq $origin} { + # May set for itself + return 0 + } + log warn "bad cookie: for a numeric address" + return 1 + } + db eval { + SELECT forbidden FROM domains WHERE domain = $domain + } { + if {$forbidden} { + log warn "bad cookie: for a forbidden address" + } + return $forbidden + } + if {[regexp {^[^.]+\.(.+)$} $domain -> super] && [db exists { + SELECT 1 FROM forbiddenSuper WHERE domain = $super + }]} then { + log warn "bad cookie: for a forbidden address" + return 1 + } + return 0 + } + + method storeCookie {options} { + db transaction { + if {[my BadDomain $options]} { + return + } + set now [clock seconds] + set persistent [dict exists $options expires] + dict with options {} + if {!$persistent} { + db eval { + INSERT OR REPLACE INTO sessionCookies ( + secure, domain, path, key, value, originonly, creation, + lastuse) + VALUES ($secure, $domain, $path, $key, $value, $hostonly, + $now, $now); + DELETE FROM persistentCookies + WHERE domain = $domain AND path = $path AND key = $key + AND secure <= $secure AND originonly = $hostonly + } + incr deletions [db changes] + log debug "defined session cookie for %s" \ + [locn $secure $domain $path $key] + } elseif {$expires < $now} { + db eval { + DELETE FROM persistentCookies + WHERE domain = $domain AND path = $path AND key = $key + AND secure <= $secure AND originonly = $hostonly + } + set del [db changes] + db eval { + DELETE FROM sessionCookies + WHERE domain = $domain AND path = $path AND key = $key + AND secure <= $secure AND originonly = $hostonly + } + incr deletions [incr del [db changes]] + log debug "deleted %d cookies for %s" \ + $del [locn $secure $domain $path $key] + } else { + db eval { + INSERT OR REPLACE INTO persistentCookies ( + secure, domain, path, key, value, originonly, expiry, + creation, lastuse) + VALUES ($secure, $domain, $path, $key, $value, $hostonly, + $expires, $now, $now); + DELETE FROM sessionCookies + WHERE domain = $domain AND path = $path AND key = $key + AND secure <= $secure AND originonly = $hostonly + } + incr deletions [db changes] + log debug "defined persistent cookie for %s, expires at %s" \ + [locn $secure $domain $path $key] \ + [clock format $expires] + } + } + } + + method PurgeCookies {} { + namespace upvar [info object namespace [self class]] \ + vacuumtrigger trigger retainlimit retain + my PostponePurge + set now [clock seconds] + log debug "purging cookies that expired before %s" [clock format $now] + db transaction { + db eval { + DELETE FROM persistentCookies WHERE expiry < $now + } + incr deletions [db changes] + db eval { + DELETE FROM persistentCookies WHERE id IN ( + SELECT id FROM persistentCookies ORDER BY lastuse ASC + LIMIT -1 OFFSET $retain) + } + incr deletions [db changes] + db eval { + DELETE FROM sessionCookies WHERE id IN ( + SELECT id FROM sessionCookies ORDER BY lastuse + LIMIT -1 OFFSET $retain) + } + incr deletions [db changes] + } + + # Once we've deleted a fair bit, vacuum the database. Must be done + # outside a transaction. + if {$deletions > $trigger} { + set deletions 0 + log debug "vacuuming cookie database" + catch { + db eval { + VACUUM + } + } + } + } + + forward Database db + + method lookup {{host ""} {key ""}} { + set host [string tolower [::tcl::idna encode $host]] + db transaction { + if {$host eq ""} { + set result {} + db eval { + SELECT DISTINCT domain FROM cookies + ORDER BY domain + } { + lappend result [::tcl::idna decode [string tolower $domain]] + } + return $result + } elseif {$key eq ""} { + set result {} + db eval { + SELECT DISTINCT key FROM cookies + WHERE domain = $host + ORDER BY key + } { + lappend result $key + } + return $result + } else { + db eval { + SELECT value FROM cookies + WHERE domain = $host AND key = $key + LIMIT 1 + } { + return $value + } + return -code error "no such key for that host" + } + } + } +} + +# Local variables: +# mode: tcl +# fill-column: 78 +# End: diff --git a/library/http/effective_tld_names.txt.gz b/library/http/effective_tld_names.txt.gz Binary files differnew file mode 100644 index 0000000..9ce2b69 --- /dev/null +++ b/library/http/effective_tld_names.txt.gz diff --git a/library/http/http.tcl b/library/http/http.tcl index a6b2bfd..620ade2 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -24,6 +24,7 @@ namespace eval http { -proxyport {} -proxyfilter http::ProxyRequired -urlencoding utf-8 + -cookiejar {} } # We need a useragent string of this style or various servers will refuse to # send us compressed content even when we ask for it. This follows the @@ -86,6 +87,9 @@ namespace eval http { set defaultKeepalive 0 } + # Regular expression used to parse cookies + variable CookieRE {\s*([^][\u0000- ()<>@,;:\\""/?={}\u007f-\uffff]+)=([!\u0023-+\u002D-:<-\u005B\u005D-~]*)(?:\s*;\s*([^\u0000]+))?} + namespace export geturl config reset wait formatQuery register unregister # Useful, but not exported: data size status code } @@ -509,8 +513,12 @@ proc http::geturl {url args} { } return -code error "Illegal characters in URL path" } + if {![regexp {^[^?#]+} $srvurl state(path)]} { + set state(path) / + } } else { set srvurl / + set state(path) / } if {$proto eq ""} { set proto http @@ -695,8 +703,10 @@ proc http::Connected { token proto phost srvurl} { puts $sock "$how $srvurl HTTP/$state(-protocol)" puts $sock "Accept: $http(-accept)" array set hdrs $state(-headers) + set state(host) $host if {[info exists hdrs(Host)]} { # Allow Host spoofing. [Bug 928154] + regexp {^[^:]+} $hdrs(Host) state(host) puts $sock "Host: $hdrs(Host)" } elseif {$port == $defport} { # Don't add port in this case, to handle broken servers. [Bug @@ -752,6 +762,22 @@ proc http::Connected { token proto phost srvurl} { seek $state(-querychannel) $start } + # Note that we don't do Cookie2; that's much nastier and not normally + # observed in practice either. It also doesn't fix the multitude of + # bugs in the basic cookie spec. + if {$http(-cookiejar) ne ""} { + set cookies "" + set separator "" + foreach {key value} [{*}$http(-cookiejar) \ + getCookies $proto $host $state(path)] { + append cookies $separator $key = $value + set separator "; " + } + if {$cookies ne ""} { + puts $sock "Cookie: $cookies" + } + } + # Flush the request header and set up the fileevent that will either # push the POST data or read the response. # @@ -970,6 +996,7 @@ proc http::Write {token} { # Read the socket and handle callbacks. proc http::Event {sock token} { + variable http variable $token upvar 0 $token state @@ -1073,6 +1100,11 @@ proc http::Event {sock token} { set state(connection) \ [string trim [string tolower $value]] } + set-cookie { + if {$http(-cookiejar) ne ""} { + ParseCookie $token [string trim $value] + } + } } lappend state(meta) $key [string trim $value] } @@ -1162,6 +1194,83 @@ proc http::Event {sock token} { } } +proc http::ParseCookie {token value} { + variable http + variable CookieRE + variable $token + upvar 0 $token state + + if {![regexp $CookieRE $value -> cookiename cookieval opts]} { + # Bad cookie! No biscuit! + return + } + + # Convert the options into a list before feeding into the cookie store; + # ugly, but quite easy. + set realopts {hostonly 1 path / secure 0 httponly 0} + dict set realopts origin $state(host) + dict set realopts domain $state(host) + foreach option [split [regsub -all {;\s+} $opts \u0000] \u0000] { + regexp {^(.*?)(?:=(.*))?$} $option -> optname optval + switch -exact -- [string tolower $optname] { + expires { + if {[catch { + #Sun, 06 Nov 1994 08:49:37 GMT + dict set realopts expires \ + [clock scan $optval -format "%a, %d %b %Y %T %Z"] + }] && [catch { + # Google does this one + #Mon, 01-Jan-1990 00:00:00 GMT + dict set realopts expires \ + [clock scan $optval -format "%a, %d-%b-%Y %T %Z"] + }] && [catch { + # This is in the RFC, but it is also in the original + # Netscape cookie spec, now online at: + # <URL:http://curl.haxx.se/rfc/cookie_spec.html> + #Sunday, 06-Nov-94 08:49:37 GMT + dict set realopts expires \ + [clock scan $optval -format "%A, %d-%b-%y %T %Z"] + }]} {catch { + #Sun Nov 6 08:49:37 1994 + dict set realopts expires \ + [clock scan $optval -gmt 1 -format "%a %b %d %T %Y"] + }} + } + max-age { + # Normalize + if {[string is integer -strict $optval]} { + dict set realopts expires [expr {[clock seconds] + $optval}] + } + } + domain { + # From the domain-matches definition [RFC 2109, section 2]: + # Host A's name domain-matches host B's if [...] + # A is a FQDN string and has the form NB, where N is a + # non-empty name string, B has the form .B', and B' is a + # FQDN string. (So, x.y.com domain-matches .y.com but + # not y.com.) + if {$optval ne "" && ![string match *. $optval]} { + dict set realopts domain [string trimleft $optval "."] + dict set realopts hostonly [expr { + ! [string match .* $optval] + }] + } + } + path { + if {[string match /* $optval]} { + dict set realopts path $optval + } + } + secure - httponly { + dict set realopts [string tolower $optname] 1 + } + } + } + dict set realopts key $cookiename + dict set realopts value $cookieval + {*}$http(-cookiejar) storeCookie $realopts +} + # http::getTextLine -- # # Get one line with the stream in blocking crlf mode diff --git a/library/http/idna.tcl b/library/http/idna.tcl new file mode 100644 index 0000000..53e45ca --- /dev/null +++ b/library/http/idna.tcl @@ -0,0 +1,289 @@ +# cookiejar.tcl -- +# +# Implementation of IDNA (Internationalized Domain Names for +# Applications) encoding/decoding system, built on a punycode engine +# developed directly from the code in RFC 3492, Appendix C (with +# substantial modifications). +# +# 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 ensemble create -command puny -map { + encode punyencode + decode punydecode + } + namespace ensemble create -command ::tcl::idna -map { + encode IDNAencode + decode IDNAdecode + puny puny + version {::apply {{} {package present tcl::idna} ::}} + } + + proc IDNAencode hostname { + set parts {} + # Split term from RFC 3490, Sec 3.1 + foreach part [split $hostname "\u002E\u3002\uFF0E\uFF61"] { + if {[regexp {[^-A-Za-z0-9]} $part]} { + if {[regexp {[^-A-Za-z0-9\u00a1-\uffff]} $part ch]} { + scan $ch %c c + if {$ch < "!" || $ch > "~"} { + set ch [format "\\u%04x" $c] + } + throw [list IDNA INVALID_NAME_CHARACTER $ch] \ + "bad character \"$ch\" in DNS name" + } + set part xn--[punyencode $part] + # Length restriction from RFC 5890, Sec 2.3.1 + if {[string length $part] > 63} { + throw [list IDNA OVERLONG_PART $part] \ + "hostname part too long" + } + } + lappend parts $part + } + return [join $parts .] + } + proc IDNAdecode hostname { + set parts {} + # Split term from RFC 3490, Sec 3.1 + foreach part [split $hostname "\u002E\u3002\uFF0E\uFF61"] { + if {[string match -nocase "xn--*" $part]} { + set part [punydecode [string range $part 4 end]] + } + lappend parts $part + } + return [join $parts .] + } + + variable digits [split "abcdefghijklmnopqrstuvwxyz0123456789" ""] + # Bootstring parameters for Punycode + variable base 36 + variable tmin 1 + variable tmax 26 + variable skew 38 + variable damp 700 + variable initial_bias 72 + variable initial_n 0x80 + + variable max_codepoint 0xFFFF ;# 0x10FFFF would be correct, except Tcl + # can't handle non-BMP characters right now + # anyway. + + proc adapt {delta first numchars} { + variable base + variable tmin + variable tmax + variable damp + variable skew + + set delta [expr {$delta / ($first ? $damp : 2)}] + incr delta [expr {$delta / $numchars}] + set k 0 + while {$delta > ($base - $tmin) * $tmax / 2} { + set delta [expr {$delta / ($base-$tmin)}] + incr k $base + } + return [expr {$k + ($base-$tmin+1) * $delta / ($delta+$skew)}] + } + + # Main punycode encoding function + proc punyencode {string {case ""}} { + variable digits + variable tmin + variable tmax + variable base + variable initial_n + variable initial_bias + + if {![string is boolean $case]} { + return -code error "\"$case\" must be boolean" + } + + set in {} + foreach char [set string [split $string ""]] { + scan $char "%c" ch + lappend in $ch + } + set output {} + + # Initialize the state: + set n $initial_n + set delta 0 + set bias $initial_bias + + # Handle the basic code points: + foreach ch $string { + if {$ch < "\u0080"} { + if {$case eq ""} { + append output $ch + } elseif {[string is true $case]} { + append output [string toupper $ch] + } elseif {[string is false $case]} { + append output [string tolower $ch] + } + } + } + + set b [string length $output] + + # h is the number of code points that have been handled, b is the + # number of basic code points. + + if {$b > 0} { + append output "-" + } + + # Main encoding loop: + + for {set h $b} {$h < [llength $in]} {incr delta; incr n} { + # All non-basic code points < n have been handled already. Find + # the next larger one: + + set m inf + foreach ch $in { + if {$ch >= $n && $ch < $m} { + set m $ch + } + } + + # Increase delta enough to advance the decoder's <n,i> state to + # <m,0>, but guard against overflow: + + if {$m-$n > (0xffffffff-$delta)/($h+1)} { + throw {PUNYCODE OVERFLOW} "overflow in delta computation" + } + incr delta [expr {($m-$n) * ($h+1)}] + set n $m + + foreach ch $in { + if {$ch < $n && ([incr delta] & 0xffffffff) == 0} { + throw {PUNYCODE OVERFLOW} "overflow in delta computation" + } + + if {$ch != $n} { + continue + } + + # Represent delta as a generalized variable-length integer: + + for {set q $delta; set k $base} true {incr k $base} { + set t [expr {min(max($k-$bias, $tmin), $tmax)}] + if {$q < $t} { + break + } + append output \ + [lindex $digits [expr {$t + ($q-$t)%($base-$t)}]] + set q [expr {($q-$t) / ($base-$t)}] + } + + append output [lindex $digits $q] + set bias [adapt $delta [expr {$h==$b}] [expr {$h+1}]] + set delta 0 + incr h + } + } + + return $output + } + + # Main punycode decode function + proc punydecode {string {case ""}} { + variable tmin + variable tmax + variable base + variable initial_n + variable initial_bias + variable max_codepoint + + if {![string is boolean $case]} { + return -code error "\"$case\" must be boolean" + } + + # Initialize the state: + + set n $initial_n + set i 0 + set first 1 + set bias $initial_bias + + # Split the string into the "real" ASCII characters and the ones to + # feed into the main decoder. Note that we don't need to check the + # result of [regexp] because that RE will technically match any string + # at all. + + regexp {^(?:(.*)-)?([^-]*)$} $string -> pre post + if {[string is true -strict $case]} { + set pre [string toupper $pre] + } elseif {[string is false -strict $case]} { + set pre [string tolower $pre] + } + set output [split $pre ""] + set out [llength $output] + + # Main decoding loop: + + for {set in 0} {$in < [string length $post]} {incr in} { + # Decode a generalized variable-length integer into delta, which + # gets added to i. The overflow checking is easier if we increase + # i as we go, then subtract off its starting value at the end to + # obtain delta. + + for {set oldi $i; set w 1; set k $base} 1 {incr in} { + if {[set ch [string index $post $in]] eq ""} { + throw {PUNYCODE BAD_INPUT LENGTH} "exceeded input data" + } + if {[string match -nocase {[a-z]} $ch]} { + scan [string toupper $ch] %c digit + incr digit -65 + } elseif {[string match {[0-9]} $ch]} { + set digit [expr {$ch + 26}] + } else { + throw {PUNYCODE BAD_INPUT CHAR} \ + "bad decode character \"$ch\"" + } + incr i [expr {$digit * $w}] + set t [expr {min(max($tmin, $k-$bias), $tmax)}] + if {$digit < $t} { + set bias [adapt [expr {$i-$oldi}] $first [incr out]] + set first 0 + break + } + if {[set w [expr {$w * ($base - $t)}]] > 0x7fffffff} { + throw {PUNYCODE OVERFLOW} \ + "excessively large integer computed in digit decode" + } + incr k $base + } + + # i was supposed to wrap around from out+1 to 0, incrementing n + # each time, so we'll fix that now: + + if {[incr n [expr {$i / $out}]] > 0x7fffffff} { + throw {PUNYCODE OVERFLOW} \ + "excessively large integer computed in character choice" + } elseif {$n > $max_codepoint} { + if {$n < 0x10ffff} { + throw {PUNYCODE NON_BMP} \ + [format "unsupported character U+%06x" $n] + } + throw {PUNYCODE NON_UNICODE} "bad codepoint $n" + } + set i [expr {$i % $out}] + + # Insert n at position i of the output: + + set output [linsert $output $i [format "%c" $n]] + incr i + } + + return [join $output ""] + } +} + +package provide tcl::idna 1.0 + +# Local variables: +# mode: tcl +# fill-column: 78 +# End: diff --git a/library/http/pkgIndex.tcl b/library/http/pkgIndex.tcl index 27ba795..2928f88 100644 --- a/library/http/pkgIndex.tcl +++ b/library/http/pkgIndex.tcl @@ -1,2 +1,4 @@ if {![package vsatisfies [package provide Tcl] 8.6]} {return} package ifneeded http 2.8.8 [list tclPkgSetup $dir http 2.8.8 {{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]] diff --git a/library/msgs/af.msg b/library/msgs/af.msg index 0892615..0892615 100644..100755 --- a/library/msgs/af.msg +++ b/library/msgs/af.msg diff --git a/library/msgs/af_za.msg b/library/msgs/af_za.msg index fef48ad..fef48ad 100644..100755 --- a/library/msgs/af_za.msg +++ b/library/msgs/af_za.msg diff --git a/library/msgs/ar.msg b/library/msgs/ar.msg index 257157f..257157f 100644..100755 --- a/library/msgs/ar.msg +++ b/library/msgs/ar.msg diff --git a/library/msgs/ar_in.msg b/library/msgs/ar_in.msg index 185e49c..185e49c 100644..100755 --- a/library/msgs/ar_in.msg +++ b/library/msgs/ar_in.msg diff --git a/library/msgs/ar_jo.msg b/library/msgs/ar_jo.msg index 0f5e269..0f5e269 100644..100755 --- a/library/msgs/ar_jo.msg +++ b/library/msgs/ar_jo.msg diff --git a/library/msgs/ar_lb.msg b/library/msgs/ar_lb.msg index e62acd3..e62acd3 100644..100755 --- a/library/msgs/ar_lb.msg +++ b/library/msgs/ar_lb.msg diff --git a/library/msgs/ar_sy.msg b/library/msgs/ar_sy.msg index d5e1c87..d5e1c87 100644..100755 --- a/library/msgs/ar_sy.msg +++ b/library/msgs/ar_sy.msg diff --git a/library/msgs/be.msg b/library/msgs/be.msg index 379a1d7..379a1d7 100644..100755 --- a/library/msgs/be.msg +++ b/library/msgs/be.msg diff --git a/library/msgs/bg.msg b/library/msgs/bg.msg index ff17759..ff17759 100644..100755 --- a/library/msgs/bg.msg +++ b/library/msgs/bg.msg diff --git a/library/msgs/bn.msg b/library/msgs/bn.msg index 664b9d8..664b9d8 100644..100755 --- a/library/msgs/bn.msg +++ b/library/msgs/bn.msg diff --git a/library/msgs/bn_in.msg b/library/msgs/bn_in.msg index 28c000f..28c000f 100644..100755 --- a/library/msgs/bn_in.msg +++ b/library/msgs/bn_in.msg diff --git a/library/msgs/ca.msg b/library/msgs/ca.msg index 36c9772..36c9772 100644..100755 --- a/library/msgs/ca.msg +++ b/library/msgs/ca.msg diff --git a/library/msgs/cs.msg b/library/msgs/cs.msg index 8db8bdd..8db8bdd 100644..100755 --- a/library/msgs/cs.msg +++ b/library/msgs/cs.msg diff --git a/library/msgs/da.msg b/library/msgs/da.msg index e4fec7f..e4fec7f 100644..100755 --- a/library/msgs/da.msg +++ b/library/msgs/da.msg diff --git a/library/msgs/de.msg b/library/msgs/de.msg index 9eb3145..9eb3145 100644..100755 --- a/library/msgs/de.msg +++ b/library/msgs/de.msg diff --git a/library/msgs/de_at.msg b/library/msgs/de_at.msg index 61bc266..61bc266 100644..100755 --- a/library/msgs/de_at.msg +++ b/library/msgs/de_at.msg diff --git a/library/msgs/de_be.msg b/library/msgs/de_be.msg index 3614763..3614763 100644..100755 --- a/library/msgs/de_be.msg +++ b/library/msgs/de_be.msg diff --git a/library/msgs/el.msg b/library/msgs/el.msg index ac19f62..ac19f62 100644..100755 --- a/library/msgs/el.msg +++ b/library/msgs/el.msg diff --git a/library/msgs/en_au.msg b/library/msgs/en_au.msg index 7f9870c..7f9870c 100644..100755 --- a/library/msgs/en_au.msg +++ b/library/msgs/en_au.msg diff --git a/library/msgs/en_be.msg b/library/msgs/en_be.msg index 5072986..5072986 100644..100755 --- a/library/msgs/en_be.msg +++ b/library/msgs/en_be.msg diff --git a/library/msgs/en_bw.msg b/library/msgs/en_bw.msg index 8fd20c7..8fd20c7 100644..100755 --- a/library/msgs/en_bw.msg +++ b/library/msgs/en_bw.msg diff --git a/library/msgs/en_ca.msg b/library/msgs/en_ca.msg index 278efe7..278efe7 100644..100755 --- a/library/msgs/en_ca.msg +++ b/library/msgs/en_ca.msg diff --git a/library/msgs/en_gb.msg b/library/msgs/en_gb.msg index 5c61c43..5c61c43 100644..100755 --- a/library/msgs/en_gb.msg +++ b/library/msgs/en_gb.msg diff --git a/library/msgs/en_hk.msg b/library/msgs/en_hk.msg index 8b33bc0..8b33bc0 100644..100755 --- a/library/msgs/en_hk.msg +++ b/library/msgs/en_hk.msg diff --git a/library/msgs/en_ie.msg b/library/msgs/en_ie.msg index ba621cf..ba621cf 100644..100755 --- a/library/msgs/en_ie.msg +++ b/library/msgs/en_ie.msg diff --git a/library/msgs/en_in.msg b/library/msgs/en_in.msg index a1f155d..a1f155d 100644..100755 --- a/library/msgs/en_in.msg +++ b/library/msgs/en_in.msg diff --git a/library/msgs/en_nz.msg b/library/msgs/en_nz.msg index b419017..b419017 100644..100755 --- a/library/msgs/en_nz.msg +++ b/library/msgs/en_nz.msg diff --git a/library/msgs/en_ph.msg b/library/msgs/en_ph.msg index 682666d..682666d 100644..100755 --- a/library/msgs/en_ph.msg +++ b/library/msgs/en_ph.msg diff --git a/library/msgs/en_sg.msg b/library/msgs/en_sg.msg index 4dc5b1d..4dc5b1d 100644..100755 --- a/library/msgs/en_sg.msg +++ b/library/msgs/en_sg.msg diff --git a/library/msgs/en_za.msg b/library/msgs/en_za.msg index fe43797..fe43797 100644..100755 --- a/library/msgs/en_za.msg +++ b/library/msgs/en_za.msg diff --git a/library/msgs/en_zw.msg b/library/msgs/en_zw.msg index 2a5804f..2a5804f 100644..100755 --- a/library/msgs/en_zw.msg +++ b/library/msgs/en_zw.msg diff --git a/library/msgs/eo.msg b/library/msgs/eo.msg index 1d2a24f..1d2a24f 100644..100755 --- a/library/msgs/eo.msg +++ b/library/msgs/eo.msg diff --git a/library/msgs/es.msg b/library/msgs/es.msg index a24f0a1..a24f0a1 100644..100755 --- a/library/msgs/es.msg +++ b/library/msgs/es.msg diff --git a/library/msgs/es_ar.msg b/library/msgs/es_ar.msg index 7d35027..7d35027 100644..100755 --- a/library/msgs/es_ar.msg +++ b/library/msgs/es_ar.msg diff --git a/library/msgs/es_bo.msg b/library/msgs/es_bo.msg index 498ad0d..498ad0d 100644..100755 --- a/library/msgs/es_bo.msg +++ b/library/msgs/es_bo.msg diff --git a/library/msgs/es_cl.msg b/library/msgs/es_cl.msg index 31d465c..31d465c 100644..100755 --- a/library/msgs/es_cl.msg +++ b/library/msgs/es_cl.msg diff --git a/library/msgs/es_co.msg b/library/msgs/es_co.msg index 77e57f0..77e57f0 100644..100755 --- a/library/msgs/es_co.msg +++ b/library/msgs/es_co.msg diff --git a/library/msgs/es_cr.msg b/library/msgs/es_cr.msg index 7a652fa..7a652fa 100644..100755 --- a/library/msgs/es_cr.msg +++ b/library/msgs/es_cr.msg diff --git a/library/msgs/es_do.msg b/library/msgs/es_do.msg index 0e283da..0e283da 100644..100755 --- a/library/msgs/es_do.msg +++ b/library/msgs/es_do.msg diff --git a/library/msgs/es_ec.msg b/library/msgs/es_ec.msg index 9e921e0..9e921e0 100644..100755 --- a/library/msgs/es_ec.msg +++ b/library/msgs/es_ec.msg diff --git a/library/msgs/es_gt.msg b/library/msgs/es_gt.msg index ecd6faf..ecd6faf 100644..100755 --- a/library/msgs/es_gt.msg +++ b/library/msgs/es_gt.msg diff --git a/library/msgs/es_hn.msg b/library/msgs/es_hn.msg index a758ca2..a758ca2 100644..100755 --- a/library/msgs/es_hn.msg +++ b/library/msgs/es_hn.msg diff --git a/library/msgs/es_mx.msg b/library/msgs/es_mx.msg index 7cfb545..7cfb545 100644..100755 --- a/library/msgs/es_mx.msg +++ b/library/msgs/es_mx.msg diff --git a/library/msgs/es_ni.msg b/library/msgs/es_ni.msg index 7c39495..7c39495 100644..100755 --- a/library/msgs/es_ni.msg +++ b/library/msgs/es_ni.msg diff --git a/library/msgs/es_pa.msg b/library/msgs/es_pa.msg index cecacdc..cecacdc 100644..100755 --- a/library/msgs/es_pa.msg +++ b/library/msgs/es_pa.msg diff --git a/library/msgs/es_pe.msg b/library/msgs/es_pe.msg index 9f90595..9f90595 100644..100755 --- a/library/msgs/es_pe.msg +++ b/library/msgs/es_pe.msg diff --git a/library/msgs/es_pr.msg b/library/msgs/es_pr.msg index 8511b12..8511b12 100644..100755 --- a/library/msgs/es_pr.msg +++ b/library/msgs/es_pr.msg diff --git a/library/msgs/es_py.msg b/library/msgs/es_py.msg index aa93d36..aa93d36 100644..100755 --- a/library/msgs/es_py.msg +++ b/library/msgs/es_py.msg diff --git a/library/msgs/es_sv.msg b/library/msgs/es_sv.msg index fc7954d..fc7954d 100644..100755 --- a/library/msgs/es_sv.msg +++ b/library/msgs/es_sv.msg diff --git a/library/msgs/es_uy.msg b/library/msgs/es_uy.msg index b33525c..b33525c 100644..100755 --- a/library/msgs/es_uy.msg +++ b/library/msgs/es_uy.msg diff --git a/library/msgs/es_ve.msg b/library/msgs/es_ve.msg index 7c2a7b0..7c2a7b0 100644..100755 --- a/library/msgs/es_ve.msg +++ b/library/msgs/es_ve.msg diff --git a/library/msgs/et.msg b/library/msgs/et.msg index 8d32e9e..8d32e9e 100644..100755 --- a/library/msgs/et.msg +++ b/library/msgs/et.msg diff --git a/library/msgs/eu.msg b/library/msgs/eu.msg index cf708b6..cf708b6 100644..100755 --- a/library/msgs/eu.msg +++ b/library/msgs/eu.msg diff --git a/library/msgs/eu_es.msg b/library/msgs/eu_es.msg index 2694418..2694418 100644..100755 --- a/library/msgs/eu_es.msg +++ b/library/msgs/eu_es.msg diff --git a/library/msgs/fa.msg b/library/msgs/fa.msg index 89b2f90..89b2f90 100644..100755 --- a/library/msgs/fa.msg +++ b/library/msgs/fa.msg diff --git a/library/msgs/fa_in.msg b/library/msgs/fa_in.msg index adc9e91..adc9e91 100644..100755 --- a/library/msgs/fa_in.msg +++ b/library/msgs/fa_in.msg diff --git a/library/msgs/fa_ir.msg b/library/msgs/fa_ir.msg index 597ce9d..597ce9d 100644..100755 --- a/library/msgs/fa_ir.msg +++ b/library/msgs/fa_ir.msg diff --git a/library/msgs/fi.msg b/library/msgs/fi.msg index acabba0..acabba0 100644..100755 --- a/library/msgs/fi.msg +++ b/library/msgs/fi.msg diff --git a/library/msgs/fo.msg b/library/msgs/fo.msg index 4696e62..4696e62 100644..100755 --- a/library/msgs/fo.msg +++ b/library/msgs/fo.msg diff --git a/library/msgs/fo_fo.msg b/library/msgs/fo_fo.msg index 2392b8e..2392b8e 100644..100755 --- a/library/msgs/fo_fo.msg +++ b/library/msgs/fo_fo.msg diff --git a/library/msgs/fr.msg b/library/msgs/fr.msg index 55b19bf..55b19bf 100644..100755 --- a/library/msgs/fr.msg +++ b/library/msgs/fr.msg diff --git a/library/msgs/fr_be.msg b/library/msgs/fr_be.msg index cdb13bd..cdb13bd 100644..100755 --- a/library/msgs/fr_be.msg +++ b/library/msgs/fr_be.msg diff --git a/library/msgs/fr_ca.msg b/library/msgs/fr_ca.msg index 00ccfff..00ccfff 100644..100755 --- a/library/msgs/fr_ca.msg +++ b/library/msgs/fr_ca.msg diff --git a/library/msgs/fr_ch.msg b/library/msgs/fr_ch.msg index 7e2bac7..7e2bac7 100644..100755 --- a/library/msgs/fr_ch.msg +++ b/library/msgs/fr_ch.msg diff --git a/library/msgs/ga.msg b/library/msgs/ga.msg index 6edf13a..6edf13a 100644..100755 --- a/library/msgs/ga.msg +++ b/library/msgs/ga.msg diff --git a/library/msgs/ga_ie.msg b/library/msgs/ga_ie.msg index b6acbbc..b6acbbc 100644..100755 --- a/library/msgs/ga_ie.msg +++ b/library/msgs/ga_ie.msg diff --git a/library/msgs/gl.msg b/library/msgs/gl.msg index 4b869e8..4b869e8 100644..100755 --- a/library/msgs/gl.msg +++ b/library/msgs/gl.msg diff --git a/library/msgs/gl_es.msg b/library/msgs/gl_es.msg index d4ed270..d4ed270 100644..100755 --- a/library/msgs/gl_es.msg +++ b/library/msgs/gl_es.msg diff --git a/library/msgs/gv.msg b/library/msgs/gv.msg index 7d332ad..7d332ad 100644..100755 --- a/library/msgs/gv.msg +++ b/library/msgs/gv.msg diff --git a/library/msgs/gv_gb.msg b/library/msgs/gv_gb.msg index 5e96e6f..5e96e6f 100644..100755 --- a/library/msgs/gv_gb.msg +++ b/library/msgs/gv_gb.msg diff --git a/library/msgs/he.msg b/library/msgs/he.msg index 4fd921d..4fd921d 100644..100755 --- a/library/msgs/he.msg +++ b/library/msgs/he.msg diff --git a/library/msgs/hi.msg b/library/msgs/hi.msg index 50c9fb8..50c9fb8 100644..100755 --- a/library/msgs/hi.msg +++ b/library/msgs/hi.msg diff --git a/library/msgs/hi_in.msg b/library/msgs/hi_in.msg index 239793f..239793f 100644..100755 --- a/library/msgs/hi_in.msg +++ b/library/msgs/hi_in.msg diff --git a/library/msgs/hr.msg b/library/msgs/hr.msg index cec145b..cec145b 100644..100755 --- a/library/msgs/hr.msg +++ b/library/msgs/hr.msg diff --git a/library/msgs/hu.msg b/library/msgs/hu.msg index e5e68d9..e5e68d9 100644..100755 --- a/library/msgs/hu.msg +++ b/library/msgs/hu.msg diff --git a/library/msgs/id.msg b/library/msgs/id.msg index 17c6bb5..17c6bb5 100644..100755 --- a/library/msgs/id.msg +++ b/library/msgs/id.msg diff --git a/library/msgs/id_id.msg b/library/msgs/id_id.msg index bb672c1..bb672c1 100644..100755 --- a/library/msgs/id_id.msg +++ b/library/msgs/id_id.msg diff --git a/library/msgs/is.msg b/library/msgs/is.msg index adc2d2a..adc2d2a 100644..100755 --- a/library/msgs/is.msg +++ b/library/msgs/is.msg diff --git a/library/msgs/it.msg b/library/msgs/it.msg index b641cde..b641cde 100644..100755 --- a/library/msgs/it.msg +++ b/library/msgs/it.msg diff --git a/library/msgs/it_ch.msg b/library/msgs/it_ch.msg index b36ed36..b36ed36 100644..100755 --- a/library/msgs/it_ch.msg +++ b/library/msgs/it_ch.msg diff --git a/library/msgs/ja.msg b/library/msgs/ja.msg index 2767665..2767665 100644..100755 --- a/library/msgs/ja.msg +++ b/library/msgs/ja.msg diff --git a/library/msgs/kl.msg b/library/msgs/kl.msg index d877bfe..d877bfe 100644..100755 --- a/library/msgs/kl.msg +++ b/library/msgs/kl.msg diff --git a/library/msgs/kl_gl.msg b/library/msgs/kl_gl.msg index 403aa10..403aa10 100644..100755 --- a/library/msgs/kl_gl.msg +++ b/library/msgs/kl_gl.msg diff --git a/library/msgs/ko.msg b/library/msgs/ko.msg index 0cd17a1..0cd17a1 100644..100755 --- a/library/msgs/ko.msg +++ b/library/msgs/ko.msg diff --git a/library/msgs/ko_kr.msg b/library/msgs/ko_kr.msg index ea5bbd7..ea5bbd7 100644..100755 --- a/library/msgs/ko_kr.msg +++ b/library/msgs/ko_kr.msg diff --git a/library/msgs/kok.msg b/library/msgs/kok.msg index 0869f20..0869f20 100644..100755 --- a/library/msgs/kok.msg +++ b/library/msgs/kok.msg diff --git a/library/msgs/kok_in.msg b/library/msgs/kok_in.msg index abcb1ff..abcb1ff 100644..100755 --- a/library/msgs/kok_in.msg +++ b/library/msgs/kok_in.msg diff --git a/library/msgs/kw.msg b/library/msgs/kw.msg index aaf79b3..aaf79b3 100644..100755 --- a/library/msgs/kw.msg +++ b/library/msgs/kw.msg diff --git a/library/msgs/kw_gb.msg b/library/msgs/kw_gb.msg index 2967680..2967680 100644..100755 --- a/library/msgs/kw_gb.msg +++ b/library/msgs/kw_gb.msg diff --git a/library/msgs/lt.msg b/library/msgs/lt.msg index 27b0985..27b0985 100644..100755 --- a/library/msgs/lt.msg +++ b/library/msgs/lt.msg diff --git a/library/msgs/lv.msg b/library/msgs/lv.msg index a037b15..a037b15 100644..100755 --- a/library/msgs/lv.msg +++ b/library/msgs/lv.msg diff --git a/library/msgs/mk.msg b/library/msgs/mk.msg index 41cf60d..41cf60d 100644..100755 --- a/library/msgs/mk.msg +++ b/library/msgs/mk.msg diff --git a/library/msgs/mr.msg b/library/msgs/mr.msg index cea427a..cea427a 100644..100755 --- a/library/msgs/mr.msg +++ b/library/msgs/mr.msg diff --git a/library/msgs/mr_in.msg b/library/msgs/mr_in.msg index 1889da5..1889da5 100644..100755 --- a/library/msgs/mr_in.msg +++ b/library/msgs/mr_in.msg diff --git a/library/msgs/ms.msg b/library/msgs/ms.msg index e954431..e954431 100644..100755 --- a/library/msgs/ms.msg +++ b/library/msgs/ms.msg diff --git a/library/msgs/ms_my.msg b/library/msgs/ms_my.msg index c1f93d4..c1f93d4 100644..100755 --- a/library/msgs/ms_my.msg +++ b/library/msgs/ms_my.msg diff --git a/library/msgs/mt.msg b/library/msgs/mt.msg index ddd5446..ddd5446 100644..100755 --- a/library/msgs/mt.msg +++ b/library/msgs/mt.msg diff --git a/library/msgs/nb.msg b/library/msgs/nb.msg index 90d49a3..90d49a3 100644..100755 --- a/library/msgs/nb.msg +++ b/library/msgs/nb.msg diff --git a/library/msgs/nl.msg b/library/msgs/nl.msg index 4c5c675..4c5c675 100644..100755 --- a/library/msgs/nl.msg +++ b/library/msgs/nl.msg diff --git a/library/msgs/nl_be.msg b/library/msgs/nl_be.msg index 4b19670..4b19670 100644..100755 --- a/library/msgs/nl_be.msg +++ b/library/msgs/nl_be.msg diff --git a/library/msgs/nn.msg b/library/msgs/nn.msg index bd61ac9..bd61ac9 100644..100755 --- a/library/msgs/nn.msg +++ b/library/msgs/nn.msg diff --git a/library/msgs/pl.msg b/library/msgs/pl.msg index d206f4b..d206f4b 100644..100755 --- a/library/msgs/pl.msg +++ b/library/msgs/pl.msg diff --git a/library/msgs/pt.msg b/library/msgs/pt.msg index 96fdb35..96fdb35 100644..100755 --- a/library/msgs/pt.msg +++ b/library/msgs/pt.msg diff --git a/library/msgs/pt_br.msg b/library/msgs/pt_br.msg index 8684327..8684327 100644..100755 --- a/library/msgs/pt_br.msg +++ b/library/msgs/pt_br.msg diff --git a/library/msgs/ro.msg b/library/msgs/ro.msg index bdd7c61..bdd7c61 100644..100755 --- a/library/msgs/ro.msg +++ b/library/msgs/ro.msg diff --git a/library/msgs/ru.msg b/library/msgs/ru.msg index 65b075d..65b075d 100644..100755 --- a/library/msgs/ru.msg +++ b/library/msgs/ru.msg diff --git a/library/msgs/ru_ua.msg b/library/msgs/ru_ua.msg index 6e1f8a8..6e1f8a8 100644..100755 --- a/library/msgs/ru_ua.msg +++ b/library/msgs/ru_ua.msg diff --git a/library/msgs/sh.msg b/library/msgs/sh.msg index 6ee0fc7..6ee0fc7 100644..100755 --- a/library/msgs/sh.msg +++ b/library/msgs/sh.msg diff --git a/library/msgs/sk.msg b/library/msgs/sk.msg index 9b2f0aa..9b2f0aa 100644..100755 --- a/library/msgs/sk.msg +++ b/library/msgs/sk.msg diff --git a/library/msgs/sl.msg b/library/msgs/sl.msg index 42bc509..42bc509 100644..100755 --- a/library/msgs/sl.msg +++ b/library/msgs/sl.msg diff --git a/library/msgs/sq.msg b/library/msgs/sq.msg index 8fb1fce..8fb1fce 100644..100755 --- a/library/msgs/sq.msg +++ b/library/msgs/sq.msg diff --git a/library/msgs/sr.msg b/library/msgs/sr.msg index 7576668..7576668 100644..100755 --- a/library/msgs/sr.msg +++ b/library/msgs/sr.msg diff --git a/library/msgs/sv.msg b/library/msgs/sv.msg index f7a67c6..f7a67c6 100644..100755 --- a/library/msgs/sv.msg +++ b/library/msgs/sv.msg diff --git a/library/msgs/sw.msg b/library/msgs/sw.msg index b888b43..b888b43 100644..100755 --- a/library/msgs/sw.msg +++ b/library/msgs/sw.msg diff --git a/library/msgs/ta.msg b/library/msgs/ta.msg index 4abb90c..4abb90c 100644..100755 --- a/library/msgs/ta.msg +++ b/library/msgs/ta.msg diff --git a/library/msgs/ta_in.msg b/library/msgs/ta_in.msg index 24590ac..24590ac 100644..100755 --- a/library/msgs/ta_in.msg +++ b/library/msgs/ta_in.msg diff --git a/library/msgs/te.msg b/library/msgs/te.msg index 6111473..6111473 100644..100755 --- a/library/msgs/te.msg +++ b/library/msgs/te.msg diff --git a/library/msgs/te_in.msg b/library/msgs/te_in.msg index 61638b5..61638b5 100644..100755 --- a/library/msgs/te_in.msg +++ b/library/msgs/te_in.msg diff --git a/library/msgs/th.msg b/library/msgs/th.msg index 7486c35..7486c35 100644..100755 --- a/library/msgs/th.msg +++ b/library/msgs/th.msg diff --git a/library/msgs/tr.msg b/library/msgs/tr.msg index 7b2ecf9..7b2ecf9 100644..100755 --- a/library/msgs/tr.msg +++ b/library/msgs/tr.msg diff --git a/library/msgs/uk.msg b/library/msgs/uk.msg index 7d4c64a..7d4c64a 100644..100755 --- a/library/msgs/uk.msg +++ b/library/msgs/uk.msg diff --git a/library/msgs/vi.msg b/library/msgs/vi.msg index c98b2a6..c98b2a6 100644..100755 --- a/library/msgs/vi.msg +++ b/library/msgs/vi.msg diff --git a/library/msgs/zh.msg b/library/msgs/zh.msg index b799a32..b799a32 100644..100755 --- a/library/msgs/zh.msg +++ b/library/msgs/zh.msg diff --git a/library/msgs/zh_cn.msg b/library/msgs/zh_cn.msg index d62ce77..d62ce77 100644..100755 --- a/library/msgs/zh_cn.msg +++ b/library/msgs/zh_cn.msg diff --git a/library/msgs/zh_hk.msg b/library/msgs/zh_hk.msg index badb1dd..badb1dd 100644..100755 --- a/library/msgs/zh_hk.msg +++ b/library/msgs/zh_hk.msg diff --git a/library/msgs/zh_sg.msg b/library/msgs/zh_sg.msg index a2f3e39..a2f3e39 100644..100755 --- a/library/msgs/zh_sg.msg +++ b/library/msgs/zh_sg.msg diff --git a/library/msgs/zh_tw.msg b/library/msgs/zh_tw.msg index e0796b1..e0796b1 100644..100755 --- a/library/msgs/zh_tw.msg +++ b/library/msgs/zh_tw.msg diff --git a/library/tzdata/Africa/Asmara b/library/tzdata/Africa/Asmara index 1f0f13e..1f0f13e 100644..100755 --- a/library/tzdata/Africa/Asmara +++ b/library/tzdata/Africa/Asmara diff --git a/library/tzdata/America/Atikokan b/library/tzdata/America/Atikokan index e72b04f..e72b04f 100644..100755 --- a/library/tzdata/America/Atikokan +++ b/library/tzdata/America/Atikokan diff --git a/library/tzdata/America/Blanc-Sablon b/library/tzdata/America/Blanc-Sablon index d5485e8..d5485e8 100644..100755 --- a/library/tzdata/America/Blanc-Sablon +++ b/library/tzdata/America/Blanc-Sablon diff --git a/library/tzdata/America/Indiana/Petersburg b/library/tzdata/America/Indiana/Petersburg index 6992bfc..6992bfc 100644..100755 --- a/library/tzdata/America/Indiana/Petersburg +++ b/library/tzdata/America/Indiana/Petersburg diff --git a/library/tzdata/America/Indiana/Tell_City b/library/tzdata/America/Indiana/Tell_City index 9eebcf7..9eebcf7 100644..100755 --- a/library/tzdata/America/Indiana/Tell_City +++ b/library/tzdata/America/Indiana/Tell_City diff --git a/library/tzdata/America/Indiana/Vincennes b/library/tzdata/America/Indiana/Vincennes index 1af7fc9..1af7fc9 100644..100755 --- a/library/tzdata/America/Indiana/Vincennes +++ b/library/tzdata/America/Indiana/Vincennes diff --git a/library/tzdata/America/Indiana/Winamac b/library/tzdata/America/Indiana/Winamac index fb6cd37..fb6cd37 100644..100755 --- a/library/tzdata/America/Indiana/Winamac +++ b/library/tzdata/America/Indiana/Winamac diff --git a/library/tzdata/America/Moncton b/library/tzdata/America/Moncton index d286c88..d286c88 100644..100755 --- a/library/tzdata/America/Moncton +++ b/library/tzdata/America/Moncton diff --git a/library/tzdata/America/North_Dakota/New_Salem b/library/tzdata/America/North_Dakota/New_Salem index 5a9d229..5a9d229 100644..100755 --- a/library/tzdata/America/North_Dakota/New_Salem +++ b/library/tzdata/America/North_Dakota/New_Salem diff --git a/library/tzdata/America/Resolute b/library/tzdata/America/Resolute index b4c0bab..b4c0bab 100644..100755 --- a/library/tzdata/America/Resolute +++ b/library/tzdata/America/Resolute diff --git a/library/tzdata/Atlantic/Faroe b/library/tzdata/Atlantic/Faroe index d2c314a..d2c314a 100644..100755 --- a/library/tzdata/Atlantic/Faroe +++ b/library/tzdata/Atlantic/Faroe diff --git a/library/tzdata/Australia/Eucla b/library/tzdata/Australia/Eucla index 0f8ed4d..0f8ed4d 100644..100755 --- a/library/tzdata/Australia/Eucla +++ b/library/tzdata/Australia/Eucla diff --git a/library/tzdata/Europe/Guernsey b/library/tzdata/Europe/Guernsey index 4372c64..4372c64 100644..100755 --- a/library/tzdata/Europe/Guernsey +++ b/library/tzdata/Europe/Guernsey diff --git a/library/tzdata/Europe/Isle_of_Man b/library/tzdata/Europe/Isle_of_Man index 870ac45..870ac45 100644..100755 --- a/library/tzdata/Europe/Isle_of_Man +++ b/library/tzdata/Europe/Isle_of_Man diff --git a/library/tzdata/Europe/Jersey b/library/tzdata/Europe/Jersey index e4da512..e4da512 100644..100755 --- a/library/tzdata/Europe/Jersey +++ b/library/tzdata/Europe/Jersey diff --git a/library/tzdata/Europe/Podgorica b/library/tzdata/Europe/Podgorica index f4f9066..f4f9066 100644..100755 --- a/library/tzdata/Europe/Podgorica +++ b/library/tzdata/Europe/Podgorica diff --git a/library/tzdata/Europe/Volgograd b/library/tzdata/Europe/Volgograd index c3f148f..c3f148f 100644..100755 --- a/library/tzdata/Europe/Volgograd +++ b/library/tzdata/Europe/Volgograd diff --git a/tests/http.test b/tests/http.test index a0a26de..6569443 100644 --- a/tests/http.test +++ b/tests/http.test @@ -79,7 +79,7 @@ if {[catch {package present Thread}] == 0 && [file exists $httpdFile]} { test http-1.1 {http::config} { http::config -useragent UserAgent http::config -} [list -accept */* -proxyfilter http::ProxyRequired -proxyhost {} -proxyport {} -urlencoding utf-8 -useragent "UserAgent"] +} [list -accept */* -cookiejar {} -proxyfilter http::ProxyRequired -proxyhost {} -proxyport {} -urlencoding utf-8 -useragent "UserAgent"] test http-1.2 {http::config} { http::config -proxyfilter } http::ProxyRequired @@ -94,10 +94,10 @@ test http-1.4 {http::config} { set x [http::config] http::config {*}$savedconf set x -} {-accept */* -proxyfilter myFilter -proxyhost nowhere.come -proxyport 8080 -urlencoding iso8859-1 -useragent {Tcl Test Suite}} +} {-accept */* -cookiejar {} -proxyfilter myFilter -proxyhost nowhere.come -proxyport 8080 -urlencoding iso8859-1 -useragent {Tcl Test Suite}} test http-1.5 {http::config} -returnCodes error -body { http::config -proxyhost {} -junk 8080 -} -result {Unknown option -junk, must be: -accept, -proxyfilter, -proxyhost, -proxyport, -urlencoding, -useragent} +} -result {Unknown option -junk, must be: -accept, -cookiejar, -proxyfilter, -proxyhost, -proxyport, -urlencoding, -useragent} test http-1.6 {http::config} -setup { set oldenc [http::config -urlencoding] } -body { @@ -631,6 +631,451 @@ test http-7.4 {http::formatQuery} -setup { http::config -urlencoding $enc } -result {%3F} +package require -exact tcl::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 ...?"} +test http-idna-1.2 {IDNA package: basics} -returnCodes error -body { + ::tcl::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 +} -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"} +test http-idna-1.5 {IDNA package: basics} -returnCodes error -body { + ::tcl::idna puny +} -result {wrong # args: should be "::tcl::idna puny subcommand ?arg ...?"} +test http-idna-1.6 {IDNA package: basics} -returnCodes error -body { + ::tcl::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?"} +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?"} +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?"} +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?"} +test http-idna-1.11 {IDNA package: basics} -returnCodes error -body { + ::tcl::idna decode +} -result {wrong # args: should be "::tcl::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"} + +test http-idna-2.1 {puny encode: functional test} { + ::tcl::idna puny encode abc +} abc- +test http-idna-2.2 {puny encode: functional test} { + ::tcl::idna puny encode a\u20acb\u20acc +} abc-k50ab +test http-idna-2.3 {puny encode: functional test} { + ::tcl::idna puny encode ABC +} ABC- +test http-idna-2.4 {puny encode: functional test} { + ::tcl::idna puny encode A\u20ACB\u20ACC +} ABC-k50ab +test http-idna-2.5 {puny encode: functional test} { + ::tcl::idna puny encode ABC 0 +} abc- +test http-idna-2.6 {puny encode: functional test} { + ::tcl::idna puny encode A\u20ACB\u20ACC 0 +} abc-k50ab +test http-idna-2.7 {puny encode: functional test} { + ::tcl::idna puny encode ABC 1 +} ABC- +test http-idna-2.8 {puny encode: functional test} { + ::tcl::idna puny encode A\u20ACB\u20ACC 1 +} ABC-k50ab +test http-idna-2.9 {puny encode: functional test} { + ::tcl::idna puny encode abc 0 +} abc- +test http-idna-2.10 {puny encode: functional test} { + ::tcl::idna puny encode a\u20ACb\u20ACc 0 +} abc-k50ab +test http-idna-2.11 {puny encode: functional test} { + ::tcl::idna puny encode abc 1 +} ABC- +test http-idna-2.12 {puny encode: functional test} { + ::tcl::idna puny encode a\u20ACb\u20ACc 1 +} ABC-k50ab +test http-idna-2.13 {puny encode: edge cases} { + ::tcl::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} { + 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} { + 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} { + 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} { + 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} { + 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} { + 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 + u+0939 u+0948 u+0902 + }]] ""] +} i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd +test http-idna-2.14-G {puny encode: examples from RFC 3492} { + ::tcl::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} { + 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} { + 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 + u+0438 + }]] ""] +} b1abfaaepdrnnbgefbadotcwatmq2g4l +test http-idna-2.14-J {puny encode: examples from RFC 3492} { + ::tcl::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 + u+0062 u+006C u+0061 u+0072 u+0065 u+006E u+0045 u+0073 u+0070 + u+0061 u+00F1 u+006F u+006C + }]] ""] +} PorqunopuedensimplementehablarenEspaol-fmd56a +test http-idna-2.14-K {puny encode: examples from RFC 3492} { + ::tcl::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 + u+0056 u+0069 u+1EC7 u+0074 + }]] ""] +} TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g +test http-idna-2.14-L {puny encode: examples from RFC 3492} { + ::tcl::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} { + 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} { + 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} { + 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} { + 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} { + 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} { + 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 <-} +} {-> $1.00 <--} + +test http-idna-3.1 {puny decode: functional test} { + ::tcl::idna puny decode abc- +} abc +test http-idna-3.2 {puny decode: functional test} { + ::tcl::idna puny decode abc-k50ab +} a\u20acb\u20acc +test http-idna-3.3 {puny decode: functional test} { + ::tcl::idna puny decode ABC- +} ABC +test http-idna-3.4 {puny decode: functional test} { + ::tcl::idna puny decode ABC-k50ab +} A\u20ACB\u20ACC +test http-idna-3.5 {puny decode: functional test} { + ::tcl::idna puny decode ABC-K50AB +} A\u20ACB\u20ACC +test http-idna-3.6 {puny decode: functional test} { + ::tcl::idna puny decode abc-K50AB +} a\u20ACb\u20ACc +test http-idna-3.7 {puny decode: functional test} { + ::tcl::idna puny decode ABC- 0 +} abc +test http-idna-3.8 {puny decode: functional test} { + ::tcl::idna puny decode ABC-K50AB 0 +} a\u20ACb\u20ACc +test http-idna-3.9 {puny decode: functional test} { + ::tcl::idna puny decode ABC- 1 +} ABC +test http-idna-3.10 {puny decode: functional test} { + ::tcl::idna puny decode ABC-K50AB 1 +} A\u20ACB\u20ACC +test http-idna-3.11 {puny decode: functional test} { + ::tcl::idna puny decode abc- 0 +} abc +test http-idna-3.12 {puny decode: functional test} { + ::tcl::idna puny decode abc-k50ab 0 +} a\u20ACb\u20ACc +test http-idna-3.13 {puny decode: functional test} { + ::tcl::idna puny decode abc- 1 +} ABC +test http-idna-3.14 {puny decode: functional test} { + ::tcl::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]] +} c282c281c280 +test http-idna-3.16 {puny decode: edge cases and errors} -returnCodes error -body { + ::tcl::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 + dict get $opt -errorcode +} {PUNYCODE BAD_INPUT CHAR} +test http-idna-3.18 {puny decode: edge cases and errors} { + ::tcl::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] +} [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] +} {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] +} {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] +} [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] +} [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 \ + i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd] +} [list {*}{ + 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 + u+0939 u+0948 u+0902 +}] +test http-idna-3.19-G {puny decode: examples from RFC 3492} { + hexify [::tcl::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 \ + 989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c] +} [list {*}{ + 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 +}] +test http-idna-3.19-I {puny decode: examples from RFC 3492} { + hexify [::tcl::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 + u+044F u+0442 u+043F u+043E u+0440 u+0443 u+0441 u+0441 u+043A + u+0438 +}] +test http-idna-3.19-J {puny decode: examples from RFC 3492} { + hexify [::tcl::idna puny decode \ + PorqunopuedensimplementehablarenEspaol-fmd56a] +} [list {*}{ + 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 + u+0062 u+006C u+0061 u+0072 u+0065 u+006E u+0045 u+0073 u+0070 + 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 \ + TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g] +} [list {*}{ + 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 + 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] +} {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] +} [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] +} [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] +} {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] +} [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] +} {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] +} {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 <--} +} {-> $1.00 <-} +rename hexify "" + +test http-idna-4.1 {IDNA encoding} { + ::tcl::idna encode abc.def +} abc.def +test http-idna-4.2 {IDNA encoding} { + ::tcl::idna encode a\u20acb\u20acc.def +} xn--abc-k50ab.def +test http-idna-4.3 {IDNA encoding} { + ::tcl::idna encode def.a\u20acb\u20acc +} def.xn--abc-k50ab +test http-idna-4.4 {IDNA encoding} { + ::tcl::idna encode ABC.DEF +} ABC.DEF +test http-idna-4.5 {IDNA encoding} { + ::tcl::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 +} abc..def +test http-idna-4.7 {IDNA encoding: invalid char} -returnCodes error -body { + ::tcl::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 + dict get $opt -errorcode +} {IDNA INVALID_NAME_CHARACTER {$}} +test http-idna-4.8 {IDNA encoding: empty} { + ::tcl::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 + 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 +}]] ""].com +test http-idna-4.9 {IDNA encoding: max lengths from RFC 5890} -body { + ::tcl::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 + 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 +} xn--pass-epa.example.com + +test http-idna-5.1 {IDNA decoding} { + ::tcl::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 +} abc.def +test http-idna-5.3 {IDNA decoding} { + # Invalid entry that's just a wrapper + ::tcl::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- +} abc.def +test http-idna-5.5 {IDNA decoding: error cases} -returnCodes error -body { + ::tcl::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 + 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 +} -result {exceeded input data} +test http-idna-5.6.1 {IDNA decoding: error cases} { + catch {::tcl::idna decode xn--a-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.def} -> opt + dict get $opt -errorcode +} {PUNYCODE BAD_INPUT LENGTH} + # cleanup catch {unset url} catch {unset badurl} diff --git a/tests/httpcookie.test b/tests/httpcookie.test new file mode 100644 index 0000000..204c263 --- /dev/null +++ b/tests/httpcookie.test @@ -0,0 +1,853 @@ +# Commands covered: http::cookiejar +# +# This file contains a collection of tests for the cookiejar package. +# Sourcing this file into Tcl runs the tests and generates output for errors. +# No output means no errors were found. +# +# Copyright (c) 2014 Donal K. Fellows. +# +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. + +package require tcltest 2 +namespace import -force ::tcltest::* + +testConstraint cookiejar [expr {![catch { + package require cookiejar +}]}] + +test http-cookiejar-1.1 {cookie storage: packaging} cookiejar { + package require cookiejar +} 0.1 +test http-cookiejar-1.2 {cookie storage: packaging} cookiejar { + package require cookiejar + package require cookiejar +} 0.1 + +test http-cookiejar-2.1 {cookie storage: basics} -constraints cookiejar -body { + http::cookiejar +} -returnCodes error -result {wrong # args: should be "http::cookiejar method ?arg ...?"} +test http-cookiejar-2.2 {cookie storage: basics} -constraints cookiejar -body { + http::cookiejar ? +} -returnCodes error -result {unknown method "?": must be configure, create, destroy or new} +test http-cookiejar-2.3 {cookie storage: basics} cookiejar { + http::cookiejar configure +} {-domainfile -domainlist -domainrefresh -loglevel -offline -purgeold -retain -vacuumtrigger} +test http-cookiejar-2.4 {cookie storage: basics} -constraints cookiejar -body { + http::cookiejar configure a b c d e +} -returnCodes error -result {wrong # args: should be "http::cookiejar configure ?optionName? ?optionValue?"} +test http-cookiejar-2.5 {cookie storage: basics} -constraints cookiejar -body { + http::cookiejar configure a +} -returnCodes error -result {bad option "a": must be -domainfile, -domainlist, -domainrefresh, -loglevel, -offline, -purgeold, -retain, or -vacuumtrigger} +test http-cookiejar-2.6 {cookie storage: basics} -constraints cookiejar -body { + http::cookiejar configure -d +} -returnCodes error -result {ambiguous option "-d": must be -domainfile, -domainlist, -domainrefresh, -loglevel, -offline, -purgeold, -retain, or -vacuumtrigger} +test http-cookiejar-2.7 {cookie storage: basics} -setup { + set old [http::cookiejar configure -loglevel] +} -constraints cookiejar -body { + list [http::cookiejar configure -loglevel] \ + [http::cookiejar configure -loglevel debug] \ + [http::cookiejar configure -loglevel] \ + [http::cookiejar configure -loglevel error] \ + [http::cookiejar configure -loglevel] +} -cleanup { + http::cookiejar configure -loglevel $old +} -result {info debug debug error error} +test http-cookiejar-2.8 {cookie storage: basics} -setup { + set old [http::cookiejar configure -loglevel] +} -constraints cookiejar -body { + list [http::cookiejar configure -loglevel] \ + [http::cookiejar configure -loglevel d] \ + [http::cookiejar configure -loglevel i] \ + [http::cookiejar configure -loglevel w] \ + [http::cookiejar configure -loglevel e] +} -cleanup { + http::cookiejar configure -loglevel $old +} -result {info debug info warn error} +test http-cookiejar-2.9 {cookie storage: basics} -constraints cookiejar -body { + http::cookiejar configure -off +} -match glob -result * +test http-cookiejar-2.10 {cookie storage: basics} -setup { + set oldval [http::cookiejar configure -offline] +} -constraints cookiejar -body { + http::cookiejar configure -offline true +} -cleanup { + catch {http::cookiejar configure -offline $oldval} +} -result 1 +test http-cookiejar-2.11 {cookie storage: basics} -setup { + set oldval [http::cookiejar configure -offline] +} -constraints cookiejar -body { + http::cookiejar configure -offline nonbool +} -cleanup { + catch {http::cookiejar configure -offline $oldval} +} -returnCodes error -result {expected boolean value but got "nonbool"} +test http-cookiejar-2.12 {cookie storage: basics} -setup { + set oldval [http::cookiejar configure -purgeold] +} -constraints cookiejar -body { + http::cookiejar configure -purge nonint +} -cleanup { + catch {http::cookiejar configure -purgeold $oldval} +} -returnCodes error -result {expected positive integer but got "nonint"} +test http-cookiejar-2.13 {cookie storage: basics} -setup { + set oldval [http::cookiejar configure -domainrefresh] +} -constraints cookiejar -body { + http::cookiejar configure -domainref nonint +} -cleanup { + catch {http::cookiejar configure -domainrefresh $oldval} +} -returnCodes error -result {expected positive integer but got "nonint"} +test http-cookiejar-2.14 {cookie storage: basics} -setup { + set oldval [http::cookiejar configure -domainrefresh] +} -constraints cookiejar -body { + http::cookiejar configure -domainref -42 +} -cleanup { + catch {http::cookiejar configure -domainrefresh $oldval} +} -returnCodes error -result {expected positive integer but got "-42"} +test http-cookiejar-2.15 {cookie storage: basics} -setup { + set oldval [http::cookiejar configure -domainrefresh] + set result unset + set tracer [http::cookiejar create tracer] +} -constraints cookiejar -body { + oo::objdefine $tracer method PostponeRefresh {} { + set ::result set + next + } + http::cookiejar configure -domainref 12345 + return $result +} -cleanup { + $tracer destroy + catch {http::cookiejar configure -domainrefresh $oldval} +} -result set + +test http-cookiejar-3.1 {cookie storage: class} cookiejar { + info object isa object http::cookiejar +} 1 +test http-cookiejar-3.2 {cookie storage: class} cookiejar { + info object isa class http::cookiejar +} 1 +test http-cookiejar-3.3 {cookie storage: class} cookiejar { + lsort [info object methods http::cookiejar] +} {configure} +test http-cookiejar-3.4 {cookie storage: class} cookiejar { + lsort [info object methods http::cookiejar -all] +} {configure create destroy new} +test http-cookiejar-3.5 {cookie storage: class} -setup { + catch {rename ::cookiejar ""} +} -constraints cookiejar -body { + namespace eval :: {http::cookiejar create cookiejar} +} -cleanup { + catch {rename ::cookiejar ""} +} -result ::cookiejar +test http-cookiejar-3.6 {cookie storage: class} -setup { + catch {rename ::cookiejar ""} +} -constraints cookiejar -body { + list [http::cookiejar create ::cookiejar] [info commands ::cookiejar] \ + [::cookiejar destroy] [info commands ::cookiejar] +} -cleanup { + catch {rename ::cookiejar ""} +} -result {::cookiejar ::cookiejar {} {}} +test http-cookiejar-3.7 {cookie storage: class} -setup { + catch {rename ::cookiejar ""} +} -constraints cookiejar -body { + http::cookiejar create ::cookiejar foo bar +} -returnCodes error -cleanup { + catch {rename ::cookiejar ""} +} -result {wrong # args: should be "http::cookiejar create ::cookiejar ?path?"} +test http-cookiejar-3.8 {cookie storage: class} -setup { + catch {rename ::cookiejar ""} + set f [makeFile "" cookiejar] + file delete $f +} -constraints cookiejar -body { + http::cookiejar create ::cookiejar $f +} -cleanup { + catch {rename ::cookiejar ""} + removeFile $f +} -result ::cookiejar +test http-cookiejar-3.9 {cookie storage: class} -setup { + catch {rename ::cookiejar ""} + set f [makeFile "bogus content for a database" cookiejar] +} -constraints cookiejar -body { + http::cookiejar create ::cookiejar $f +} -returnCodes error -cleanup { + catch {rename ::cookiejar ""} + removeFile $f +} -result {file is encrypted or is not a database} +test http-cookiejar-3.10 {cookie storage: class} -setup { + catch {rename ::cookiejar ""} + set dir [makeDirectory cookiejar] +} -constraints cookiejar -body { + http::cookiejar create ::cookiejar $dir +} -returnCodes error -cleanup { + catch {rename ::cookiejar ""} + removeDirectory $dir +} -result {unable to open database file} + +test http-cookiejar-4.1 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar +} -constraints cookiejar -body { + cookiejar +} -returnCodes error -cleanup { + ::cookiejar destroy +} -result {wrong # args: should be "cookiejar method ?arg ...?"} +test http-cookiejar-4.2 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar +} -constraints cookiejar -body { + cookiejar ? +} -returnCodes error -cleanup { + ::cookiejar destroy +} -result {unknown method "?": must be destroy, forceLoadDomainData, getCookies, lookup or storeCookie} +test http-cookiejar-4.3 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar +} -constraints cookiejar -body { + lsort [info object methods cookiejar -all] +} -cleanup { + ::cookiejar destroy +} -result {destroy forceLoadDomainData getCookies lookup storeCookie} +test http-cookiejar-4.4 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar +} -constraints cookiejar -body { + cookiejar getCookies +} -returnCodes error -cleanup { + ::cookiejar destroy +} -result {wrong # args: should be "cookiejar getCookies proto host path"} +test http-cookiejar-4.5 {cookie storage} -setup { + http::cookiejar create ::cookiejar +} -constraints cookiejar -body { + cookiejar getCookies http www.example.com / +} -cleanup { + ::cookiejar destroy +} -result {} +test http-cookiejar-4.6 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar +} -constraints cookiejar -body { + cookiejar storeCookie +} -returnCodes error -cleanup { + ::cookiejar destroy +} -result {wrong # args: should be "cookiejar storeCookie options"} +test http-cookiejar-4.7 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } +} -cleanup { + ::cookiejar destroy +} -result {} +test http-cookiejar-4.8 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + oo::objdefine ::cookiejar export Database +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + # Poke inside implementation! + cookiejar Database eval {SELECT count(*) FROM sessionCookies} +} -cleanup { + ::cookiejar destroy +} -result 1 +test http-cookiejar-4.9 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + oo::objdefine ::cookiejar export Database +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + # Poke inside implementation! + cookiejar Database eval {SELECT count(*) FROM persistentCookies} +} -cleanup { + ::cookiejar destroy +} -result 0 +test http-cookiejar-4.10 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar +} -constraints cookiejar -body { + cookiejar storeCookie [dict replace { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } expires [expr {[clock seconds]+5}]] +} -cleanup { + ::cookiejar destroy +} -result {} +test http-cookiejar-4.11 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + oo::objdefine ::cookiejar export Database +} -constraints cookiejar -body { + cookiejar storeCookie [dict replace { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } expires [expr {[clock seconds]+5}]] + # Poke inside implementation! + cookiejar Database eval {SELECT count(*) FROM sessionCookies} +} -cleanup { + ::cookiejar destroy +} -result 0 +test http-cookiejar-4.12 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + oo::objdefine ::cookiejar export Database +} -constraints cookiejar -body { + cookiejar storeCookie [dict replace { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } expires [expr {[clock seconds]+5}]] + # Poke inside implementation! + cookiejar Database eval {SELECT count(*) FROM persistentCookies} +} -cleanup { + ::cookiejar destroy +} -result 1 +test http-cookiejar-4.13 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + lappend result [cookiejar getCookies http www.example.com /] + cookiejar storeCookie { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + lappend result [cookiejar getCookies http www.example.com /] +} -cleanup { + ::cookiejar destroy +} -result {{} {foo bar}} +test http-cookiejar-4.14 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + lappend result [cookiejar getCookies http www.example.com /] + cookiejar storeCookie [dict replace { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } expires [expr {[clock seconds]+5}]] + lappend result [cookiejar getCookies http www.example.com /] +} -cleanup { + ::cookiejar destroy +} -result {{} {foo bar}} +test http-cookiejar-4.15 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + lappend result [cookiejar getCookies http www.example.com /] + cookiejar storeCookie { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie [dict replace { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } expires [expr {[clock seconds]+5}]] + lappend result [cookiejar getCookies http www.example.com /] +} -cleanup { + ::cookiejar destroy +} -result {{} {foo bar}} +test http-cookiejar-4.16 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + lappend result [cookiejar getCookies http www.example.com /] + cookiejar storeCookie { + key foo1 + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie [dict replace { + key foo2 + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } expires [expr {[clock seconds]+5}]] + lappend result [lsort -stride 2 [cookiejar getCookies http www.example.com /]] +} -cleanup { + ::cookiejar destroy +} -result {{} {foo1 bar foo2 bar}} +test http-cookiejar-4.17 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar +} -constraints cookiejar -body { + cookiejar lookup a b c d +} -returnCodes error -cleanup { + ::cookiejar destroy +} -result {wrong # args: should be "cookiejar lookup ?host? ?key?"} +test http-cookiejar-4.18 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + lappend result [cookiejar lookup] + lappend result [cookiejar lookup www.example.com] + lappend result [catch {cookiejar lookup www.example.com foo} value] $value + cookiejar storeCookie { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + lappend result [cookiejar lookup] + lappend result [cookiejar lookup www.example.com] + lappend result [cookiejar lookup www.example.com foo] +} -cleanup { + ::cookiejar destroy +} -result {{} {} 1 {no such key for that host} www.example.com foo bar} +test http-cookiejar-4.19 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo + value bar + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie { + key bar + value foo + secure 0 + domain www.example.org + origin www.example.org + path / + hostonly 1 + } + lappend result [lsort [cookiejar lookup]] + lappend result [cookiejar lookup www.example.com] + lappend result [cookiejar lookup www.example.com foo] + lappend result [cookiejar lookup www.example.org] + lappend result [cookiejar lookup www.example.org bar] +} -cleanup { + ::cookiejar destroy +} -result {{www.example.com www.example.org} foo bar bar foo} +test http-cookiejar-4.20 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo1 + value bar1 + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie [dict replace { + key foo2 + value bar2 + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } expires [expr {[clock seconds]+5}]] + lappend result [cookiejar lookup] + lappend result [lsort [cookiejar lookup www.example.com]] + lappend result [cookiejar lookup www.example.com foo1] + lappend result [cookiejar lookup www.example.com foo2] +} -cleanup { + ::cookiejar destroy +} -result {www.example.com {foo1 foo2} bar1 bar2} +test http-cookiejar-4.21 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo1 + value bar1 + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie { + key foo2 + value bar2 + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + lappend result [cookiejar lookup] + lappend result [lsort [cookiejar lookup www.example.com]] + lappend result [cookiejar lookup www.example.com foo1] + lappend result [cookiejar lookup www.example.com foo2] +} -cleanup { + ::cookiejar destroy +} -result {www.example.com {foo1 foo2} bar1 bar2} +test http-cookiejar-4.22 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + cookiejar forceLoadDomainData x y z +} -returnCodes error -cleanup { + ::cookiejar destroy +} -result {wrong # args: should be "cookiejar forceLoadDomainData"} +test http-cookiejar-4.23 {cookie storage: instance} -setup { + http::cookiejar create ::cookiejar + set result {} +} -constraints cookiejar -body { + cookiejar forceLoadDomainData +} -cleanup { + ::cookiejar destroy +} -result {} +test http-cookiejar-4.23.a {cookie storage: instance} -setup { + set off [http::cookiejar configure -offline] +} -constraints cookiejar -body { + http::cookiejar configure -offline 1 + [http::cookiejar create ::cookiejar] destroy +} -cleanup { + catch {::cookiejar destroy} + http::cookiejar configure -offline $off +} -result {} +test http-cookiejar-4.23.b {cookie storage: instance} -setup { + set off [http::cookiejar configure -offline] +} -constraints cookiejar -body { + http::cookiejar configure -offline 0 + [http::cookiejar create ::cookiejar] destroy +} -cleanup { + catch {::cookiejar destroy} + http::cookiejar configure -offline $off +} -result {} + +test http-cookiejar-5.1 {cookie storage: constraints} -setup { + http::cookiejar create ::cookiejar + cookiejar forceLoadDomainData +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo + value bar + secure 0 + domain com + origin com + path / + hostonly 1 + } + cookiejar lookup +} -cleanup { + ::cookiejar destroy +} -result {} +test http-cookiejar-5.2 {cookie storage: constraints} -setup { + http::cookiejar create ::cookiejar + cookiejar forceLoadDomainData +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo + value bar + secure 0 + domain foo.example.com + origin bar.example.org + path / + hostonly 1 + } + cookiejar lookup +} -cleanup { + ::cookiejar destroy +} -result {} +test http-cookiejar-5.3 {cookie storage: constraints} -setup { + http::cookiejar create ::cookiejar + cookiejar forceLoadDomainData +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo1 + value bar + secure 0 + domain com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie { + key foo2 + value bar + secure 0 + domain example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar lookup +} -cleanup { + ::cookiejar destroy +} -result {example.com} +test http-cookiejar-5.4 {cookie storage: constraints} -setup { + http::cookiejar create ::cookiejar + cookiejar forceLoadDomainData +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo + value bar1 + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie { + key foo + value bar2 + secure 0 + domain example.com + origin www.example.com + path / + hostonly 1 + } + lsort [cookiejar lookup] +} -cleanup { + ::cookiejar destroy +} -result {example.com www.example.com} +test http-cookiejar-5.5 {cookie storage: constraints} -setup { + http::cookiejar create ::cookiejar + cookiejar forceLoadDomainData +} -constraints cookiejar -body { + cookiejar storeCookie { + key foo1 + value 1 + secure 0 + domain com + origin www.example.com + path / + hostonly 0 + } + cookiejar storeCookie { + key foo2 + value 2 + secure 0 + domain com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie { + key foo3 + value 3 + secure 0 + domain example.com + origin www.example.com + path / + hostonly 0 + } + cookiejar storeCookie { + key foo4 + value 4 + secure 0 + domain example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie { + key foo5 + value 5 + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 0 + } + cookiejar storeCookie { + key foo6 + value 6 + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie { + key foo7 + value 7 + secure 1 + domain www.example.com + origin www.example.com + path / + hostonly 0 + } + cookiejar storeCookie { + key foo8 + value 8 + secure 1 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + cookiejar storeCookie { + key foo9 + value 9 + secure 0 + domain sub.www.example.com + origin www.example.com + path / + hostonly 1 + } + list [cookiejar getCookies http www.example.com /] \ + [cookiejar getCookies http www2.example.com /] \ + [cookiejar getCookies https www.example.com /] \ + [cookiejar getCookies http sub.www.example.com /] +} -cleanup { + ::cookiejar destroy +} -result {{foo3 3 foo6 6} {foo3 3} {foo3 3 foo6 6 foo8 8} {foo3 3 foo5 5}} + +test http-cookiejar-6.1 {cookie storage: expiry and lookup} -setup { + http::cookiejar create ::cookiejar + oo::objdefine cookiejar export PurgeCookies + set result {} + proc values cookies { + global result + lappend result [lsort [lmap {k v} $cookies {set v}]] + } +} -constraints cookiejar -body { + values [cookiejar getCookies http www.example.com /] + cookiejar storeCookie { + key foo + value session + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } + values [cookiejar getCookies http www.example.com /] + cookiejar storeCookie [dict replace { + key foo + value cookie + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } expires [expr {[clock seconds]+1}]] + values [cookiejar getCookies http www.example.com /] + cookiejar storeCookie { + key foo + value session-global + secure 0 + domain example.com + origin www.example.com + path / + hostonly 0 + } + values [cookiejar getCookies http www.example.com /] + after 2500 + update + values [cookiejar getCookies http www.example.com /] + cookiejar PurgeCookies + values [cookiejar getCookies http www.example.com /] + cookiejar storeCookie { + key foo + value go-away + secure 0 + domain example.com + origin www.example.com + path / + hostonly 0 + expires 0 + } + values [cookiejar getCookies http www.example.com /] +} -cleanup { + ::cookiejar destroy +} -result {{} session cookie {cookie session-global} {cookie session-global} session-global {}} + +test http-cookiejar-7.1 {cookie storage: persistence of persistent cookies} -setup { + catch {rename ::cookiejar ""} + set f [makeFile "" cookiejar] + file delete $f +} -constraints cookiejar -body { + http::cookiejar create ::cookiejar $f + ::cookiejar destroy + http::cookiejar create ::cookiejar $f +} -cleanup { + catch {rename ::cookiejar ""} + removeFile $f +} -result ::cookiejar +test http-cookiejar-7.2 {cookie storage: persistence of persistent cookies} -setup { + catch {rename ::cookiejar ""} + set f [makeFile "" cookiejar] + file delete $f + set result {} +} -constraints cookiejar -body { + http::cookiejar create ::cookiejar $f + cookiejar storeCookie [dict replace { + key foo + value cookie + secure 0 + domain www.example.com + origin www.example.com + path / + hostonly 1 + } expires [expr {[clock seconds]+1}]] + lappend result [::cookiejar getCookies http www.example.com /] + ::cookiejar destroy + http::cookiejar create ::cookiejar + lappend result [::cookiejar getCookies http www.example.com /] + ::cookiejar destroy + http::cookiejar create ::cookiejar $f + lappend result [::cookiejar getCookies http www.example.com /] +} -cleanup { + catch {rename ::cookiejar ""} + removeFile $f +} -result {{foo cookie} {} {foo cookie}} + +::tcltest::cleanupTests + +# Local variables: +# mode: tcl +# End: diff --git a/tests/lsetComp.test b/tests/lsetComp.test index 6846cbf..6846cbf 100644..100755 --- a/tests/lsetComp.test +++ b/tests/lsetComp.test diff --git a/tests/notify.test b/tests/notify.test index d2b9123..d2b9123 100644..100755 --- a/tests/notify.test +++ b/tests/notify.test diff --git a/tests/tcltest.test b/tests/tcltest.test index e66678b..e66678b 100644..100755 --- a/tests/tcltest.test +++ b/tests/tcltest.test diff --git a/tools/encoding/ebcdic.txt b/tools/encoding/ebcdic.txt index d9fa42e..d9fa42e 100644..100755 --- a/tools/encoding/ebcdic.txt +++ b/tools/encoding/ebcdic.txt diff --git a/tools/encoding/tis-620.txt b/tools/encoding/tis-620.txt index d3656c5..d3656c5 100644..100755 --- a/tools/encoding/tis-620.txt +++ b/tools/encoding/tis-620.txt diff --git a/win/buildall.vc.bat b/win/buildall.vc.bat index e4f0a30..e4f0a30 100644..100755 --- a/win/buildall.vc.bat +++ b/win/buildall.vc.bat |