Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297886

mime_header_encode() doesn't correctly follow the RFC 2047

$
0
0

Suggested commit message (feel free to change / doublecheck contributors, I scanned manually):

#84883 by earnie, ximo, netbjarne, scor, greggles, pillarsdotnet, DuaelFr, roderik: make Unicode::mimeHeaderEncode() conform to RFC 2047.

Problem

1)
Drupal\Component\Utility\Unicode::mimeHeaderEncode() ( mime_header_encode() in Drupal < 8) does not conform to RFC 2047 standards, particularly to one bit in section 2:

An 'encoded-word' may not be more than 75 characters long, including
'charset', 'encoding', 'encoded-text', and delimiters. If it is
desirable to encode more text than will fit in an 'encoded-word' of
75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may
be used.

This non-conformance was apparently introduced on purpose, given the current comments on the method/function (introduced july 2005, commit #11a4aba by Steven):

 * Using \n as the chunk separator may cause problems on some systems and
 * may have to be changed to \r\n or \r.

...so people with problems would have to hack their own solution in case or problems. Which was apparently because of (issues related to) restrictions in PHP's mail() function:

$subject - Subject of the email to be sent.
Caution: This must not contain any newline characters, or the mail may not be sent properly.

This restriction on mail() has by now been removed (as reported around november 2009), however - so we should be able to just conform to RFC 2047.

2)

The 'chunk size' of 47 is not correct, resulting in errors because of the length of encoded lines being longer than 75 characters.

Issue history

The combination of 2 bugs probably contributed to confusion around pinpointing the exact cause(s).

Until #95, people were trying to remove any newlines from the (encoded) subject header, to solve reported problems. (Which does not conform to the RFC). Plus figuring out where they came from.

The separator and chunk size were first introduced in #105, after which there were relatively few diversions.

Proposed resolution

The patch does two things, besides adding a test / changing comments:

  • Change the separator for encoded chunks to CRLF SPACE, as per the RFC
  • Decrease the chunk size to 45

Remaining tasks

review latest patch.

User interface changes

none

API changes

none

Data model changes

none

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue categoryBug because sending mail breaks (in easily reproducible situations)
Issue priorityMajor because same
Unfrozen changesNo.
Prioritized changesImproves stability; fixes clear bug; backport to D7/D6
DisruptionNo

Viewing all articles
Browse latest Browse all 297886

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>