Argh, just remove all RTL and LTR control codes in bidi_cleanup.
If the name and subject fields both start with RLO characters, then the subject would be after the name with the old bidi_cleanup.
This commit is contained in:
parent
9b0c31daa6
commit
82e3592703
@ -214,7 +214,7 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bidi_cleanup($str){
|
function bidi_cleanup($str){
|
||||||
# Closes all embedded RTL and LTR unicode formatting blocks in a string so that
|
# Removes all embedded RTL and LTR unicode formatting blocks in a string so that
|
||||||
# it can be used inside another without controlling its direction.
|
# it can be used inside another without controlling its direction.
|
||||||
# More info: http://www.iamcal.com/understanding-bidirectional-text/
|
# More info: http://www.iamcal.com/understanding-bidirectional-text/
|
||||||
#
|
#
|
||||||
@ -228,21 +228,7 @@ function bidi_cleanup($str){
|
|||||||
$explicits = '\xE2\x80\xAA|\xE2\x80\xAB|\xE2\x80\xAD|\xE2\x80\xAE';
|
$explicits = '\xE2\x80\xAA|\xE2\x80\xAB|\xE2\x80\xAD|\xE2\x80\xAE';
|
||||||
$pdf = '\xE2\x80\xAC';
|
$pdf = '\xE2\x80\xAC';
|
||||||
|
|
||||||
$stack = 0;
|
$str = preg_replace("!(?<explicits>$explicits)|(?<pdf>$pdf)!", '', $str);
|
||||||
$str = preg_replace_callback("!(?<explicits>$explicits)|(?<pdf>$pdf)!", function($match) use (&$stack) {
|
|
||||||
if (isset($match['explicits']) && $match['explicits']) {
|
|
||||||
$stack++;
|
|
||||||
} else {
|
|
||||||
if ($stack)
|
|
||||||
$stack--;
|
|
||||||
else
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return $match[0];
|
|
||||||
}, $str);
|
|
||||||
for ($i=0; $i<$stack; $i++){
|
|
||||||
$str .= "\xE2\x80\xAC";
|
|
||||||
}
|
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user