php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27505 htmlentities fail to escape BIG5 characters correctly
Submitted: 2004-03-05 03:43 UTC Modified: 2004-03-06 13:27 UTC
From: ywliu at hotmail dot com Assigned:
Status: Closed Package: *Languages/Translation
PHP Version: 4.3.4 OS: linux
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:
MUST BE VALID
Solve the problem:
38 - 14 = ?
Subscribe to this entry?

 
 [2004-03-05 03:43 UTC] ywliu at hotmail dot com
Description:
------------
In ext/standard/html.c , htmlentities() fails to identify BIG5 Chinese characters correctly.

I have checked CVS version 1.87, the bug is still there.

Reproduce code:
---------------
In html.c, look for this piece of code :

case cs_big5:
case cs_gb2312:
case cs_big5hkscs:
    {
	/* check if this is the first of a 2-byte sequence */
	if (this_char >= 0xa1 && this_char <= 0xf9) {
	/* peek at the next char */
	unsigned char next_char = str[pos];
		if ((next_char >= 0x40 && next_char <= 0x73) ||(next_char >= 0xa1 && next_char <= 0xfe)) {
			

Expected result:
----------------
In fact, the first byte should be from 0xa1 to 0xfe, and the second byte should be from 0x40-0x7e and 0xa1-0xfe.

(from page 88, "Understanding Japanese Information Processing" by Ken Lunde , O'Reilly.)

Actual result:
--------------
So it should be :

	if (this_char >= 0xa1 && this_char <= 0xfe) {

and 

		if ((next_char >= 0x40 && next_char <= 0x7e) ||(next_char >= 0xa1 && next_char <= 0xfe)) {
			

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-06 13:27 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC