diff options
| author | Michael <savetheinternet@tinyboard.org> | 2013-07-15 21:59:24 -0700 |
|---|---|---|
| committer | Michael <savetheinternet@tinyboard.org> | 2013-07-15 21:59:24 -0700 |
| commit | 1cabad128211718c0cc2b2803ab487e655bb05b2 (patch) | |
| tree | 5813aae3fe52bdfdbb63d4e4bda8d3c5c9548661 | |
| parent | 230b5de16ed0e50843136efffdef85e7df8c91b1 (diff) | |
| parent | 82e3592703f50869d589839f7d4d1bf763852b51 (diff) | |
Merge pull request #121 from Macil/morertlfix
Remove all RTL and LTR control codes in bidi_cleanup.
| -rw-r--r-- | inc/display.php | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/inc/display.php b/inc/display.php index 5395edcc..2021dc8f 100644 --- a/inc/display.php +++ b/inc/display.php @@ -214,7 +214,7 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) { } 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. # 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'; $pdf = '\xE2\x80\xAC'; - $stack = 0; - $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"; - } + $str = preg_replace("!(?<explicits>$explicits)|(?<pdf>$pdf)!", '', $str); return $str; } |
