Skip to content
Snippets Groups Projects
Commit 39ede986 authored by Andrew Dolgov's avatar Andrew Dolgov
Browse files

experimental: decode numerical utf entities on import in entry title

parent 258068b3
No related branches found
No related tags found
No related merge requests found
......@@ -553,6 +553,7 @@
_debug("date $entry_timestamp [$entry_timestamp_fmt]", $debug_enabled);
$entry_title = html_entity_decode($item->get_title(), ENT_COMPAT, 'UTF-8');
$entry_title = decode_numeric_entities($entry_title);
$entry_link = rewrite_relative_url($site_url, $item->get_link());
......@@ -1388,4 +1389,15 @@
_debug("Cleaned $rc cached tags.");
}
function utf8_entity_decode($entity){
$convmap = array(0x0, 0x10000, 0, 0xfffff);
return mb_decode_numericentity($entity, $convmap, 'UTF-8');
}
function decode_numeric_entities($body) {
$body = preg_replace('/&#\d{2,5};/ue', "utf8_entity_decode('$0')", $body );
$body = preg_replace('/&#x([a-fA-F0-7]{2,8});/ue', "utf8_entity_decode('&#'.hexdec('$1').';')", $body );
return $body;
}
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment