Commit e8265f07 authored by Steven Wittens's avatar Steven Wittens

- Bugfix: the XML parser in PHP4 requires you to specify the input encoding explicitly.

Added a short piece of code that does this.
(see drupal.org's Drupal Talk to see this bug in action)
parent 21a0e8b9
......@@ -325,8 +325,13 @@ 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):
if (ereg('encoding="([^"]+)"', $data, $match)) {
$encoding = $match[1];
}
// parse the data:
$xml_parser = xml_parser_create();
$xml_parser = xml_parser_create($encoding);
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");
......
......@@ -325,8 +325,13 @@ 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):
if (ereg('encoding="([^"]+)"', $data, $match)) {
$encoding = $match[1];
}
// parse the data:
$xml_parser = xml_parser_create();
$xml_parser = xml_parser_create($encoding);
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");
......
......@@ -325,8 +325,13 @@ 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):
if (ereg('encoding="([^"]+)"', $data, $match)) {
$encoding = $match[1];
}
// parse the data:
$xml_parser = xml_parser_create();
$xml_parser = xml_parser_create($encoding);
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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment