#23192 [Opn->Asn]: mb_encode_mimeheader mangles long lines?
| From: | moriyoshi@php.net | Date: | Thu, 17 Apr 2003 02:11:28 +0000 |
| Subject: | #23192 [Opn->Asn]: mb_encode_mimeheader mangles long lines? | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969352627@lists.php.net to get a copy of this message | ||
ID: 23192
Updated by: moriyoshi@php.net
Reported By: jc at mega-bucks dot co dot jp
-Status: Open
+Status: Assigned
Bug Type: Documentation problem
Operating System: Red Hat Linux 8.0
PHP Version: 4.3.2RC1
-Assigned To:
+Assigned To: moriyoshi
New Comment:
Yep, you are always welcome; but I'd rather to see your mb reports such
as this one at the php-i18n list first than at the bug database..
Previous Comments:
------------------------------------------------------------------------
[2003-04-16 20:45:26] jc at mega-bucks dot co dot jp
Thanks. Should I also submit a documentation bug then concerning
mb_encode_mimeheader()?
I'll try out your solution. But what is "HTML-ENTITIES"? I cannot find
any mention of that in the mb_string documenation?
------------------------------------------------------------------------
[2003-04-16 20:36:01] moriyoshi@php.net
Hmm, yes, you are right and this is absolutely a problem that is caused
by lack of words in the misleading documentation.
Besides I forgot to append the correct diagnosis of this problem.
mb_encode_mimeheader() can only deal with the most basic elements of
strings. That is, it simply treats such a charcter that is represented
by a numeric html entity as separate components.
Therefore if line folding is done in the middle of a entity compounded
of several characters, it inserts CRLF & space there and ends up
cluttering the structure of the html entity.
To avoid this, you have to do the following conversion on the string
before passing it to mb_encode_mimeheader()
$subject = mb_convert_encoding($subject, "ISO-2022-JP",
"HTML-ENTITIES");
var_dump($subject);
var_dump(mb_encode_mimeheader($subject, "ISO-2022-JP", "B"));
------------------------------------------------------------------------
[2003-04-16 20:14:04] jc at mega-bucks dot co dot jp
Oh, and you said:
>Although mb_send_mail() seems to resolve your problem
How does mb_send_mail() seem to solve my problem? I cannot find
anything in mb_send_mail() documentation that says it will act
differently than mb_encode_mimeheader(). But it does solve the problem
I will certainly use it :)
------------------------------------------------------------------------
[2003-04-16 19:51:33] jc at mega-bucks dot co dot jp
>Please double-check the documentation
Ok,
#1 I can't find anywhere in the docs that say that
mb_encode_mimeheader() follows RFC2047.
#2 Just becuase it follows RFC2047 doesn't say anything about how
mb_encode_mimeheader() treats lines that are too long. Nowhere in the
documentation does it say that mb_encode_mimeheader() truncates lines
...
#3 Since the documentation doesn't say anything I had assumed that
mb_encode_mimeheader() would trim correctly convert strings that are
too long into "CRLF space" encoded words. Is this right? If so it
should be added to the documentation
#4 It seems that mb_encode_mimeheader() *did* correctly detect that my
headers line was too long and did split the header properly. *However*
the subject was garbled when my mail reader put it back together. I am
assuming this is because the string is double-byte and
mb_encode_mimeheader() cut the string *inside* a double-byte. If this
is the case then I would consider *that* a bug.
I'm not conversant in double-byte characters ... Did
mb_encode_mimeheader() incorrectly cut the string inside a double-byte
character?
------------------------------------------------------------------------
[2003-04-16 15:50:13] moriyoshi@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Although mb_send_mail() seems to resolve your problem, the behaviour is
quite by design.
mb_encode_mimeheader is implemented in accordance with section 2
("Syntax of encoded-words") of
RFC2047(http://www.ietf.org/rfc/rfc2047.txt).
---------------------------------------------------------
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.
While there is no limit to the length of a multiple-line header
field, each line of a header field that contains one or more
'encoded-word's is limited to 76 characters.
--------------------------------------------------------- EOQ
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/23192
--
Edit this bug report at http://bugs.php.net/?id=23192&edit=1