最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】通过WLW向WordPress发布帖子后,显示出来的内容却是html源码且HML的p标签被破坏掉了

WordPress crifan 3029浏览 0评论

【问题】

之前用wlw离线发布帖子到wordpress一直很正常。

刚刚遇到一个问题是:

wlw发布帖子后,结果wordpress网站中显示出来的内容却是html源码:

post-content-only-show-html-source

【解决过程】

1.以为是偶尔的异常呢,所以再次测试了一把,结果问题依旧:

test-result-is-same-html-source

2.之前的帖子,以为是用了自己的WLW的插件:PictureManager

thought-wlw-picture-manager-plugin

导致的,结果很明显不是。

3.想了想,最近,对于wordpress网站的更改,只有一个:

升级了“Contact Form 7”:

only-update-contact-form-7

难道是这个引起的?

所以去停用试试。

再次发布一个测试帖子看看是否还是会显示html源码,结果是问题依旧:

second-test-wlw-post-show-html

所以排除Contact Form 7的影响。

4.突然想到,不会是wordpress网站本身有问题吧?

所以去看了看别人,任意一个帖子,结果是可以正常显示内容,而非html代码的:

normal-post-show-content-not-html

5.这里:

Publishing posts from WLW to wordpress isnt working

貌似和我问题类似。但是无解。

6。现在问题比较明显了,就是:

wlw在发布帖子到wordpress的时候,就是把内容,变成了html源码。。。

所以,wordpress中,显示出来的,就是html源码,而不是内容。

7.难道是本地的wlw,被破坏了?

那么就去试试,清空当前账户:

for-wlw-account-delete

重新添加:

use-another-service

add-post-account

结果重新第三次测试,结果问题依旧。

8.然后去看了看帖子的内容,发现,原先内容中,在发布时,被加上了一个p标签。

显示出来的内容是:

third-test-still-html

本质上内部被加了p:

found-real-action-added-p-tag

所以导致结果只是显示出html代码了。

9.知道现象了,现在去找根本原因。

但是才发现,其实去掉开始和结束的p,结果也还是不正常了。。。

没法恢复真正的内容了。。。

因为其中的<>,都被过滤掉了。。。

对应的,和本地的wlw中的html源码比较一下,就可以看出上述规律了:

on-wlw-third-test-html-code

算了,现在暂时不折腾了。

等抽空换个电脑,再去测试wlw发布是否正常。。。。

10.然后换个电脑,结果第四次测试,问题依旧,还是会显示html源码。

11.想办法,看看能否用fiddler去调试一下,看看从wlw发送到自己的crifan.com的wordpress网站时,发送的数据,是否正确。

然后结果就是发现,第五次测试,wlw中的html是:

fifth test see wlw html

然后用fiddler抓取处理的信息是:

fiddler capter that send content is html

即,在wlw发送给wordpress网站之前的数据,就已经是去除掉了对应的html的tag了。

即,本身wlw中是:

<p>555</p>

<p>&#160;</p>

<p>撒个的考虑后果</p>

<p>撒高端客户</p>

就已经被处理成了:

p555/p p#160;/p p撒个的考虑后果/p p撒高端客户/p

所以,网页中才显示出对应的内容的:

fifth test post show html

所以,看来是怪wlw,而不是wordpress网站了。

12.但是还是有点没道理啊。

最近的wlw,我又没有更新。

而且不可能突然2台电脑中的本地已经安装的wlw,突然都出现同样问题啊。

13.想办法再去测试一下,本地wamp中已经安装的wordpress,让wlw也发布个帖子试试,是否有同样问题。

经过测试,本地的,之前就和在线的crifan.com的wordpress,内容和配置都一样的wordpress,然后是发帖正常的。

所以说明:

问题根本原因是:

在线的crifan.com的wordpress有问题,导致发帖后,显示出来的内容是html源码而不是内容。

所以,要抽空再去对比一样,在线的wordpress和本地的,哪里有差别,然后才能找到根本原因。

但是目前所能想到的是,就是最近1,2天,更新了在线的crifan.com中的哪些东西,所导致发帖异常的。

之前几天,都一直是正常的,wlw发帖都是可以正常显示内容的。

14.现在一点点去排除,看看是否是某个插件而导致的此问题:

无觅插件:不是;

Breadcrumb NavXT:不是;

Akismet,Audio player,Contact Form 7,Dagon Design Sitemap Generator,Google XML Sitemaps,Login LockDown,Revision Cleaner,UEditor,

WP-PostViews,

WP SyntaxHighlighter,

WPtouch:都禁止掉,看看效果。

结果也没效果,还是显示html。

看来就不是插件的问题。

15.后来看到:

Windows Live Writer issue and WordPress 2.6x

中有提到类似的问题:

For those who made a lot of helpful suggestion re. HTML and the Visual editor, this is a weird problem where WordPress displays _partial_ HTML instead of th desired human readble form. In other words, a paragraph which should read "This is my paragraph" and which of course in HTML shows "<p>This is my patagrah … instead displays as " p>This is my paragraoh … (note the leading ‘<‘ character is stripped of, breaking the code.

然后,猜测到根本原因是:

hawk的服务器那端,在我不知情的情况下,自己升级了libxml,从而导致:

之前可以正常通过wlw发布帖子的,不会无缘无故的,去除掉html的tag;

而现在,升级了libxml后,导致通过wlw发布帖子,会出现html的p标签被处理掉,导致页面显示出html源码,而非正常的内容。

所以,接下来就是去问问hawk官网,到底是怎么回事,是不是其升级了libxml了。

16.暂时先去:

看看本地的wordpress中的phpinfo,看看libxml的版本;

然后再去在线的wordpress中看看对应的phpinfo中的libxml的信息,对比看看。

这个是本地的wordpress中的phpinfo中的libxml的版本:

PHP Logo

PHP Version 5.4.3

System Windows NT PC-20130611GART 6.1 build 7601 (Windows 7 Ultimate Edition Service Pack 1) AMD64

Build Date May 15 2012 00:57:24

Compiler MSVC9 (Visual C++ 2008)

Architecture x64

Configure Command cscript /nologo configure.js "–enable-snapshot-build" "–without-dblib" "–without-pdo-dblib" "–without-pdo-mssql" "–with-pdo-oci=C:\php-sdk\php54dev\vc9\x64\deps\instantclient_10_2\sdk,shared" "–with-oci8=C:\php-sdk\php54dev\vc9\x64\deps\instantclient_10_2\sdk,shared" "–with-oci8-11g=C:\php-sdk\php54dev\vc9\x64\deps\instantclient_11_2\sdk,shared" "–disable-debug-pack" "–disable-static-analyze"

Server API Apache 2.0 Handler

1 dom

DOM/XML

enabled

DOM/XML API Version

20031129

libxml Version

2.7.8

HTML Support

enabled

XPath Support

enabled

XPointer Support

enabled

Schema Support

enabled

RelaxNG Support

enabled

2 libxml

libXML support

active

libXML Compiled Version

2.7.8

libXML Loaded Version

20708

libXML streams

enabled

3 xml

XML Support

active

XML Namespace Support

active

libxml2 Version

2.7.8

 

其对应的地址是:

http://localhost/?phpinfo=1

去试试在线的话,能否用此地址:

https://www.crifan.com/?phpinfo=1

结果没用。

所以只能自己上传一个php文件去试试了。

先写内容:

<?php phpinfo(); ?>

存为phpinfo.php

上传到在线的wordpress中的根目录。

然后去试试:

www.crifan.com/phpinfo.php

然后结果是:

PHP Logo

PHP Version 5.2.17

System Linux sjc004.hawkhost.com 2.6.18-448.4.1.el5.lve0.8.69 #1 SMP Wed May 8 12:33:37 EEST 2013 x86_64

Build Date Jun 11 2013 11:15:01

Configure Command ‘./configure’ ‘–build=x86_64-redhat-linux-gnu’ …… ‘–with-libxml-dir=/usr’ ……

Server API LiteSpeed V6.2

1 dom

DOM/XML

enabled

DOM/XML API Version

20031129

libxml Version

2.6.26

HTML Support

enabled

XPath Support

enabled

XPointer Support

enabled

Schema Support

enabled

RelaxNG Support

enabled

2 libxml

libXML support

active

libXML Version

2.6.26

libXML streams

enabled

3 SimpleXML

Simplexml support

enabled

Revision

$Revision: 299016 $

Schema support

enabled

4 xml

XML Support

active

XML Namespace Support

active

libxml2 Version

2.6.26

5 xmlreader

XMLReader

enabled

6 xmlrpc

core library version

xmlrpc-epi v. 0.51

php extension version

0.51

author

Dan Libby

homepage

http://xmlrpc-epi.sourceforge.net

open sourced by

Epinions.com

7 xmlwriter

XMLWriter

enabled

8 xsl

XSL

enabled

libxslt Version

1.1.17

libxslt compiled against libxml Version

2.6.26

EXSLT

enabled

libexslt Version

1.1.17

然后看到自己的在线的wordpress所用的libxml是2.6.26的,本地是2.7.8的

另外主要的php的版本是:在线的是“PHP Version 5.2.17”,本地的是“PHP Version 5.4.3”

所以就去搜搜2.6.26的libxml是不是有此bug。

然后找到:

Restore breaks HTML in Moodle 1.9.5

遇到类似的,是2.6.30的libxml,会导致

html tag be strip

另外,参考:

Windows Live Writer issue and WordPress 2.6x 的第二页

给出一个wordpress的插件:

http://wordpress.org/extend/plugins/libxml2-fix/

可以解决类似的,但是是2.7.x版本的libxml的bug:

在解析xml时,会去除掉tag

其说是只支持:

“PHP 5.2.9+ with libxml2 2.7.3+”

(并且提到了对应的wordpress中已发现了此bug:

XMLRPC api stripping leading angle brackets

而我此处在线的wordpress是:

PHP 5.2.17 + libxml 2.6.26

不是太符合,但是不管了,先去试试此插件是否有效。

try the libxml2 fix plugin

然后结果竟然真的可以了:

the wordpress plugin libxml2 fix really work

感谢作者。

 

【总结】

此处,通过wlw发布帖子到自己的在线的wordpress网站crifan.com上,之前都是好好的,前天出现问题:

发布后的内容,html标签被破坏了,被过滤掉一部分,导致显示出来的内容,变成html源码了。

根本原因是:

hawk的主机上的libxml,估计(前天?)刚刚重新换了个版本,换成了2.6.26,由于此2.6.26版本的libxml2有bug

至少和当前hawk主机上的5.2.17版本的PHP搭配起来有bug,所以弄出上述的问题:

当通过wlw发布帖子到hawk上的PHP 5.2.17 + libxml2 2.6.26,结果正常的内容

比如

<p>xxx</p>

就被过滤成了:

pxxxp

即,其中的<和>都被过滤掉了。

然后导致显示出来的内容,全部乱掉了。

解决办法是:

1.最佳办法,其实是去找hawk主机提供商,让其换个,没有此bug的libxml2

2.我此处用的是workaround:用了别人提供的插件LibXML2 Fix,暂时规避此问题。

之后,等抽空,给hawk写信,让其尽快解决次问题,尽快换个正常的libxml2。。。


【后记 2013-06-29】

1.给hawk发了个ticket:

[background]

my website is www.crifan.com, based on wordpress.

I use WLW(Windows Live Writer) to publish post to my wordpress site, internally using wordpress’s XML-RPC

previous, always, is normal.

[issue]

when use WLW publish post to wordpress website, but the post content show out, is messy code, reason is the post content is be removed the html brackets

after spend much time to investigate, found out the root cause:

your, hawk, provided web server, use the libxml2 2.6.26, which has some bug:

(use wlw, do offline publish post, using XML-RPC, will use) libxml2 will strip out brackets when parsing XML

so lead to the published post content show out is messy code.

and finnaly, just a workaround, use the plugin:

http://wordpress.org/plugins/libxml2-fix/

to temprary avoid this issue.

the detailed process of investigating is here:

https://www.crifan.com/wlw_publish_post_to_wordpress_but_show_html_source_p_tag_be_filtered/

(written in Chinese, you can read it using google translate to English, if you do not understand Chinese)

so what I want to ask help for yourside is:

1. ask yourside:

does yourside, about 2013-06-27, do some update, which changed the libxml2 (or something related) ?

2. whether or not, please makesure yourside provided webserver is function well:

please test/verify that the libxml2 and related libraries work well.

Thanks.

等待其回复。。。

2.结果由于用的邮件,不是之前注册时候的邮件,导致需要另外去:

要么用注册邮件重发问题

要么把新邮件添加到new contact中:

How do I add a contact to my account?

 

所以,就去添加一下,再重发。。。

不过发现此help系统中,也可以添加:

image

 

结果没Update成功,显示那个邮件已经注册过了。。。

 

然后再去hawk系统中添加:

image

然后再去重新发一个ticket,用的是163的邮件。。。

3。这个是后来技术部的回复:

Hello,

This appears to be a build issue with our PHP 5.2 only which PHP 5.2 had it’s end of life over 900 days ago I would highly recommend using PHP 5.3 using the select php version option. We are however going to investigate upgrading libxml2 on PHP 5.2 but our estimate is it won’t be available on all systems until July 3rd at the earliest as it needs to pass through QA before going live.

——————————

Tony B.

Chief Executive Officer, Hawk Host

Ticket Details


Ticket ID: CCZ-749-83878

Department: System Admin

Type: Issue

Status: Open

Priority: Urgent

Support Center: https://support.hawkhost.com/index.php?/default_import

感觉木有完全看懂的说,需要我等到7月3号才可以???

4.然后收到回复:

Hello,

At the earliest July 3rd we estimate it will be fixed for PHP 5.2. Though as already mentioned you should be running PHP 5.3 at a minimum using our select php version so you can resolve this now if you run PHP 5.3.

感觉像是我自己可以去hawk中自定义php的版本?

所以去看看。

然后从:

select PHP version

->

Introducing our PHP Selector and PHP 5.5: The Choice is Yours

找到方法了:

To change your PHP version, simply login to cPanel and use the top-left finder to search for ‘Select PHP Version’.

然后就去试试:

Select PHP version

select php version

果然看到了默认的PHP 5.2:

default use php 5.2 version

所以,现在就去改为所想要的PHP 5.3:

for php 5.3 set as current

now has set to 5.3 version

另外,去Show PHP Settings看看现在的php的配置:

current php setting

其中,常见的三个大小的配置很明显是:

memory_limit=128M

post_max_size=50M

upload_max_filesize=50M

另,看到时区是America/Chicago,所以去改为我自己所想要的。

先去找到php官网中,关于timezone的值:

http://php.net/manual/en/timezones.php

然后从:

http://www.php.net/manual/zh/timezones.asia.php

找到Asia/Shanghai,所以去改为Asia/Shanghai:

change timezone to shanghai

然后点击Save,即可。

5.然后,再去像之前一样,弄个

<?php phpinfo(); ?>

存为phpinfo.php放到主页上,然后访问一下,看看php的版本,是否变成了5.3.

其中,没弄之前,就已经看到,Cpanel中的信息,php的版本就是5.3了:

cpanel php version already 5.3.26

接着去访问:

https://www.crifan.com/phpinfo.php

可以看到对应的PHP是5.3.26了:

PHP Version 5.3.26

Server API

LiteSpeed V6.2

1 xml

XML Support

active

XML Namespace Support

active

libxml2 Version

2.9.1

2 xmlreader

XMLReader

enabled

3 xmlrpc

core library version

xmlrpc-epi v. 0.51

php extension version

0.51

author

Dan Libby

homepage

http://xmlrpc-epi.sourceforge.net

open sourced by

Epinions.com

4 xmlwriter

XMLWriter

enabled

5 xsl

XSL

enabled

libxslt Version

1.1.17

libxslt compiled against libxml Version

2.6.26

EXSLT

enabled

libexslt Version

1.1.17

然后可以看到,libxml2是2.9.1了。

6.所以,就可以先去测试一把,看看禁止掉之前的libxml2 fix插件:

disable libxml2 fix plugin

后,发帖是否正常,结果是正常的了:

after use php 3.5 then wlw post ok

 

至此,终于彻底解决了此问题了。

 

【总结】

之前已经总结了,此问题是由于

hawk上的PHP 5.2.17 + libxml2 2.6.26

导致xml-rpc有问题,导致wlw发帖子后显示有问题。

然后之前是通过一个wordpress插件:libxml2 fix暂时解决此问题。

现在,通过,在hawk中,换了PHP版本,变成了:

PHP 5.3.26 + libxml2 2.9.1

不需要插件的,彻底的解决了此问题。

 

感慨:

其实,hawk在这方面,尤其是php可以方便的换版本,php配置可以方便的更改,这些方面,做的已经很人性化了。赞一个。

转载请注明:在路上 » 【已解决】通过WLW向WordPress发布帖子后,显示出来的内容却是html源码且HML的p标签被破坏掉了

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.182 seconds, using 22.23MB memory