summaryrefslogtreecommitdiff
path: root/modules/aggregator.module
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2004-01-06 12:09:42 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2004-01-06 12:09:42 +0000
commitb817bdb302050195881ce501dd98cacde651494f (patch)
tree4376250981cd62ceed9b1b9503b7a64537fb46ce /modules/aggregator.module
parent7cf848279ceec2f8870fe80f4be6343c37528f1e (diff)
downloadbrdo-b817bdb302050195881ce501dd98cacde651494f.tar.gz
brdo-b817bdb302050195881ce501dd98cacde651494f.tar.bz2
- Improved XML encoding fix. There is now a function drupal_xml_parser_create():
/** * Wrapper around xml_parser_create() which extracts the encoding from the XML * data first and sets the output encoding to UTF-8. This function should be * used instead of xml_parser_create(), because PHP's XML parser doesn't check * the input encoding itself. * * This is also where unsupported encodings should be converted. * Callers should take this into account: $data might have been changed after * the call. * * @param $data The XML data which will be parsed later. */
Diffstat (limited to 'modules/aggregator.module')
-rw-r--r--modules/aggregator.module9
1 files changed, 1 insertions, 8 deletions
diff --git a/modules/aggregator.module b/modules/aggregator.module
index aed065eaf..eccd80ad0 100644
--- a/modules/aggregator.module
+++ b/modules/aggregator.module
@@ -325,17 +325,10 @@ function import_refresh($feed) {
return t("failed to parse RSS feed '%site': suspicious input data.", array("%site" => $feed["title"]));
}
- // extract the XML file's encoding (the XML parser in PHP4 doesn't do this by itself):
- $encoding = 'utf-8';
- if (ereg('^<\?xml[^>]+encoding="([^"]+)"', $data, $match)) {
- $encoding = $match[1];
- }
-
// parse the data:
- $xml_parser = xml_parser_create($encoding);
+ $xml_parser = drupal_xml_parser_create($data);
xml_set_element_handler($xml_parser, "import_element_start", "import_element_end");
xml_set_character_data_handler($xml_parser, "import_element_data");
- xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, "utf-8");
if (!xml_parse($xml_parser, $data, 1)) {
return t("failed to parse RSS feed '%site': %error at line %line.", array("%site" => $feed["title"], "%error" => xml_error_string(xml_get_error_code($xml_parser)), "%line" => xml_get_current_line_number($xml_parser)));