php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50954 iconv_mime_encode fails in Q-encoding
Submitted: 2010-02-07 14:15 UTC Modified: 2010-05-04 15:00 UTC
From: hiroaki dot kawai at gmail dot com Assigned:
Status: Duplicate Package: ICONV related
PHP Version: 5.2.12 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hiroaki dot kawai at gmail dot com
New email:
PHP Version: OS:

 

 [2010-02-07 14:15 UTC] hiroaki dot kawai at gmail dot com
Description:
------------
iconv_mime_encode fails Q-encoding when encoding non-ascii chars, 
which case is very common. This problem does not happen if line-length 
is long enough to hold the encoded string in a single line. 

The code use unsigned int to capture expected byte. In Q-encoding, the 
value is goes to negative value (at iconv.c line 1295), and fails 
separating the value into multiple lines.

Patch as following:
===============================
--- iconv.c.orig	2008-12-31 20:17:49.000000000 +0900
+++ iconv.c	2010-02-07 11:01:54.436000000 +0900
@@ -1217,7 +1217,7 @@
 				prev_in_left = ini_in_left = in_left;
 				ini_in_p = in_p;
 
-				for (out_size = char_cnt; out_size > 
0;) {
+				for (out_size = (char_cnt-2)/3; 
out_size > 0;) {
 					size_t prev_out_left;
 
 					nbytes_required = 0;


Reproduce code:
---------------
<?php
ini_set('error_reporting',E_ALL);
echo iconv_mime_encode('a',"\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88",array('output-charset'=>'UTF-8','input-charset'=>'UTF-8','scheme'=>'Q','line-length'=>30));


Expected result:
----------------
a: =?UTF-8?Q?=E3=83=86?=
 =?UTF-8?Q?=E3=82=B9?=
 =?UTF-8?Q?=E3=83=88?=
 =?UTF-8?Q?=E3=83=86?=
 =?UTF-8?Q?=E3=82=B9?=
 =?UTF-8?Q?=E3=83=88?=

Actual result:
--------------
Notice: iconv_mime_encode(): Unknown error (7) in /home/hawk/hoge.php on 
line 3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-07 17:37 UTC] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #48289
 [2010-02-08 00:22 UTC] hiroaki dot kawai at gmail dot com
I'm not sure this is a dup of #48289 because I could not reproduce the 
test case. So I created a separete report. If you are sure this is a dup 
of #48289, please mark this as "Duplicate" not "Bogus". Bogus means "the 
report was not a bug at last".
 [2010-04-29 20:58 UTC] softex at kaliningrad dot ru
I have the same problem using non-ascii characters in second argument of the function. 

When to expect this patch to be included in new release?
 [2010-05-04 13:12 UTC] softex at kaliningrad dot ru
This function does not work in Base64 mode too using utf-8 charset.
 [2010-05-04 13:52 UTC] aharvey@php.net
-Status: Bogus +Status: Duplicate
 [2010-05-04 13:52 UTC] aharvey@php.net
It does indeed look like a dupe. Changing the status accordingly.
 [2010-05-04 14:34 UTC] softex at kaliningrad dot ru
This function add also space character to the each wrapped line
 [2010-05-04 15:00 UTC] aharvey@php.net
The spaces aren't a bug; that's part of the folding behaviour specified in section 2.2.3 of RFC 5322.

Also, even if they were a bug, they'd be a separate issue. This is now closed. :)
 [2013-07-25 21:00 UTC] janymodric150 at gmail dot com
My name is Janifer modric and I base in USA...“My life is back!!! After 14 years of Broken marriage, my husband left me and our two twins . I felt like my life was about to end i almost commited suicide, i was emotionally down for a very long time. Thanks to a spell caster called Dr Zula which i met online. On one faithful day, as I was browsing through the internet, I was searching for a good spell caster that can solve my problems. I came across alot of testimonies about this particular spell caster. Some people testified that he brought their Ex lover back, some testified that he restores womb,cure cancer,and other sickness, some testified that he can cast a spell to stop divorce and so on. i also come across one particular testimony,it was about a woman called sonia,she testified about how Dr Zula brought back her Ex lover in less than 7 days and reverse the effect of their little boys cancer, and at the end of her testimony she dropped Dr. Zula 's e-mail address. After reading all these,I decided to give Dr Zula a try. I contacted him via email and explained my problem to him. In just 3 days, my husband came back to me. We solved our issues, and we are evenhappier than before. Dr Zula is really a gifted man and i will not stop publishing him because he is a wonderful man... If you have a problem and you are looking for a real and genuine spell caster to solve all your problems for you. Try Dr Zula anytime, he might be the answer to your problems. Here's his contact:{odumagadaspiritualtemple@hotmail.com}.or by phone :+2348155983287 Thank you Dr Zula
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC