Tcl Library Source Code

View Ticket
Login
Ticket UUID: 1193023
Title: smtp can have no originator/from
Type: Bug Version: None
Submitter: davidw Created on: 2005-04-30 15:16:18
Subsystem: smtp Assigned To: patthoyts
Priority: 5 Medium Severity:
Status: Open Last Modified: 2006-10-24 17:23:33
Resolution: None Closed By:
    Closed on:
Description:
Consider this code:

-----------------------------
        # If no -originator was provided, get the
originator from the "From"
        # header.  If there was no "From" header get it
from the username
        # executing the script.

        set who "-originator"
        if {$originator == ""} {
            if {![info exists header($fromL)]} {
                set originator $::tcl_platform(user)
            } else {
                set originator [join $header($fromL) ,]

                # Indicate that we're using the From
header for the originator.

                set who $fromM
            }
        }
        
# If there's no "From" header, create a From header
with the value
# of -originator as the value.

        if {[lsearch -exact $lowerL $fromL] < 0} {
            lappend lowerL $fromL
            lappend mixedL $fromM
            lappend header($fromL) $originator
        }

# ::mime::parseaddress returns a list whose elements
are huge key-value
# lists with info about the addresses.  In this case,
we only want one
# originator, so we want the length of the main list
to be 1.

        set addrs [::mime::parseaddress $originator]
        if {[llength $addrs] > 1} {
            error "too many mailboxes in $who: $originator"
        }
        array set aprops [lindex $addrs 0]
        if {$aprops(error) != ""} {
            error "error in $who: $aprops(error)"
        }
-----------------------------

It is entirely possible that there is no originator,
because tcl_platform(user) can be empty.  In that case,
the above code will fail if no -originator is provided
because aprops(error) will be empty.
User Comments: davidw added on 2005-04-30 22:23:46:
Logged In: YES 
user_id=240

I think this is really a Tcl bug, but for the time being,
it's probably a good idea to provide a workaround here.  The
Tcl bug in question is this: 681877