换空间之后,用WLW远程发布日志时,出现问题:html标签处理不当(<>&等三个符号显示不出来),Google了一下原因,才知道是一个处理XML的函式库libxml2出了问题。新克蘭德已经给出了解决办法,按照此办法修改相关页面后,问题解决。把办法转在这里,以后升级WP时备查。
方法简述:
修改下述三个php文件里面的一个function (注意各人文件内容不尽相同)
- /wp-admin/import/blogger.php — function parse($xml)
- /wp-includes/rss.php — function MagpieRSS ($source)
- /wp-includes/class-IXR.php — function parse()
依照下面的方式修改:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // /wp-admin/import/blogger.php 913-935 //----------------------------------------------- function parse($xml) { <a href="http://www.php.net/global">global</a> $app_logging; <a href="http://www.php.net/array_unshift">array_unshift</a>($this->ns_contexts, <a href="http://www.php.net/array">array</a>()); $parser = <a href="http://www.php.net/xml_parser_create_ns">xml_parser_create_ns</a>(); <a href="http://www.php.net/xml_set_object">xml_set_object</a>($parser, $this); <a href="http://www.php.net/xml_set_element_handler">xml_set_element_handler</a>($parser, "start_element", "end_element"); <a href="http://www.php.net/xml_parser_set_option">xml_parser_set_option</a>($parser,XML_OPTION_CASE_FOLDING,0); <a href="http://www.php.net/xml_parser_set_option">xml_parser_set_option</a>($parser,XML_OPTION_SKIP_WHITE,0); <a href="http://www.php.net/xml_set_character_data_handler">xml_set_character_data_handler</a>($parser, "cdata"); <a href="http://www.php.net/xml_set_default_handler">xml_set_default_handler</a>($parser, "_default"); <a href="http://www.php.net/xml_set_start_namespace_decl_handler">xml_set_start_namespace_decl_handler</a>($parser, "start_ns"); <a href="http://www.php.net/xml_set_end_namespace_decl_handler">xml_set_end_namespace_decl_handler</a>($parser, "end_ns"); $contents = ""; //xmllib 2.7.0 -2.7.3 stripping leading angle brackets bug patch $xml =<a href="http://www.php.net/str_replace">str_replace</a>("&lt;","&#60;",$xml ); $xml =<a href="http://www.php.net/str_replace">str_replace</a>("&gt;","&#62;",$xml ); $xml =<a href="http://www.php.net/str_replace">str_replace</a>("&amp;","&#38;",$xml ); //end Fix <a href="http://www.php.net/xml_parse">xml_parse</a>($parser, $xml); <a href="http://www.php.net/xml_parser_free">xml_parser_free</a>($parser); return true; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | // /wp-includes/rss.php 49-90 //----------------------------------------------- function MagpieRSS ($source) { # if PHP xml isn't compiled in, die # if ( !<a href="http://www.php.net/function_exists">function_exists</a>('xml_parser_create') ) <a href="http://www.php.net/trigger_error">trigger_error</a>( "Failed to load PHP's XML Extension.http://www.php.net/manual/en/ref.xml.php" ); $parser = @<a href="http://www.php.net/xml_parser_create">xml_parser_create</a>(); if ( !<a href="http://www.php.net/is_resource">is_resource</a>($parser) ) <a href="http://www.php.net/trigger_error">trigger_error</a>( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php"); $this->parser = $parser; # pass in parser, and a reference to this object # setup handlers # <a href="http://www.php.net/xml_set_object">xml_set_object</a>( $this->parser, $this ); <a href="http://www.php.net/xml_set_element_handler">xml_set_element_handler</a>($this->parser, 'feed_start_element', 'feed_end_element' ); <a href="http://www.php.net/xml_set_character_data_handler">xml_set_character_data_handler</a>( $this->parser, 'feed_cdata' ); //xmllib 2.7.0 -2.7.3 stripping leading angle brackets bug patch $source =<a href="http://www.php.net/str_replace">str_replace</a>("&lt;","&#60;",$source ); $source =<a href="http://www.php.net/str_replace">str_replace</a>("&gt;","&#62;",$source ); $source =<a href="http://www.php.net/str_replace">str_replace</a>("&amp;","&#38;",$source ); //end fix $status = <a href="http://www.php.net/xml_parse">xml_parse</a>( $this->parser, $source ); if (! $status ) { $errorcode = <a href="http://www.php.net/xml_get_error_code">xml_get_error_code</a>( $this->parser ); if ( $errorcode != XML_ERROR_NONE ) { $xml_error = <a href="http://www.php.net/xml_error_string">xml_error_string</a>( $errorcode ); $error_line = <a href="http://www.php.net/xml_get_current_line_number">xml_get_current_line_number</a>($this->parser); $error_col = <a href="http://www.php.net/xml_get_current_column_number">xml_get_current_column_number</a>($this->parser); $errormsg = "$xml_error at line $error_line, column $error_col"; $this->error( $errormsg ); } } <a href="http://www.php.net/xml_parser_free">xml_parser_free</a>( $this->parser ); $this->normalize(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | // /wp-includes/class-IXR.php 159-185 //----------------------------------------------- function parse() { // first remove the XML declaration $this->message = <a href="http://www.php.net/preg_replace">preg_replace</a>('/<\?xml(.*)?\?'.'>/', '', $this->message); if (<a href="http://www.php.net/trim">trim</a>($this->message) == '') { return false; } $this->_parser = <a href="http://www.php.net/xml_parser_create">xml_parser_create</a>(); // Set XML parser to take the case of tags in to account <a href="http://www.php.net/xml_parser_set_option">xml_parser_set_option</a>($this->_parser, XML_OPTION_CASE_FOLDING, false); // Set XML parser callback functions <a href="http://www.php.net/xml_set_object">xml_set_object</a>($this->_parser, $this); <a href="http://www.php.net/xml_set_element_handler">xml_set_element_handler</a>($this->_parser, 'tag_open', 'tag_close'); <a href="http://www.php.net/xml_set_character_data_handler">xml_set_character_data_handler</a>($this->_parser, 'cdata'); //xmllib 2.7.0 -2.7.3 stripping leading angle brackets bug patch $this->message =<a href="http://www.php.net/str_replace">str_replace</a>("&lt;","&#60;",$this->message); $this->message =<a href="http://www.php.net/str_replace">str_replace</a>("&gt;","&#62;",$this->message); $this->message =<a href="http://www.php.net/str_replace">str_replace</a>("&amp;","&#38;",$this->message); //end fix if (!<a href="http://www.php.net/xml_parse">xml_parse</a>($this->_parser, $this->message)) { /* die(sprintf('XML error: %s at line %d', xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser))); */ return false; } <a href="http://www.php.net/xml_parser_free">xml_parser_free</a>($this->_parser); // Grab the error messages, if any if ($this->messageType == 'fault') { $this->faultCode = $this->params[0]['faultCode']; $this->faultString = $this->params[0]['faultString']; } return true; } |

