Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix mime failing tests. Add GPL license. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | mime | INCOMPATIBLE_LICENSE |
Files: | files | file ages | folders |
SHA3-256: |
f5d6a5e51b7d8607aa02a93c3cd2d71c |
User & Date: | pooryorick 2024-10-31 12:59:55.486 |
Context
2024-11-21
| ||
09:38 | shun COPYING. Re-licensing existing code is not allowed. Closing this branch, assuming you no longer want to continue with it. Feel free to re-open, if you like. Closed-Leaf check-in: 51bb6cedcd user: jan.nijtmans tags: pyk | |
2024-11-04
| ||
23:42 | Merge "mime" and "aes" branches into new "pyk" branch. check-in: 0b0d3c2be7 user: pooryorick tags: pyk, INCOMPATIBLE_LICENSE | |
2024-10-31
| ||
12:59 | Fix mime failing tests. Add GPL license. Closed-Leaf check-in: f5d6a5e51b user: pooryorick tags: mime, INCOMPATIBLE_LICENSE | |
2024-10-17
| ||
22:03 | Merge trunk and resolve conflicts. Some mime tests fail. check-in: aed2b8c04b user: pooryorick tags: mime | |
Changes
Deleted COPYING.
Changes to modules/mime/mime.tcl.
|
| < < < < > > > > > > > > > > > < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # (c) 1999-2000 Marshall T. Rose # (c) 2000 Brent Welch # (c) 2000 Sandeep Tamhankar # (c) 2000 Dan Kuchler # (c) 2000-2001 Eric Melski # (c) 2001 Jeff Hobbs # (c) 2001-2008 Andreas Kupries # (c) 2002-2003 David Welton # (c) 2003-2008 Pat Thoyts # (c) 2005 Benjamin Riefenstahl # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Copyright (c) 2018-2024 Poor Yorick # # You may distribute and/or modify this program under the terms of the GNU # Affero General Public License as published by the Free Software Foundation, # either version 3 of the License, or (at your option) any later version. # # See the file "COPYING" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # mime.tcl - MIME body parts # # Influenced by Borenstein's/Rose's safe-tcl (circa 1993) and Darren New's # unpublished package of 1999. # new string features and inline scan are used, requiring 8.3. package require Tcl 8.5 9 # Fix for 00d04c4f12l, base64 transchan over a refchan: segmentation fault, # requires 8.6.9 package require Tcl 8.6.9- package require {mime qp} package require namespacex package require tcl::chan::cat package provide mime 3.0.0 package require tcl::chan::memchan package require tcl::chan::string |
︙ | ︙ | |||
46 47 48 49 50 51 52 | # Warning! ## # These are a fragile emulations of the more general calling # sequence that appears to work with this code here. ## # The `__ignored__` arguments are expected to be `--` options on # the caller's side. (See the uses in `copymessageaux`, | | | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # Warning! ## # These are a fragile emulations of the more general calling # sequence that appears to work with this code here. ## # The `__ignored__` arguments are expected to be `--` options on # the caller's side. (See the uses in `copymessageaux`, # `serialize`, `parsepart`, and `getbody`). package require base64 2.0 set ::major [lindex [split [package require md5] .] 0] # Create these commands in the mime namespace so that they # won't collide with things at the global namespace level |
︙ | ︙ | |||
340 341 342 343 344 345 346 347 | if {[info exists fd]} { error [list {a channel is already present}] } if {[$chan configure -encoding] ne {binary}} { $chan configure -translation auto } set fd $chan | > > > > > | > > > | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | if {[info exists fd]} { error [list {a channel is already present}] } if {[$chan configure -encoding] ne {binary}} { $chan configure -translation auto } if {[set current [$chan tell]] < 0} { set chan [makeseekable $chan] } incr channels($chan) dropchan $token set fd $chan if {!$state(closechan)} { error [ list {need permission to close the channel in to make it seekable}] } return } # ::mime::addr_next -- # # Locate the next address in a mime token. |
︙ | ︙ | |||
932 933 934 935 936 937 938 939 940 941 942 943 944 945 | upvar 0 $token state upvar 0 state(bodychandecoded) bodychandecoded $_ parsepart if {[info exists state(parts)]} { error [list {not a leaf part} $token] } if {$state(canonicalP)} { $state(fd) seek 0 return $state(fd) } else { if {![info exists bodychandecoded]} { set bodychandecoded [[::tcllib::chan::base new [ info cmdcount]_bodydecoded] .init [file tempfile]] $bodychandecoded configure -translation binary | > | 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | upvar 0 $token state upvar 0 state(bodychandecoded) bodychandecoded $_ parsepart if {[info exists state(parts)]} { error [list {not a leaf part} $token] } if {$state(canonicalP)} { #{to do} {shouldn't this also get decoded?} $state(fd) seek 0 return $state(fd) } else { if {![info exists bodychandecoded]} { set bodychandecoded [[::tcllib::chan::base new [ info cmdcount]_bodydecoded] .init [file tempfile]] $bodychandecoded configure -translation binary |
︙ | ︙ | |||
1348 1349 1350 1351 1352 1353 1354 | set asciiP 1 set lineP 1 if {[info exists state(parts)]} { return [set state(encoding) {}] } if {[set current [$chan tell]] < 0} { | | | 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 | set asciiP 1 set lineP 1 if {[info exists state(parts)]} { return [set state(encoding) {}] } if {[set current [$chan tell]] < 0} { set chan [makeseekable $chan] set current [$chan tell] } set chanconfig [$chan configure] try { set buf {} set dataend 0 while {[set data [$chan read 8192]] ne {} || $buf ne {}} { |
︙ | ︙ | |||
1498 1499 1500 1501 1502 1503 1504 | if {!$childpart(addmessageid)} { header::unset $part message-id } } } set id [::sha2::sha256 -hex $ids] } else { | > > > > > | > | 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 | if {!$childpart(addmessageid)} { header::unset $part message-id } } } set id [::sha2::sha256 -hex $ids] } else { if {[info exists bodychan]} { #use the transfer-encoded form of the body to generate the id so that #each different encoding gets its own id set chan $state(bodychan) } else { set chan $state(fd) } set config [$chan configure] if {[dict exists $config -chan]} { dict unset config -chan } try { $chan seek 0 set id [::sha2::sha256 -hex -channel [$chan configure -chan]] |
︙ | ︙ | |||
1521 1522 1523 1524 1525 1526 1527 | proc ::mime::dropchan token { variable channels upvar 0 $token state upvar 0 state(fd) fd if {[info exists fd]} { | | | 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 | proc ::mime::dropchan token { variable channels upvar 0 $token state upvar 0 state(fd) fd if {[info exists fd]} { if {[incr channels($fd) -1] <= 0} { unset channels($fd) if {$state(closechan)} { $fd close } } unset state(fd) } |
︙ | ︙ | |||
1614 1615 1616 1617 1618 1619 1620 | #set unique [uniqueID] if {![header::exists $token content-id] && $state(addcontentid)} { header::setinternal $token Content-ID [contentid $_] } set sha [::sha2::SHA256Init] foreach {key val} [lsort -stride 2 [$_ header get]] { lassign $val value params | | | | 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 | #set unique [uniqueID] if {![header::exists $token content-id] && $state(addcontentid)} { header::setinternal $token Content-ID [contentid $_] } set sha [::sha2::SHA256Init] foreach {key val} [lsort -stride 2 [$_ header get]] { lassign $val value params ::sha2::SHA256Update $sha [::encoding convertto utf-8 $key$value] foreach {pkey pval} $params { ::sha2::SHA256Update $sha [::encoding convertto utf-8 $pkey$pval] } } set hash [::sha2::SHA256Final $sha] binary scan $hash H* hex return $hex@| } |
︙ | ︙ | |||
1690 1691 1692 1693 1694 1695 1696 | foreach part $state(parts) { incr size [getsize $part] } } else { set size 0 if {$state(canonicalP)} { if {[set current [$inputchan tell]] < 0} { | | | 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 | foreach part $state(parts) { incr size [getsize $part] } } else { set size 0 if {$state(canonicalP)} { if {[set current [$inputchan tell]] < 0} { set inputchan [makeseekable $inputchan] } set current [$inputchan tell] $inputchan seek 0 end set size [$inputchan tell] $inputchan seek $current } else { set size $state(size) |
︙ | ︙ | |||
2467 2468 2469 2470 2471 2472 2473 | # # the public interface for initializeaux proc ::mime::.new args { variable mime if {[llength $args] % 2} { set args [lassign $args[set args {}] name] | < < | 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 | # # the public interface for initializeaux proc ::mime::.new args { variable mime if {[llength $args] % 2} { set args [lassign $args[set args {}] name] } else { set name {} } set mimeid [incr mime(uid)] set token [namespace current]::$mimeid if {$name eq {}} { set name $token |
︙ | ︙ | |||
2539 2540 2541 2542 2543 2544 2545 | return -options $eopts $result } return $name } # ::mime::initializeaux -- # | | | 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 | return -options $eopts $result } return $name } # ::mime::initializeaux -- # # Creates a MIME part and returns the MIME token for that part. # # Arguments: # args Args can be any one of the following: # ?-canonical type/subtype # ?-params {?key value? ...} # ?-encoding value? # ?-headers {?key value? ...} |
︙ | ︙ | |||
2829 2830 2831 2832 2833 2834 2835 | if {[info exists headers]} { error "-header requires -canonical" } } | | | | > | > | | | | | < | | 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 | if {[info exists headers]} { error "-header requires -canonical" } } proc mime::makeseekable chan { if {[set current [$chan tell]] >= 0} { return $chan } set chan2 [::tcllib::chan::base new [info cmdcount]_chan] $chan2 .init [file tempfile] $chan2 configure -translation binary $chan copy [$chan2 configure -chan] incr size [$chan2 tell] $chan2 seek 0 $chan close return $chan2 } # ::mime::mapencoding -- # # mime::mapencodings maps tcl encodings onto the proper names for their # MIME charset type. This is only done for encodings whose charset types |
︙ | ︙ | |||
2923 2924 2925 2926 2927 2928 2929 | if {[dict exists $params charset]} { set charset [reversemapencoding [dict get $params charset]] if {$charset eq {}} { upvar 0 state(warnings) warnings lappend warnings [list {unknown charset} [ dict get $params charset] {using binary translation instead}] # but still do line automatic translation | | | 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 | if {[dict exists $params charset]} { set charset [reversemapencoding [dict get $params charset]] if {$charset eq {}} { upvar 0 state(warnings) warnings lappend warnings [list {unknown charset} [ dict get $params charset] {using binary translation instead}] # but still do line automatic translation $fd configure -encoding iso8859-1 -translation auto } else { $fd configure -encoding [reversemapencoding [dict get $params charset]] } } $bodychan configure -translation binary if {[info exists state(boundary)]} { |
︙ | ︙ | |||
2987 2988 2989 2990 2991 2992 2993 | $child header setinternal Content-Type application/octet-stream break } elseif {[llength $state(parts)] || [string first --$boundary $line] == 0} { # either just saw the first boundary or saw a boundary between parts # do not brace this expression if $iseof { | | > | | | | 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 | $child header setinternal Content-Type application/octet-stream break } elseif {[llength $state(parts)] || [string first --$boundary $line] == 0} { # either just saw the first boundary or saw a boundary between parts # do not brace this expression if $iseof { # reached the end of the file break } elseif {[string first --$boundary-- $line] >= 0} { # saw the closing boundary set state(sawclosing) 1 break } else { #mimegets returned 0 because it found a border set child [.new {} -chan $fd \ -root $state(root) -boundary $boundary -usemem $usemem] $child parsepart lappend state(parts) $child lappend state(dynamic) $child upvar 0 $child childstate set state(sawclosing) $childstate(sawclosing) if {$childstate(eof)} break } } else { # Accumulate data in case the terminating boundary occurs # before starting boundary was found, so that a part can be # generated from data seen so far. if $iseof { $bodychan puts -nonewline $line } else { $bodychan puts $line } set size [expr {$size + [ string length $line] + 1}] |
︙ | ︙ | |||
3689 3690 3691 3692 3693 3694 3695 | } else { $channel puts {} if {$state(canonicalP)} { set transforms [setencoding $token $channel] $state(fd) seek 0 $state(fd) copy [$channel configure -chan] while {[incr transforms -1] >= 0} { | | | 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 | } else { $channel puts {} if {$state(canonicalP)} { set transforms [setencoding $token $channel] $state(fd) seek 0 $state(fd) copy [$channel configure -chan] while {[incr transforms -1] >= 0} { $channel pop } } else { $state(bodychan) seek 0 $state(bodychan) copy [$channel configure -chan] } } |
︙ | ︙ |
Changes to modules/mime/mime.test.
1 2 3 4 5 6 7 | # mime.test - Test suite for TclMIME -*- tcl -*- # # This file contains a collection of tests for one or more of the Tcl # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 2000 by Ajuba Solutions, 2023 AK | < > > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # mime.test - Test suite for TclMIME -*- tcl -*- # # This file contains a collection of tests for one or more of the Tcl # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 2000 by Ajuba Solutions, 2023 AK # All rights reserved. # Copyright (c) 2018-2024 Poor Yorick # # You may distribute and/or modify this program under the terms of the GNU # Affero General Public License as published by the Free Software Foundation, # either version 3 of the License, or (at your option) any later version. # # See the file "COPYING" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ------------------------------------------------------------------------- source [file join [ file dirname [file dirname [file join [pwd] [info script]]] ] devtools testutilities.tcl] testsNeedTcl 9.0- testsNeedTcltest 2.0 support { # This code loads md5x, i.e. md5 v2. Proper testing should do one # run using md5 v1, aka md5.tcl as well. use md5/md5x.tcl md5 |
︙ | ︙ | |||
40 41 42 43 44 45 46 | proc channamescmp names { expr {[llength $names] == [llength [chan names]]} } | | > > > > > > > > > > > > > > > < < < < < | < > | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | proc channamescmp names { expr {[llength $names] == [llength [chan names]]} } proc cleanly args { if {![llength $args]} { error [list {wrong # args}] } set script [lindex $args end] set args [lrange $args[set args {}] 0 end-1] if {[llength $args] % 2} { error [list {wrong # args}] } set ns [info cmdcount] set names {} set values {} while {[llength $args]} { set args [lassign $args[set args {}] name value] lappend names $name lappend values $value } namespace eval $ns { namespace path [namespace parent] } catch {apply [list $names $script $ns] {*}$values} cres copts namespace delete $ns return -options $copts $cres } proc setup1 {} { uplevel 1 { |
︙ | ︙ | |||
251 252 253 254 255 256 257 | msg1} set tok [.new {} -string $msg1] catch {[$tok body raw] read} err1 catch {$tok serialize} err1a list $err1 $err1a }} "msg1 {MIME-Version: 2.0\r | | | | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | msg1} set tok [.new {} -string $msg1] catch {[$tok body raw] read} err1 catch {$tok serialize} err1a list $err1 $err1a }} "msg1 {MIME-Version: 2.0\r Message-ID: <7938b12d5fca6dac4d93058a53bd042eb6489fe781dc7c1d9e4d3fb2a0298568@|>\r Content-ID: <6d940d16b5e44281d818537093e2d718cf63b738bd80db235246918456966ad1@|>\r Content-Type: text/plain\r \r msg1}" test mime-3.5 {Try to parse a MIME message with no newline between headers and data} {cleanly { set msg2 {MIME-Version: 1.0 |
︙ | ︙ | |||
279 280 281 282 283 284 285 | foo} .new mime1 -string $msg3 catch {[mime1 body raw] read} err3 catch {mime1 serialize} err3a copts list $err3 $err3a }} "foo {MIME-Version: 1.0\r | | | > | | | | | | | | | | | | | < > | | | | | | < > | | | | | | | | | | | > > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | foo} .new mime1 -string $msg3 catch {[mime1 body raw] read} err3 catch {mime1 serialize} err3a copts list $err3 $err3a }} "foo {MIME-Version: 1.0\r Message-ID: <022a8d8e0087a026961cc81f97548a5961bc4bafad4c5d9619dc36553ee49064@|>\r Content-ID: <ff40a450d9fe90ddc6b0398c197809bf1c75166c9e18ad928c717927e96ba83f@|>\r Content-Type: text/plain\r \r foo}" cleanly { foreach name {file chan} { test mime-3.7.$name {Test mime with a bad email [SF Bug 631314 ]} [list cleanly name $name { with.$name [localPath test-assets badmail1.txt] { set res {} lappend res [llength [$tok property parts]] set ctok [lindex [$tok property parts] 0] lappend res [dictsort [$tok property]] lappend res [dictsort [$ctok property]] $tok .destroy string map [list $ctok CHILD] $res } }] {1 {content multipart/mixed encoding {} params {boundary ----------CSFNU9QKPGZL79} parts CHILD size 0} {content application/octet-stream encoding {} params {} size 0}} } foreach name {file chan} { test mime-3.8.1.$name {Test mime with another bad email [SF Bug 631314 ]} -body [list cleanly name $name { with.$name [localPath test-assets badmail2.txt] { set ctok [lindex [$tok property parts] 0] } }] -returnCodes 1 -result {end-of-string encountered while parsing multipart/form-data} } foreach name {file chan} { test mime-3.8.2.$name {Test mime with another bad email [SF Bug 631314 ]} [list cleanly name $name { with.$name [localPath test-assets badmail2.txt] -relax finalboundary { set res {} set ctok [lindex [$tok property parts] 0] lappend res [dictsort [$tok property]] lappend res [dictsort [$ctok property]] $tok .destroy string map [list $ctok CHILD] $res } }] {{content multipart/related encoding {} params {boundary ----=_NextPart_000_0000_2CBA2CBA.150C56D2} parts CHILD size 879} {content text/html encoding base64 params {} size 879}} } } test mime-3.9 {Parse a MIME message with a charset encoded body and use [body decoded] to get it back} {cleanly { set msg {MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Fran\xE7ois |
︙ | ︙ | |||
369 370 371 372 373 374 375 | This is a message in the scribble charset that tcl does not recognise.} set tok [.new {} -string $msg] lappend res [$tok header get content-type] lappend res [[$tok body decoded] configure -encoding] catch {[$tok body decoded] read} errmsg lappend res $errmsg | | < | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | This is a message in the scribble charset that tcl does not recognise.} set tok [.new {} -string $msg] lappend res [$tok header get content-type] lappend res [[$tok body decoded] configure -encoding] catch {[$tok body decoded] read} errmsg lappend res $errmsg }} {{text/plain {charset SCRIBBLE}} iso8859-1 {This is a message in the scribble charset that tcl does not recognise.}} test mime-4.1 {Test qp::encode with a > 76 character string containing special chars.} {cleanly { set str1 "foo!\"\t barbaz \$ ` \{ # jack and jill went up a hill to fetch a pail of water. Jack fell down and said !\"\#\$@\[\\\]^`\{\|\}\~ \nJill said, \"Oh my\"" qp encode $str1 }} "foo=21=22\t barbaz =24 =60 =7B =23 jack and jill went up a hill to fetch a=\n pail of water. Jack fell down and said =21=22=23=24=40=5B=5C=5D=5E=60=7B=\n=7C=7D=7E =20\nJill said, =22Oh my=22" |
︙ | ︙ | |||
500 501 502 503 504 505 506 | test mime-5.9 {Test word_encode with quoted-printable method and multibyte character} {cleanly { word_encode euc-jp quoted-printable "Following me is a multibyte character \xA4\xCF" }} =?EUC-JP?Q?Following_me_is_a_multibyte_character_=A4=CF?= set n 10 while {$n < 14} { | | | | | > | | | | | | | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | test mime-5.9 {Test word_encode with quoted-printable method and multibyte character} {cleanly { word_encode euc-jp quoted-printable "Following me is a multibyte character \xA4\xCF" }} =?EUC-JP?Q?Following_me_is_a_multibyte_character_=A4=CF?= set n 10 while {$n < 14} { test mime-5.$n {Test word_encode with quoted-printable method and multibyte character across encoded word boundary} [list cleanly n $n { word_encode euc-jp quoted-printable "Following me is a multibyte character \xA4\xCF" -maxlength [expr 42 + $n] }] "=?EUC-JP?Q?Following_me_is_a_multibyte_character_?= =?EUC-JP?Q?=A4=CF?=" incr n } test mime-5.14 {Test word_encode with quoted-printable method and multibyte character (triple)} {cleanly { word_encode utf-8 quoted-printable "Here is a triple byte encoded character \xE3\x81\xAF" }} =?UTF-8?Q?Here_is_a_triple_byte_encoded_character_=E3=81=AF?= set n 15 while {$n < 23} { test mime-5.$n {Test word_encode with quoted-printable method and triple byte character across encoded word boundary} [list cleanly n $n { word_encode utf-8 quoted-printable "Here is a triple byte encoded character \xE3\x81\xAF" -maxlength [expr 38 + $n] }] "=?UTF-8?Q?Here_is_a_triple_byte_encoded_character_?= =?UTF-8?Q?=E3=81=AF?=" incr n } while {$n < 25} { test mime-5.$n {Test word_encode with quoted-printable method and triple byte character across encoded word boundary} [list cleanly n $n { word_encode utf-8 quoted-printable "Here is a triple byte encoded character \xE3\x81\xAF" -maxlength [expr 38 + $n] }] =?UTF-8?Q?Here_is_a_triple_byte_encoded_character_=E3=81=AF?= incr n } while {$n < 29} { test mime-5.$n {Test word_encode with base64 method across encoded word boundaries} [list cleanly n $n { word_encode euc-jp base64 "There is a multibyte character \xA4\xCF" -maxlength [expr 28 + $n] }] "=?EUC-JP?B?VGhlcmUgaXMgYSBtdWx0aWJ5dGUgY2hhcmFjdGVy?= =?EUC-JP?B?IKTP?=" incr n } while {$n < 33} { test mime-5.$n {Test word_encode with base64 method and triple byte character across encoded word boundary} [list cleanly n $n { word_encode utf-8 base64 "Here is a multibyte character \xE3\x81\xAF" -maxlength [expr 23 + $n] }] "=?UTF-8?B?SGVyZSBpcyBhIG11bHRpYnl0ZSBjaGFyYWN0ZXIg?= =?UTF-8?B?44Gv?=" incr n } test mime-5.33 {Test word_encode with quoted-printable method and -maxlength set to same length as will the result} {cleanly { word_encode iso8859-1 quoted-printable 123 -maxlength 20 |
︙ | ︙ | |||
660 661 662 663 664 665 666 | 11 {(=?ISO-8859-1?Q?a?=x=?ISO-8859-2?Q?_b?=)} {(ax b)} 12 {a b c} {a b c} 13 {} {} } { | | > > | | > | | > | | > > | | | | | | | | | | | | | | | | | > | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | 11 {(=?ISO-8859-1?Q?a?=x=?ISO-8859-2?Q?_b?=)} {(ax b)} 12 {a b c} {a b c} 13 {} {} } { test mime-6.$n {Test field_decode (from RFC 2047, part 8)} [ list cleanly n $n encoded $encoded expected $expected { field_decode $encoded }] $expected } foreach {bug n encoded expected} { 764702 1 {(=?utf-8?Q?H=C3=BCrz?=)} {(Hürz)} } { test mime-7.$n "Test field_decode (from SF Tcllib bug $bug)" [ list cleanly encoded $encoded { field_decode $encoded }] $expected } test mime-8.1 {Test reversemapencoding+mapencoding with preferred name} {cleanly { set charset [reversemapencoding US-ASCII] mapencoding $charset }} US-ASCII test mime-8.2 {Test reversemapencoding+mapencoding with alias} {cleanly { set charset [reversemapencoding UTF8] mapencoding $charset }} UTF-8 cleanly { foreach name {file chan} { test mime-9.0.$name {Test chunk handling of serialize and helpers} [ list cleanly name $name { set in [makeFile [set data [string repeat [string repeat {123456789 } 10]\n 350]] input.txt] set mi [makeFile {} mime.txt] with.$name $in -canonical text/plain { [::tcllib::chan::base new chan1] .init [open $mi w] chan1 configure -translation binary $tok serialize -chan chan1 chan1 close with.$name $mi { set newdata [[$tok body raw] read] set res [string compare $data $newdata] removeFile input.txt removeFile mime.txt unset data newdata tok in mi set res } } }] 0 } } set ::env(TZ) UTC0 set epoch [clock scan 2000-01-01] foreach {n stamp date} { 1 86340 {Sat, 01 Jan 2000 23:59:00 +0000} 2 5176620 {Tue, 29 Feb 2000 21:57:00 +0000} |
︙ | ︙ | |||
772 773 774 775 776 777 778 | chan1 configure -translation binary $attachment serialize -chan chan1 -level 1 chan1 close set data [viewFile $out] file delete $in $out set data | | | | 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 | chan1 configure -translation binary $attachment serialize -chan chan1 -level 1 chan1 close set data [viewFile $out] file delete $in $out set data }} {Message-ID: <f0349bb839fb06cd4d858de88c094b8922a43956a8c0c1a192fb9a2863ad96a5@|> Content-ID: <2d33a7fd638536de66c1ae9fce46cb98e4356a363e593148a130e45c390313ca@|> Content-Type: application/octet-stream ; name=a0036.dss Content-Disposition: attachment ; filename=a0036.dss Content-Transfer-Encoding: base64 BGRzcwEAAQABAAAAYQAAAAAAAAAAAAAAAAAAACQAAAD+//7/+/8wNzA2MTYwODE1MjQwNzA2 |
︙ | ︙ | |||
821 822 823 824 825 826 827 | set tok [.new {} -string $msg] [$tok body raw] read } "so plain\n" # ------------------------------------------------------------------------- test mime-14.0 {ticket 5f455d6343} -setup { | < | | | | | < | | | | | | | | | 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 | set tok [.new {} -string $msg] [$tok body raw] read } "so plain\n" # ------------------------------------------------------------------------- test mime-14.0 {ticket 5f455d6343} -setup { set part [.new -canonical application/x-simile \ -headers [list "Content-Description" "Run Status"] \ -encoding base64 -string "This is a test"] set whole [.new -canonical multipart/mixed -parts [list $part]] set saved checkmime.msg set stm [open $saved w] mime::serialize $whole -chan $stm close $stm } -body { set stm [open $saved r] set str [read $stm] close $stm set restore [.new -string $str] } -cleanup { $restore .destroy unset part whole saved stm str } -match glob -result "::mime::*" # ------------------------------------------------------------------------- test mime-14.1 {cleanly { hostname argument to parseaddress }} { set parsed [parseaddress hostname fakedomain.fake {Here <h>}] list [llength $parsed] [lindex $parsed 0] } [list 1 [list address [email protected] comment {} domain {} error {} \ friendly Here group {} local h memberP 0 phrase Here \ proper {Here <[email protected]>} route {}]] test mime-14.2 {cleanly { special characters in local part }} { set parsed [parseaddress hostname fakedomain.fake foo<>[email protected]] list [llength $parsed] [lindex $parsed 0] } [list 1 [list address {} comment {} domain {} \ error {expecting mailbox in local-part (found >)} friendly foo group {} \ local {} memberP 0 phrase foo proper {foo <>} route {}]] test mime-14.3 { special characters in local part } {cleanly { set parsed [parseaddress hostname fakedomain.fake {"foobar"@grill.com}] list [llength $parsed] [lindex $parsed 0] }} [list 1 [ list address {"foobar"@grill.com} comment {} domain grill.com error {} \ friendly foobar group {} local {"foobar"} memberP 0 phrase {} \ proper {"foobar"@grill.com} route {}]] # ------------------------------------------------------------------------- |
︙ | ︙ | |||
914 915 916 917 918 919 920 | $tok header get } [list Content-Type {text/plain {}} Content-Disposition [ list attachment [list param1 {a parameter value} \ param2 {another parameter value}]]] set char [encoding convertfrom utf-8 \xE3\x81\xAF] | | < | | | 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 | $tok header get } [list Content-Type {text/plain {}} Content-Disposition [ list attachment [list param1 {a parameter value} \ param2 {another parameter value}]]] set char [encoding convertfrom utf-8 \xE3\x81\xAF] test mime-16.1 {} { set res {} set mime [.new {} -canonical text/plain -string {dawg one}] $mime header set Content-Disposition attachment [list param1 $char] set msg [$mime serialize] lappend res $msg set mime2 [.new {} -string $msg] lappend res [$mime2 header get] return $res } [list "MIME-Version: 1.0\r Message-ID: <056eb988475329e0d14defde74ba007f9b56e6f0d3a04ad773528dec1336ff26@|>\r Content-ID: <086570e97284c5bc5145f32689a5342363b10b64963446293b83930fa8a9fa45@|>\r Content-Type: text/plain\r Content-Disposition: attachment\r ; param1*0*=utf-8''%E3%81%AF\r \r dawg one" \ [list Content-ID {<086570e97284c5bc5145f32689a5342363b10b64963446293b83930fa8a9fa45@|> {}} Content-Type {text/plain {}} \ Message-ID {<056eb988475329e0d14defde74ba007f9b56e6f0d3a04ad773528dec1336ff26@|> {}} \ Content-Disposition [list attachment [list param1 $char]]] ] # ------------------------------------------------------------------------- |
︙ | ︙ | |||
1027 1028 1029 1030 1031 1032 1033 | } { set mime [.new {} -spec http -string {}] $mime serialize } "\r " | | | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | } { set mime [.new {} -spec http -string {}] $mime serialize } "\r " test {mime cookie serialization} { cookie serialization } { set mime [.new {} -spec http -string {}] $mime cookie set one two set res [$mime serialize] $mime .destroy return $res |
︙ | ︙ | |||
1059 1060 1061 1062 1063 1064 1065 | \t; HttpOnly\r \r " testsuiteCleanup | < | > > > > | | 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | \t; HttpOnly\r \r " testsuiteCleanup return } after 0 [list ::coroutine [info cmdcount]_main ::apply [list {} { variable done catch main cres copts set done [list $copts $cres] } [namespace current]]] vwait [namespace current]::done return -options {*}$done |
Changes to modules/mime/pkgIndex.tcl.
|
| | | 1 2 3 4 5 | if {![package vsatisfies [package provide Tcl] 8.6.9 9]} return package ifneeded smtp 1.5.2 [list source [file join $dir smtp.tcl]] package ifneeded mime 3.0.0 [list source [file join $dir mime.tcl]] package ifneeded {mime qp} 1.7 [list source [file join $dir qp.tcl]] |
Changes to modules/ncgi/ncgi.tcl.
1 2 3 4 5 6 7 | # ncgi.tcl # # Basic support for CGI programs # # Copyright (c) 2000 Ajuba Solutions. # Copyright (c) 2012 Richard Hipp, Andreas Kupries # Copyright (c) 2013-2014 Andreas Kupries | < > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # ncgi.tcl # # Basic support for CGI programs # # Copyright (c) 2000 Ajuba Solutions. # Copyright (c) 2012 Richard Hipp, Andreas Kupries # Copyright (c) 2013-2014 Andreas Kupries # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Copyright (c) 2018-2024 Poor Yorick # # You may distribute and/or modify this program under the terms of the GNU # Affero General Public License as published by the Free Software Foundation, # either version 3 of the License, or (at your option) any later version. # # See the file "COPYING" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # Please note that Don Libes' has a "cgi.tcl" that implements version 1.0 # of the cgi package. That implementation provides a bunch of cgi_ procedures # (it doesn't use the ::cgi:: namespace) and has a wealth of procedures for # generating HTML. In contrast, the package provided here is primarly # concerned with processing input to CGI programs. # Note, I use the term "query data" to refer to the data that is passed in # to a CGI program. Typically this comes from a Form in an HTML browser. # The query data is composed of names and values, and the names can be # repeated. The names and values are encoded, and this module takes care # of decoding them. # We use newer string routines package require Tcl 8.6- package require {chan base} package require fileutil ; # Required by importFile. package require mime 3.0- package require uri package provide ncgi 1.5.0 |
︙ | ︙ | |||
173 174 175 176 177 178 179 | # Decodes data in www-url-encoded format. # # Arguments: # An encoded value. # # Results: # The decoded value. | | > > | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | # Decodes data in www-url-encoded format. # # Arguments: # An encoded value. # # Results: # The decoded value. proc ::ncgi::DecodeHex hex { return [binary decode hex $hex] } proc ::ncgi::decode str { # rewrite "+" back to space # protect \ from quoting another '\' set str [string map [list + { } "\\" "\\\\" \[ \\\[ \] \\\]] $str] # prepare to process all %-escapes regsub -all -nocase -- {%([E][A-F0-9])%([89AB][A-F0-9])%([89AB][A-F0-9])%([89AB][A-F0-9])} \ $str {[encoding convertfrom utf-8 [DecodeHex \1\2\3]]} str regsub -all -nocase -- {%([E][A-F0-9])%([89AB][A-F0-9])%([89AB][A-F0-9])} \ $str {[encoding convertfrom utf-8 [DecodeHex \1\2\3]]} str regsub -all -nocase -- {%([CD][A-F0-9])%([89AB][A-F0-9])} \ $str {[encoding convertfrom utf-8 [DecodeHex \1\2]]} str regsub -all -nocase -- {%([A-F0-9][A-F0-9])} $str {\\u00\1} str # process \u unicode mapped chars return [subst -novar $str] } |
︙ | ︙ | |||
636 637 638 639 640 641 642 | # Results: # The raw query data. proc ::ncgi::query_string token { namespace upvar $token env env querystring querystring if {[info exists querystring]} { | | < | 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 | # Results: # The raw query data. proc ::ncgi::query_string token { namespace upvar $token env env querystring querystring if {[info exists querystring]} { # This ensures you can call ncgi::query more than once. return $querystring } set querystring {} if {[info exists env(QUERY_STRING)]} { set querystring $env(QUERY_STRING) } |
︙ | ︙ |
Changes to modules/ncgi/ncgi.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # -*- tcl -*- # Tests for the cgi module. # # This file contains a collection of tests for one or more of the Tcl # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 1998-2000 by Ajuba Solutions # ------------------------------------------------------------------------- source [file join [ file dirname [file dirname [file join [pwd] [info script]]] ] devtools testutilities.tcl] testsNeedTcl 8.5 | > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # -*- tcl -*- # Tests for the cgi module. # # This file contains a collection of tests for one or more of the Tcl # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 1998-2000 by Ajuba Solutions # Copyright (c) 2018-2024 Poor Yorick # # You may distribute and/or modify this program under the terms of the GNU # Affero General Public License as published by the Free Software Foundation, # either version 3 of the License, or (at your option) any later version. # # See the file "COPYING" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ------------------------------------------------------------------------- source [file join [ file dirname [file dirname [file join [pwd] [info script]]] ] devtools testutilities.tcl] testsNeedTcl 8.5 |
︙ | ︙ | |||
203 204 205 206 207 208 209 | test ncgi-3.9 {ncgi::decode, bug 3601995} { ncgi decode {%E2%A0%90} } "\u2810" ; # a braille pattern | | | | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | test ncgi-3.9 {ncgi::decode, bug 3601995} { ncgi decode {%E2%A0%90} } "\u2810" ; # a braille pattern test ncgi-3.10 {ncgi::decode, bug 3601995, tkt [1f900bdf6b]} { ncgi::decode {%E2%B1} } "\u00e2\u00b1" ;# Changed with branch `ncgi-1f900bdf6b`, tkt [1f900bdf6b] test ncgi-4.1 {ncgi::encode} { ncgi encode abcdef0123 } abcdef0123 |
︙ | ︙ |
Changes to modules/pop3/pop3.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # -*- tcl -*- # pop3.test: tests for the pop3 client. # # This file contains a collection of tests for one or more of the Tcl # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 2002-2006 by Andreas Kupries <[email protected]> # All rights reserved. # ------------------------------------------------------------------------- | | < | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # -*- tcl -*- # pop3.test: tests for the pop3 client. # # This file contains a collection of tests for one or more of the Tcl # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 2002-2006 by Andreas Kupries <[email protected]> # All rights reserved. # ------------------------------------------------------------------------- source [file join [file dirname [file dirname [ file join [pwd] [info script]]]] devtools testutilities.tcl] testsNeedTcl 8.5 testsNeedTcltest 2.0 tcltest::testConstraint hastls [expr {![catch {package require tls}]}] support { #use snit/snit.tcl snit ;# comm futures, not used, still a dependency #use comm/comm.tcl comm use log/log.tcl log |
︙ | ︙ |
Changes to modules/pop3d/pop3d.tcl.
︙ | ︙ | |||
1097 1098 1099 1100 1101 1102 1103 | # construction in memory (depending on source of token). log::log debug "pop3d $name Transfer $msgid /full" # We do "."-stuffing here. This is not in the scope of the # MIME library we use, but a transport dependent thing. | | | | | 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | # construction in memory (depending on source of token). log::log debug "pop3d $name Transfer $msgid /full" # We do "."-stuffing here. This is not in the scope of the # MIME library we use, but a transport dependent thing. set msg [string trimright [string map [list "\n." "\n.."] [ mime::serialize $token]] \n] log::log debug "($msg)" puts $sock $msg puts $sock . } else { # As long as FR #531541 is not implemented we have to build # the entire message in memory and then cut it down to the # requested size. If limit was greater than the number of # lines in the message we will get the terminating "." # too. Using regsub we make sure that it is not present and # reattach during the transfer. Otherwise we would have to use # a regexp/if combo to decide wether to attach the terminator # not. set msg [split [mime::serialize $token] \n] set i 0 incr limit -1 while {[lindex $msg $i] != {}} { incr i incr limit } # i now refers to the line separating header and body |
︙ | ︙ |
Changes to modules/pop3d/pop3d.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # Copyright (c) 2002-2014 by Andreas Kupries <[email protected]> # All rights reserved. # # RCS: @(#) $Id: pop3d.test,v 1.24 2011/11/14 22:33:48 andreas_kupries Exp $ # ------------------------------------------------------------------------- | | < | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Copyright (c) 2002-2014 by Andreas Kupries <[email protected]> # All rights reserved. # # RCS: @(#) $Id: pop3d.test,v 1.24 2011/11/14 22:33:48 andreas_kupries Exp $ # ------------------------------------------------------------------------- source [file join [file dirname [file dirname [ file join [pwd] [info script]]]] devtools testutilities.tcl] testsNeedTcl 8.5 ;# Required by mime.tcl testsNeedTcltest 2.0 support { #use comm/comm.tcl comm useTcllibFile devtools/coserv.tcl ; # loads comm too useTcllibFile devtools/dialog.tcl use md5/md5x.tcl md5 use mime/mime.tcl mime |
︙ | ︙ |
Changes to modules/pop3d/pop3d_dbox.tcl.
︙ | ︙ | |||
433 434 435 436 437 438 439 | } { return -code error "id \"$msgId\" out of range" } incr msgId -1 set mailfile [lindex $state($dir) $msgId] | | | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | } { return -code error "id \"$msgId\" out of range" } incr msgId -1 set mailfile [lindex $state($dir) $msgId] set token [::mime::.new -file $mailfile] return $token } ########################### ########################### # Internal helper commands. |
︙ | ︙ |
Changes to modules/pop3d/pop3d_dbox.test.
︙ | ︙ | |||
13 14 15 16 17 18 19 | # ------------------------------------------------------------------------- source [file join \ [file dirname [file dirname [file join [pwd] [info script]]]] \ devtools testutilities.tcl] testsNeedTcl 8.5 ;# Required by mime.tcl | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # ------------------------------------------------------------------------- source [file join \ [file dirname [file dirname [file join [pwd] [info script]]]] \ devtools testutilities.tcl] testsNeedTcl 8.5 ;# Required by mime.tcl testsNeedTcltest 2.0 support { use md5/md5x.tcl md5 use mime/mime.tcl mime } testing { useLocal pop3d_dbox.tcl pop3d::dbox |
︙ | ︙ |