diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2003-12-30 05:58:17 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2003-12-30 05:58:17 +0000 |
commit | e8265f07592937f149d0b1e4ba78898b71b86d10 (patch) | |
tree | 0c3aa91915da1b48daa6a105636d4cdc2124f0d9 /modules | |
parent | 21a0e8b904274aa3f31c60b4b4ec31f52f248ded (diff) | |
download | brdo-e8265f07592937f149d0b1e4ba78898b71b86d10.tar.gz brdo-e8265f07592937f149d0b1e4ba78898b71b86d10.tar.bz2 |
- 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)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/aggregator.module | 7 | ||||
-rw-r--r-- | modules/aggregator/aggregator.module | 7 | ||||
-rw-r--r-- | modules/import.module | 7 |
3 files changed, 18 insertions, 3 deletions
diff --git a/modules/aggregator.module b/modules/aggregator.module index fc6012319..be29a8995 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -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"); diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index fc6012319..be29a8995 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -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"); diff --git a/modules/import.module b/modules/import.module index fc6012319..be29a8995 100644 --- a/modules/import.module +++ b/modules/import.module @@ -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"); |