6.0.0-beta1
7/4/25

[#13587] MIME parsing breaks when boundary includes apostrophe
Summary MIME parsing breaks when boundary includes apostrophe
Queue Horde Framework Packages
Queue Version Git master
Type Bug
State Resolved
Priority 1. Low
Owners slusarz (at) horde (dot) org
Requester spamstop1 (at) terriertech (dot) com
Created 09/20/2014 (3940 days ago)
Due
Updated 09/24/2014 (3936 days ago)
Assigned 09/24/2014 (3936 days ago)
Resolved 09/24/2014 (3936 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
09/24/2014 11:41:01 PM Michael Slusarz Comment #6
State ⇒ Resolved
Reply to this comment
Will be in Horde_Mime 2.5.0
09/24/2014 11:40:53 PM Git Commit Comment #5 Reply to this comment
Changes have been made in Git (master):

commit dc54d1510227f35382715f4ade02f1644868d146
Author: Michael M Slusarz <slusarz@horde.org>
Date:   Tue Sep 23 01:04:39 2014 -0600

     [mms] Moved content parameter handling methods out of Horde_Mime 
and into Horde_Mime_ContentParam.

     [mms] Use string-based ABNF-based parser for scanning MIME 
content parameters instead of a regular expression (Bug #13587).

  framework/Mime/doc/Horde/Mime/UPGRADING            |   17 +-
  framework/Mime/lib/Horde/Mime.php                  |  316 
+++-----------------
  framework/Mime/lib/Horde/Mime/ContentParam.php     |  280 +++++++++++++++++
  .../Mime/lib/Horde/Mime/ContentParam/Decode.php    |  103 +++++++
  framework/Mime/lib/Horde/Mime/Headers.php          |   17 +-
  framework/Mime/package.xml                         |   20 ++-
  .../test/Horde/Mime/ContentParam/DecodeTest.php    |   78 +++++
  .../Mime/test/Horde/Mime/ContentParamTest.php      |  189 ++++++++++++
  framework/Mime/test/Horde/Mime/MimeTest.php        |   56 ----
  9 files changed, 735 insertions(+), 341 deletions(-)

http://github.com/horde/horde/commit/dc54d1510227f35382715f4ade02f1644868d146
09/24/2014 08:41:29 PM Michael Slusarz Comment #4
Assigned to Michael Slusarz
State ⇒ Assigned
Priority ⇒ 1. Low
Reply to this comment
This is a good excuse to tear out the archaic regex and replace with 
the correct, ABNF string parsing method instead.
09/21/2014 09:29:33 AM spamstop1 (at) terriertech (dot) com Comment #3 Reply to this comment
I tried changing the regex to
         $splitRegex = 
'/([^;\'"]*([\'"])((?:(?!\1).)+)(?1)[^;\'"]*|([^;]+))(;|$)/';

It fixed the problem.

I tried a few other phones and it didn't break anything on them, but I 
don't have an extensive set of test messages to test with.
09/20/2014 04:33:30 AM spamstop1 (at) terriertech (dot) com Comment #2
New Attachment: broken.txt Download
Reply to this comment
Now it is attached.
An example is attached.
09/20/2014 04:32:14 AM spamstop1 (at) terriertech (dot) com Comment #1
Priority ⇒ 2. Medium
Type ⇒ Bug
Summary ⇒ MIME parsing breaks when boundary includes apostrophe
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ No
State ⇒ Unconfirmed
Reply to this comment
Horde_Mime::decodeParam breaks when the MIME boundary contains an apostrophe.

The splitRegex (line 440 in Mime.php) seems to assume that apostrophes 
will enclose a string and not occur within it.  This means that the 
"boundary=" parameter is stripped out of the Content-Type header when 
it includes an apostrophe.

An example is attached.

The message body is OK, but since the boundary is missing from the 
Content-Type header it shows up blank in most mail clients.

Saved Queries