From 68a89c301e26d2109a57f9438c186cc84b8a758d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 12 Aug 2007 10:43:08 +0100 Subject: [PATCH] magpie: do some scrubbing on rss before parsing (patch from zoop@forums) --- functions.js | 4 +++- magpierss/rss_fetch.inc | 30 +++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/functions.js b/functions.js index 8a370d6b..f704c673 100644 --- a/functions.js +++ b/functions.js @@ -1541,7 +1541,9 @@ function infobox_callback() { var shadow = document.getElementById('infoBoxShadow'); if (box) { - new Draggable(shadow); + if (!is_safari()) { + new Draggable(shadow); + } box.innerHTML=xmlhttp.responseText; if (shadow) { diff --git a/magpierss/rss_fetch.inc b/magpierss/rss_fetch.inc index 695d3b69..dd475e31 100644 --- a/magpierss/rss_fetch.inc +++ b/magpierss/rss_fetch.inc @@ -279,6 +279,33 @@ function _fetch_remote_file ($url, $headers = "" ) { } +function _convert_entities ($string) { + # Source: http://www.w3.org/TR/REC-html40/sgml/entities.html + $html_entities = array( + " ", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", + "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", + "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", + "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", + "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", + "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", + "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", + "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", + "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", + "ú", "û", "ü", "ý", "þ", "ÿ",); + $numeric_entities = array( + " ", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", + "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", + "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", + "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", + "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", + "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", + "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", + "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", + "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", + "ú", "û", "ü", "ý", "þ", "ÿ"); + return str_replace($html_entities, $numeric_entities, $string); +} + /*=======================================================================*\ Function: _response_to_rss Purpose: parse an HTTP response object into an RSS object @@ -286,7 +313,8 @@ function _fetch_remote_file ($url, $headers = "" ) { Output: parsed RSS object (see rss_parse) \*=======================================================================*/ function _response_to_rss ($resp) { - $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); + $converted_source = _convert_entities(mb_convert_encoding($resp->results, "UTF-8", mb_detect_encoding($resp->results))); + $rss = new MagpieRSS( $converted_source, MAGPIE_OUTPUT_ENCODING, "UTF-8", false); // if RSS parsed successfully if ( $rss and !$rss->ERROR) { -- 2.39.5