Project

General

Profile

Actions

Bug #17310

closed

Wrong quoted-printable encoding of email headers

Added by Thorsten Kahler almost 17 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2007-05-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
4.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

For email header lines there are some special conditions. E.g. quotation marks are used to denote the transfer encoding (quoted-printable or base64).

The attached patch adds a distinction to t3lib_div::quoted_printable() to respect these cases.

Send an email (either with t3lib_htmlmail or t3lib_div::plainMailEncoded()) that has a quotation mark in the subject line.

(issue imported from #M5633)


Files

quoted-printable.diff (2.4 KB) quoted-printable.diff Administrator Admin, 2007-05-14 18:11
Actions #1

Updated by Martin Kutschker almost 17 years ago

If I read the patch correctly for headers the characters = and ? are not encoded. Which is wrong BECAUSE these are used to signify charset and encoding.

The attached diff shows clearly that the encoded string is to be used WITHIN a =?charset?Q?...?= construct.

So I fail to see a) the original problem and b) how the "fix" is any better. In fact I think the patch is wrong.

Actions #2

Updated by Thorsten Kahler almost 17 years ago

For me the patch works.

But indeed it doesn't reach far enough. According to RFC 2047 5 [1]. "encoded-word"s are not allowed in all header fields. The current interface of t3lib_div::encodeHeader() has to be extended to enable that distinction.

I'm currently working on a new patch which adds an optional parameter to the interface of t3lib_div::encodedHeader() and uses the "best available" PHP function to encode the header line. IMO it should prefer the function that's pointed out by TYPO3_CONF_VARS[SYS][t3lib_cs_convMethod].

[1] http://www.faqs.org/rfcs/rfc2047.html

Actions #3

Updated by Martin Kutschker almost 17 years ago

Maybe it would help, if you posted input and expected and actual output. Neither from this bug entry nor frrom the patch I'm able to see what went wrong for you.

Actions #4

Updated by Thorsten Kahler almost 17 years ago

Hi Masi,

please try these lines:

<?php
$headerline1 = 'Is this line wrong? Yes!';
$headerline2 = 'Is this line wrong? No!';
include('t3lib/class.t3lib_div.php');
$preferences = array('scheme'=>'Q', 'input-charset'=>'iso-8859-1', 'output-charset'=>'iso-8859-1');
echo ( iconv_mime_encode( 'subject', $headerline2, $preferences ) );
// subject: =?iso-8859-1?Q?Is=20this=20line=20wrong=3F=20No!?=
echo ( t3lib_div::encodeHeader(  $headerline1, 'quoted-printable', 'iso-8859-1 ) );
// Is this line wrong? Yes!
?>
Actions #5

Updated by Martin Kutschker almost 17 years ago

IMHO there is no need to quote all occurences of ? and =. iconv_mime_encode() is overeager. Why should a standalone ? be quoted? What MUST be quoted is a starting sequence of =?. t3lib_div::encodedHeader() fails in fact to do so.

As = is correctly quoted for quoted-printable nothing needs to be done here.

So it is sufficient to trigger the encoding when a non ASCII character is found or the string contains a =? sequence. Change the check at the top of t3lib_div::encodedHeader() like this:

if (!preg_match('/[^'.chr(32).'-'.chr(127).']/',$line) && ($enc=='base64' || strpos($line,'=?')===FALSE)) return $line;

Note that the header will not be encoded at all if it contains ###!

Actions #6

Updated by Alexander Opitz almost 11 years ago

  • Category deleted (Communication)
  • Status changed from New to Needs Feedback
  • Target version deleted (0)

The issue is very old, does this issue exists in newer versions of TYPO3 CMS (4.5 or 6.1)?

Actions #7

Updated by Alexander Opitz over 10 years ago

  • Status changed from Needs Feedback to Closed

No feedback for over 90 days.

Actions

Also available in: Atom PDF