Tk Library Source Code

View Ticket
Login
Ticket UUID: 1889835
Title: fix for extra CR/LF's inserted into binary file data
Type: Bug Version: None
Submitter: hume Created on: 2008-02-08 20:44:53
Subsystem: mime Assigned To: mrose
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2013-07-04 17:25:31
Resolution: Not Applicable Here Closed By:
    Closed on:
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)
            }
User Comments: hume added on 2008-02-09 03:44:53:

File Added - 265582: mime.tcl

Attachments: