Tcl Library Source Code

View Ticket
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Ticket UUID: 1613224
Title: too much braced message header values (::mime::getheader)
Type: Bug Version: None
Submitter: martinlemburg Created on: 2006-12-11 15:33:08
Subsystem: mime Assigned To:
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2018-08-29 14:41:31
Resolution: Fixed Closed By:
    Closed on:
Description:
Hello,

currently experienced, that an eMail had for one message part a Content-ID like "[email protected]".

Using ::mime::getheader on that message part returned:

    % set header [::mime::getheader ::mime::3-2]
    Content-ID {{<002401c71848_6fba22d[email protected]>}}
    % dict get $header Content-ID
    {<[email protected]>}
    % ::mime::getheader ::mime::3-2 Content-ID
    {<[email protected]>}

I expected to get a once-braced value, but not a twice-braced value.

I used the mime package v1.5 from the tcllib 1.9 in tcl/tk 8.4.13 and 8.5a4.

IMHO this is a misbehaviour, a bug.

Thanks,

Martin Lemburg
User Comments: pooryorick added on 2018-08-29 14:41:31:

As of [5006be5e6a3d2ccd] ::mime::getheader returns a dictionary of headers, where keys may be redundant. This eliminates the list behaviour described in this ticket. By the same token, when a key is provided, a list of matching headers is still returned. This variety of behaviours should be enough to satisfy both needs while remaining sufficiently convenient to use.


dnew added on 2006-12-15 02:36:25:
Logged In: YES 
user_id=37425
Originator: NO

There are many headers that are only supposed to appear once, and many that may appear multiple times. There's no easy way to provide a list of all headers that should only appear once and all headers that may appear multiple times. Now that you know why it happens, why not simply take [lindex ... 0] of any header that your code expects to appear only once? Or, alternately, check that the list length is indeed only 1, and provide an error message if you are given a malformed message?

martinlemburg added on 2006-12-14 15:39:22:
Logged In: YES 
user_id=802134
Originator: YES

I do still think, that this is a bug!

The Content-Id inside a "header" of a message part must be a real identifier!
There is only one Content-Id per message part, or the message is mal formed!

So the Content-ID should not be a list.

I think from my own experience, that there is some addition quoting/bracing because of the "$" inside the Content-ID.
If this is needed during parsing the message part ... ok.
But returning the additionally braced value is ... not ok and unexpected, because of the intention of this value, the Content-ID.

Good morning from Berlin/Germany,

Marti

dnew added on 2006-12-14 03:30:17:
Logged In: YES 
user_id=37425
Originator: NO

I don't believe this is a bug. Headers are allowed to be repeated, such as for "Received" headers. Putting "Received" in a list and other headers not in a list would require the mime package and the user to know every possible header, and it would require everyone knowing that a header that appears only once might in other messages appear multiple times. If you expect only one instance of a header in your message, just access the zero'th element of the list returned.