Changeset 24902 for trunk/wp-includes/class-oembed.php
- Timestamp:
- 07/30/2013 09:57:27 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-oembed.php
r24480 r24902 222 222 */ 223 223 function _parse_xml( $response_body ) { 224 if ( !function_exists('simplexml_load_string') ) {225 return false;226 }227 224 if ( ! function_exists( 'libxml_disable_entity_loader' ) ) 228 225 return false; 229 226 230 227 $loader = libxml_disable_entity_loader( true ); 231 232 228 $errors = libxml_use_internal_errors( true ); 233 $data = simplexml_load_string( $response_body ); 229 230 $return = $this->_parse_xml_body( $response_body ); 231 234 232 libxml_use_internal_errors( $errors ); 235 236 $return = false;237 if ( is_object( $data ) ) {238 $return = new stdClass;239 foreach ( $data as $key => $value ) {240 $return->$key = (string) $value;241 }242 }243 244 233 libxml_disable_entity_loader( $loader ); 234 235 return $return; 236 } 237 238 /** 239 * Helper function for parsing an XML response body. 240 * 241 * @since 3.6.0 242 * @access private 243 */ 244 private function _parse_xml_body( $response_body ) { 245 if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument' ) ) 246 return false; 247 248 $dom = new DOMDocument; 249 $success = $dom->loadXML( $response_body ); 250 if ( ! $success ) 251 return false; 252 253 if ( isset( $dom->doctype ) ) 254 return false; 255 256 foreach ( $dom->childNodes as $child ) { 257 if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType ) 258 return false; 259 } 260 261 $xml = simplexml_import_dom( $dom ); 262 if ( ! $xml ) 263 return false; 264 265 $return = new stdClass; 266 foreach ( $xml as $key => $value ) { 267 $return->$key = (string) $value; 268 } 269 245 270 return $return; 246 271 }
Note: See TracChangeset
for help on using the changeset viewer.