r78888 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78887‎ | r78888 | r78889 >
Date:14:27, 23 December 2010
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Added removal of comments from XML before parsing
Modified paths:
  • /trunk/extensions/ExternalData/ED_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExternalData/ED_Utils.php
@@ -207,6 +207,10 @@
208208 global $edgXMLValues;
209209 $edgXMLValues = array();
210210
 211+ // Remove comments from XML - for some reason, xml_parse()
 212+ // can't handle them.
 213+ $xml = preg_replace( '/<!--.*?-->/', '', $xml );
 214+
211215 $xml_parser = xml_parser_create();
212216 xml_set_element_handler( $xml_parser, array( 'EDUtils', 'startElement' ), array( 'EDUtils', 'endElement' ) );
213217 xml_set_character_data_handler( $xml_parser, array( 'EDUtils', 'getContent' ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r78930Follow-up to r78888 - added "/s" modifier to preg_replace(), to allow for mul...yaron22:05, 23 December 2010

Comments

#Comment by Zakgreant (talk | contribs)   17:51, 23 December 2010

Can the comments span multiple lines? If so, the regex probably needs to have the /s flag applied.

#Comment by Yaron Koren (talk | contribs)   22:04, 23 December 2010

Hi, indeed, that's true! I was going to put that in, but then forgot about it. Thanks for the note.

Status & tagging log