Tcl Library Source Code

Ticket Change Details
Login
Overview

Artifact ID: a3ac593dfa35367025764364e1cedba29dc72b1fd0263e57042582c4577ee511 (Awaiting Moderator Approval)
Ticket: d3f66f9a756f54569caf57bbb2cade1f3d25ad06
mime::field_decode remove spaces in specific situations
User & Date: anonymous 2025-05-19 09:28:02
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. comment changed to:
    Example from a newsletter:
    
    Subject: =?UTF-8?Q?Neuer_SPD-Generalsekret=C3=A4r_?=
     =?UTF-8?Q?Kl=C3=BCssendorf_warnt_Union_vor_?=
     =?UTF-8?Q?Konflikt_bei_Migration?=
    
    puts [::mime::field_decode [::mime::getheader $mime_data "Subject"]]
    results in
    
    "Neuer SPD-GeneralsekretärKlüssendorf warnt Union vorKonflikt bei Migration"
    
    it should be
    "Neuer SPD-Generalsekretär Klüssendorf warnt Union vor Konflikt bei Migration"
    
    Note that the whitespace is part of the encoded word.
    A quick-fix for me (may break some other case) was to switch order while decoding:
    
    @@ -2537,18 +2537,18 @@
     proc ::mime::qp_decode {string {encoded_word 0}} {
         # 8.1+ improved string manipulation routines used.
         # Special processing for encoded words (RFC 2047)
    -
    -    if {$encoded_word} {
    -        # _ == \x20, even if SPACE occupies a different code position
    -        set string [string map [list _ \u0020] $string]
    -    }
    -
    +
         # smash the white-space at the ends of lines since that must've been
         # generated by an MUA.
    
         regsub -all -- {[ \t]+\n} $string \n string
         set string [string trimright $string " \t"]
    
    +    if {$encoded_word} {
    +        # _ == \x20, even if SPACE occupies a different code position
    +        set string [string map [list _ \u0020] $string]
    +    }
    +
         # Protect the backslash for later subst and
         # smash soft newlines, has to occur after white-space smash
         # and any encoded word modification.
    
  4. foundin changed to: "1.20"
  5. is_private changed to: "0"
  6. login: "anonymous"
  7. mimetype: "text/x-fossil-plain"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "anonymous"
  13. subsystem changed to: "mime"
  14. title changed to:
    mime::field_decode remove spaces in specific situations
    
  15. type changed to: "Bug"