Opened 4 years ago
Closed 4 years ago
#9616 closed defect (bug) (fixed)
Trunk throws warnings on php4 sites
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 2.8 |
| Component: | Warnings/Notices | Version: | 2.8 |
| Severity: | blocker | Keywords: | has-patch needs-testing dev-feedback |
| Cc: |
Description
On my customer's site, it was due to the RSS widgets grabbing eBay feeds. But there are other calls to html_entity_decode() around.
Symptom:
Trying to decode HTML entities into UTF-8 results in the following error message:
Warning: cannot yet handle MBCS in html_entity_decode()!
The line is repeated about 200 times, then html_entity_decode just uses ISO-8859-1 charset.
The related php bugs:
Also occurs in BB:
http://bbpress.org/forums/topic/warning-cannot-yet-handle-mbcs-in-html_entity_decode
Based on this thread, there is a potential fix:
Attachments (3)
Change History (10)
comment:1
Denis-de-Bernardy
— 4 years ago
- Keywords needs-patch dev-feedback added
comment:3
Denis-de-Bernardy
— 4 years ago
yeah, I'm aware, but wp is still supporting it. plus, it might fix your plugin too. ;-)
comment:4
ryan
— 4 years ago
- Component changed from General to Warnings/Notices
- Owner anonymous deleted
comment:5
Denis-de-Bernardy
— 4 years ago
Their implementation is in classes/core/String.inc.php, and goes like this:
function html2utf($str) {
// convert named entities to numeric entities
$str = strtr($str, String::getHTMLEntities());
// use PCRE-aware replace function to replace numeric entities
$str = String::regexp_replace('~&#x([0-9a-f]+);~ei', 'String::code2utf(hexdec("\\1"))', $str);
$str = String::regexp_replace('~&#([0-9]+);~e', 'String::code2utf(\\1)', $str);
return $str;
}
Side note: best I'm aware, strtr is not mb safe, so the above code is potentially buggy in mb languages.
Denis-de-Bernardy
— 4 years ago
comment:6
Denis-de-Bernardy
— 4 years ago
- Keywords has-patch needs-testing added; needs-patch removed
The code in the String.inc.php file might fix the issue as well...
http://core.trac.wordpress.org/attachment/ticket/9616/String.inc.php#L381
http://core.trac.wordpress.org/attachment/ticket/9616/String.inc.php#L487
http://core.trac.wordpress.org/attachment/ticket/9616/String.inc.php#L197
http://core.trac.wordpress.org/attachment/ticket/9616/String.inc.php#L323
... provided that this entity list is complete.
PHP4 has reached EOL.
You may want to read: http://lesterchan.net/wordpress/2008/06/09/warning-cannot-yet-handle-mbcs-in-html_entity_decode/