php.net |  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
Votes:3
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php2eran at tromer dot org
New email:
PHP Version: OS:

 

 [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).
---------------------------------------------
*** 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;
                                }
---------------------------------------------

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-26 02:57 UTC] mfischer@php.net
Fixed in CVS.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Feb 26 07:01:26 2020 UTC