|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-03-26 02:57 UTC] mfischer@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 23:00:01 2025 UTC |
There's a problem with the hebrev() and hebrevc() functions (PHP 4.0.5 and earlier). These functions convert logical Hebrew text to visual Hebrew text (generally by byte-reversing the blocks of Hebrew letters but not of English letters but there are a lot of gotchas). There's a problem in the handling of the characters '[', ']','{', '}', '<', '>': they come out reversed when they appear in a Hebrew block, compared to the logical-to-visual algorithm used in MSIE (tested: v5 and v5.5). Specifically, text entered using MSIE edit boxes and then hebrev()ed will have the reversal problem. Since MSIE is by far the most popular browser for Hebrew users (due to deficient Hebrew support in alternatives), this should be considered a bug. The problem would occur for the normal parenthesis '(' and ')' as well, but the current implementation of hebrev() handles this case specifically by exchanging these characters when in a Hebrew block. The same method will work for the '[]{}<>' characters. Note that since exchanging should be done only in Hebrew blocks, it cannot be easily done using the PHP code that calls hebrev() with guaranteed consistency. hebrev() and hebrevc() are implemented in php_hebrev in ext/standard/string.c. The following simple patch does the character exchanging described above. I've tested it extensively and it seems compatible with the MSIE algorithm. However, for backward compatibility it would be prudent to make this change in behavior only when instructed so via an optional parameter (sorry, I don't know how to implement this). --------------------------------------------- *** string.c.org Fri Jun 1 22:55:21 2001 --- string.c Fri Jun 1 22:56:38 2001 *************** *** 2387,2392 **** --- 2387,2410 ---- case ')': *target = '('; break; + case '[': + *target = ']'; + break; + case ']': + *target = '['; + break; + case '<': + *target = '>'; + break; + case '>': + *target = '<'; + break; + case '{': + *target = '}'; + break; + case '}': + *target = '{'; + break; default: break; } ---------------------------------------------