Re: [PATCH] Bug #43896 htmlspecialchars returns empty stringoninvalid unicode sequence
| From: | Xuefer | Date: | Wed, 06 Feb 2008 04:01:11 +0000 |
| Subject: | Re: [PATCH] Bug #43896 htmlspecialchars returns empty stringoninvalid unicode sequence | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-35223@lists.php.net to get a copy of this message | ||
> iconv() will stop on conversion error and return partial string or empty
> string. It will require even more complex code than 5.2.5
> htmlspecialchars() does. With htmlspecialchars you check for empty string
> before and after the call. With iconv you check for php errors during
> iconv call.
the current impl of iconv() wrap in php is a pain in the @$$, i can
only get truncated string if there's some invalid char, or rely on
glibc "//IGNORE" flag. "string".encode() in python is much better that
u can with 'ignore', 'replace', 'xmlcharrefreplace',
'backslashreplace' as the 2nd param of encode()
i agree that ignoring the invalid char in "all case" is not good, but
truncating in all case isn't either. there're some case acceptable
like user post -> server accept it, ignoring invalid chars -> and user
have chance to review his text later.
too bad that the conversation implicit like __set/__get that you can't
add one more optional paramter. hope there's some nice way to get this
problem done.