|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11244 Reversed '[]{}<>' in hebrev, hebrevc
Submitted: 2001-06-01 16:30 UTC Modified: 2002-03-26 02:57 UTC
Avg. Score:2.7 ± 1.7
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: php2eran at tromer dot org Assigned:
Status: Closed Package: *Languages/Translation
PHP Version: 4.0.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
43 + 1 = ?
Subscribe to this entry?

 [2001-06-01 16:30 UTC] php2eran at tromer dot org
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).
***        Fri Jun  1 22:55:21 2001
--- string.c    Fri Jun  1 22:56:38 2001
*** 2387,2392 ****
--- 2387,2410 ----
                                        case ')':
                                                *target = '(';
+                                       case '[':
+                                               *target = ']';
+                                               break;
+                                       case ']':
+                                               *target = '[';
+                                               break;
+                                       case '<':
+                                               *target = '>';
+                                               break;
+                                       case '>':
+                                               *target = '<';
+                                               break;
+                                       case '{':
+                                               *target = '}';
+                                               break;
+                                       case '}':
+                                               *target = '{';
+                                               break;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-26 02:57 UTC]
Fixed in CVS.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 29 10:03:35 2022 UTC