Description: |
The mime::buildmessageaux procedure has logic to insert carriage return line feeds in the middle of file data even when the encoding is binary. The problem occurs when the number of bytes is greater than 32766 so the file is read in more than one read call. Here are my changed lines in the version of mime.tcl that was released with tcllib 1.8. I believe that the head version is the same, at least in this procedure. I am no expert on mime and encodings, but I suspect the "\r\n" can be removed when $converter is not {} too. This excerpt starts around line 2030 of the file mime.tcl:
while {($size != 0) && (![eof $fd])} {
if {$size < 0 || $size > 32766} {
set X [read $fd 32766]
} else {
set X [read $fd $size]
}
if {$size > 0} {
set size [expr {$size - [string length $X]}]
}
if {[string compare $converter ""]} {
append result "[$converter -mode encode -- $X]\r\n"
} else {
# append result "$X\r\n"
# ECH fix - if binary do not mess up chunk boundaries
append result $X
}
}
# ECH fix - now add the \r\n after the data
if {![string compare $converter ""]} { append result "\r\n" } ;# ECH fix
if {$closeP} {
catch { close $state(fd) }
unset state(fd)
}
|