MantisBT

View Issue Details Jump to Notes ] Wiki ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008572mantisbtlocalizationpublic2007-11-12 18:322009-06-23 15:26
Reporterjanusz 
Assigned Tojreese 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version1.1.0rc2 
Target Version1.1.3Fixed in Version1.2.0rc1 
Summary0008572: multibyte str pad problem
DescriptionMantis sends report e-mails with utf-8 encoding with correct utf-8 strings, but uses simple str_pad to padding fields which contains multi byte charaters, but it doesn't work correctly.

To solve this bug add mb_str_pad implementation from http://hu.php.net/manual/en/function.str-pad.php#71558 [^] to email_api.php, and change all str_pad to mb_str_pad.

I tested it, and it's work correctly.
Tagspatch
Attached Files

- Relationships
has duplicate 0008798closedryandesign wrong alignment in email if using german umlaut 
has duplicate 0007669closed [all lang] Email field padding is not working correctly when using multibyte encodings 
child of 0010303closedjreese Create and use string_api wrappers for multibyte string functions 

-  Notes
User avatar (0016472)
janusz (reporter)
2007-12-20 07:32

any chance to fix it in 1.1.1
User avatar (0016479)
vboctor (administrator)
2007-12-20 12:01

Set target release to 1.1.1.
User avatar (0017134)
combr (reporter)
2008-02-21 04:04
edited on: 2008-02-21 04:06

I have such problem, 1.1.1 version
may be demonstrated like this:
(russian letters replaced by questions?? )

$g_email_padding_length = 28;

1. only numbers: (new line at 28)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31 32 33 34 35 36 37 38 39 40

2. numbers + letters (russian and latin), without patch
(new line at 25 with russian and 26 with english)
? ? ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

G G G 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
27 28 29 30 31 32 33 34 35 36 37 38 39 40

3. the same with patch from here and str_pad replaced with mb_str_pad
(same result as without patch)

? ? ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

G G G 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
27 28 29 30 31 32 33 34 35 36 37 38 39 40

---------------

when lines contain many russian letters, email formatted like this:

????? ???????? ??????? ??????? ?
?????????????? ???????????? ? ???????
?? mantis.
??????????? ????????????? ? ???????
????? ???????.
 
how i can format it as "only numbers" width?

User avatar (0017139)
combr (reporter)
2008-02-21 05:23
edited on: 2008-02-25 04:57

my comment related to body of added notes, not to header... maybe it is another bug.

but as I can see, it's related with WrapText() in phpmailer function bug.

see:
in email_api.php
    $mail->WordWrap = 80; # set word wrap to 50 characters (funny,
edit the comment too ;)

in class.phpmailer.php
    $this->Body = $this->WrapText($this->Body, $this->WordWrap);

try to set $mail->WordWrap = 120; or $mail->WordWrap = 0; - same view, no effect

User avatar (0017193)
combr (reporter)
2008-02-25 04:54

make a workaround :

--- email_api.php.orig 2008-02-25 12:51:51.000000000 +0300
+++ email_api.php 2008-02-25 12:46:26.000000000 +0300
@@ -1080,7 +1080,8 @@

- $t_message .= wordwrap( $t_bugnote->note ) . " \n\n";
+ $t_message .= $t_bugnote->note . " \n\n";

------------------

wordwrap() function need to be reworked with utf8 in mind
User avatar (0017630)
cheater (reporter)
2008-04-21 09:00

... also the function "email_format_attribute()"
The issue 0008798 is a result of the function email_format_attribute()
The german expression of priority is "Priorät" and the alignment in this row is wrong (see screenshot).

These are the two issues in my opinion!
User avatar (0019139)
combr (reporter)
2008-08-13 04:34
edited on: 2008-08-13 08:19

in 1.1.2, i meet the same problem with wrap text in email.
I expect this bug will resolved in 1.2.*?


I found alternative to function mb_str_pad from first post, it's utf8Wordwrap from http://ru.php.net/wordwrap [^] (comment at 28-May-2008 03:56)

with it, i need to replace only 2 call to wordwrap() to utf8wordwap().

maybe it's more simple than replace all calls to str_pad.

User avatar (0020178)
philipp-kempgen (reporter)
2008-12-01 22:01
edited on: 2008-12-01 22:03

I just happened to stumble across this page.
In case you're interested, here's what we use in "Gemeinschaft" (GNU GPL).
https://svn.amooma.com/gemeinschaft/trunk/opt/gemeinschaft/inc/mb_str_pad.php [^]
http://www.amooma.de/gemeinschaft/ [^]

if (! function_exists('mb_str_pad')) {
function mb_str_pad( $str, $len, $padstr=' ', $padtype=STR_PAD_RIGHT, $enc='' )
{
    if (! function_exists('mb_strlen'))
        return str_pad( $str, $len, $padstr, $padtype );
    
    if ($enc==='') $enc = mb_internal_encoding();
    $strlen = mb_strLen($str,$enc);
    $flen = $len - $strlen;
    if ($flen <= 0) return $str;
    $pad = str_repeat($padstr, $flen);
    
    switch ($padtype) {
    case STR_PAD_RIGHT:
        $pad = mb_subStr($pad, 0, $flen, $enc);
        return $str . $pad;
    case STR_PAD_LEFT:
        $pad = mb_subStr($pad, 0, $flen, $enc);
        return $pad . $str;
    case STR_PAD_BOTH:
        $flenh = $flen/2;
        $padl = mb_subStr($pad, 0, floor($flenh), $enc);
        $padr = mb_subStr($pad, 0, ceil($flenh), $enc);
        return $padl . $str . $padr;
    default:
        trigger_error('mb_str_pad(): Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH.', E_USER_WARNING);
        return null;
    }
}
}

User avatar (0020536)
olegos (reporter)
2009-01-05 01:55

Similar problem exists with Subjects of e-mails. For example this Subject is split into multiple lines incorrectly:

Subject: =?utf-8?B?W1JlYWx0b3ItT25saW5lIDAwMDAwMzRdOiDQl9Cw0L/RgNCw0YjQuNCy0LDQ?=
    =?utf-8?B?tdC80L7Qs9C+INGE0LDQudC70LAg0L3QtSDRgdGD0YnQtdGB0YLQstGD0LXR?=
    =?utf-8?B?giDQuNC70Lgg0L7QvSDQvdC10LTQvtGB0YLRg9C/0LXQvQ==?=


(reported in http://www.mantisbt.org/forums/viewtopic.php?f=3&t=6522 [^] )
User avatar (0022172)
jreese (reporter)
2009-06-15 10:11

Fixed via issue 0010303 implementing multibyte-aware string functions.

- Issue History
Date Modified Username Field Change
2007-11-12 18:32 janusz New Issue
2007-11-13 02:51 vboctor Target Version => 1.1.0rc3
2007-12-20 07:32 janusz Note Added: 0016472
2007-12-20 12:01 vboctor Note Added: 0016479
2007-12-20 12:01 vboctor Target Version 1.1.0rc3 => 1.1.1
2008-01-14 10:15 vboctor Target Version 1.1.1 => 1.1.x
2008-02-21 04:04 combr Note Added: 0017134
2008-02-21 04:06 combr Note Edited: 0017134
2008-02-21 04:39 ryandesign Relationship added has duplicate 0008798
2008-02-21 05:23 combr Note Added: 0017139
2008-02-25 04:54 combr Note Added: 0017193
2008-02-25 04:57 combr Note Edited: 0017139
2008-04-21 09:00 cheater Note Added: 0017630
2008-07-13 15:29 vboctor Status new => acknowledged
2008-07-13 15:29 vboctor Category email => localization
2008-07-13 15:30 vboctor Tag Attached: patch
2008-08-05 10:33 jreese Target Version 1.1.x => 1.1.3
2008-08-13 04:34 combr Note Added: 0019139
2008-08-13 08:19 combr Note Edited: 0019139
2008-12-01 22:01 philipp-kempgen Note Added: 0020178
2008-12-01 22:03 philipp-kempgen Note Edited: 0020178
2009-01-05 01:55 olegos Note Added: 0020536
2009-06-11 06:32 siebrand Relationship added has duplicate 0007669
2009-06-11 10:43 siebrand Relationship added child of 0010303
2009-06-15 10:11 jreese Note Added: 0022172
2009-06-15 10:11 jreese Status acknowledged => resolved
2009-06-15 10:11 jreese Fixed in Version => 1.2.2
2009-06-15 10:11 jreese Resolution open => fixed
2009-06-15 10:11 jreese Assigned To => jreese
2009-06-23 15:26 jreese Status resolved => closed


MantisBT 1.2.17 [^]
Copyright © 2000 - 2014 MantisBT Team
Time: 0.1110 seconds.
memory usage: 3,106 KB
Powered by Mantis Bugtracker