Categories
Posts

WordPress & libxml2 Episode IV: A New Plugin

Despite the libxml2 problems having been solved by the release of PHP 5.2.9 and libxml2 2.7.3 there are still hosts out there who refuse to update their known to be broken setup. This really bummed me out, I didn’t want to include a hack to deal with this in core WordPress.

Just as I was ready to throw in the towel and look at getting a work around into core WordPress Peter Westwood suggested a method that would allow this “fix” to work in a plugin. His idea was spot on and I wrote a small WordPress plugin, LibXML2 Fix, the next day and tested it on a WordPress install with this problem. It fixed the stripped brackets problem for XML-RPC requests, so I’ve submitted it to the plugin directory and it’s now available at http://wordpress.org/extend/plugins/libxml2-fix/.

To be clear, the best way to fix this is to upgrade to PHP 5.2.9+ and libxml2 2.7.3+. But if you are stuck in a hosting situation where that’s not possible then the LibXML2 Fixed plugin will fix XML-RPC requests so that brackets don’t get stripped.

I’ve closed ticket 7771 and will be pointing people to this plugin if they can’t upgrade PHP and libxml2.

30 replies on “WordPress & libxml2 Episode IV: A New Plugin”

Joseph –

Have you found any situations in which the plugin does not work? I have WordPress 2.7.1 – with the plugin installed (and active) and all the are still stripped.

Is there anything that needs to be done beyond putting it in the plugins directory and activating it?

Any help would be appreciated.

Brian Roy

The plugin only tries to work around libxml2 bracket stripping if it detects that your PHP build is using libxml2 2.7.0, 2.7.1 or 2.7.2. If you are using any other version then the plugin does nothing. First thing I’d look at is a phpinfo() page to see what version of libxml2 your PHP was built with.

Hi there, just realised I’ve been having this problem for months on one of my servers without anyone having noticed!

Hmm I’ve got libxml 2.7.3 and php 5.2.5 and the plugin LibXML2 Fixed but posts are still coming through mangled

Any other ideas?

Best regards

Roger

You only fix 1 section of a 2 part problem. In order to things to work normally again you must be using PHP 5.2.9 and libxml2 2.7.3. Only upgrading one with out the other won’t do any good.

I’ve upgraded everything on my FC10 machine but phpinfo still shows the old libXML version. I then tried installing this plugin, but I’m still getting the stripped when I use the FeedWordPress plugin to syndicate content from some other sites.

I just installed it with Yum. I ran yum update and I think I have the most recent version. Are you saying I need to uninstall the yum version and rebuild from source?

Joseph, I ran into this same issue with FC10 and yum install – a simple restart of my web server fixed the problem. FC10 and yum update on both php and libxml2 should do the trick, no source build necessary.

php 5.2.9 and libxml2 2.7.3 on my server, plugin on wordpress 2.7.1 doesnt not work (josephscott.org/code/wordpress/plugin-libxml2-fix/)
restart server- problem too – HELP!!!

hi, sorry my spanglish…

i recently change to a dedicated server:
1) i had a problem with “ –> p
2) i did install the plugin libxml2
3) still having problems and
4) so people do this: ”
I have enabled suPHP. I have also installed the latest version of PHP and libXML”
5) all is correct now but still having this problem: publishing with wordpress this example: ¿Dónde están mis viejos amigos de la izquierda? is ok
but with xmlrpc (windows live writer) this example: `¿Dónde están mis viejos amigos de la izquierda?` is not ok
6) Having searched a lot the only thing that i have found is to do some modifications to wordpress files…http://blog.hoofoo.net/2009/01/14/wordpress-patch-for-problamatic-libxml2-version/…should i do this? or is another simplier solution? TY

ok, i will try to explain again my problem:

1) when i post to wordpress inside wordpress (mean from the administrator) any accented letter is an accented letter. example: á is á, ¿ is ¿ …and so. [write so in database]

2) when i post using windows live writer an á is á – ¿ is &iquest, this i can see when i go to edit the article. [write acute, rdaquo, iquest… in database]

3) both 1 and 2 shows correct in browser. but not when i edit the article. so my database can have titles with condition 1 or 2.

4) the interesting thing is that happens only with the title of the article. the content for both 1 and 2 is correctly written.

5) i did notice it because my post goes to twitter (shows correct) and then goes to facebook (shows incorrect with acute, iquest, rdaquo …)

6) i have checked my database tables. wordpress tables are utf8_general, collate for all the database is latin. yesterday i did make a new database with tables utf8 and collate utf8 and the problems persist. so, it is not a question of database format.

7) i did deactivate all plugins and the problem persist…

8) information from my new dedicated server people: I have enabled suPHP. I have also installed the latest version of PHP (5.2.10) and libXML (2.7.3), provided by cPanel.

9) i have tried changing my theme and the problem persist..

Now what can i do to resolve this? I will appreciate a lot your answer. TY

Something in WordPress is likely not dealing with the encoding correctly. This might be related to long standing problem with WordPress has in storing the encoded version of a post title in the database, instead of the raw (but properly escaped) version of the title string.

Hello,

When I post on by WordPress blog from flickr, the are stripped from the message and I see only html content as text.
see:
http://mgroleau.com/wp/?p=53

My WordPress version is 2.8.5 and my PHP version is 5.2.9 and my libxml2 version is 2.6.27

Like the LibXML2 version is not the 2.7.3+ I installed and activate the LibXML2 fix plugin, but the result is the same.

That certainly looks like the same libxml problem where brackets are stripped. But with that version of libxml it shouldn’t be an issue.

Try adding that version to the plugin and see if it solves it.

The plugin looks up your libxml version number and then compares to a list of versions that are know to have this problem. Add your libxml version to that list and see if that fixes the problem.

Thank you so much! Your plugin worked like magic. I just had to edit it to include the following lines since I also needed to be able to use single and double quotes.

$HTTP_RAW_POST_DATA = str_replace( ‘'’, ‘'’, $HTTP_RAW_POST_DATA );
$HTTP_RAW_POST_DATA = str_replace( ‘"’, ‘"’, $HTTP_RAW_POST_DATA );

(Hope this code displays properly)

Looking forward to my hosting company upgrading their PHP. :

Oops! Well, my code almost displayed properly. It just converted the character codes into the actual characters, let’s see if I can portray it another way (for those who need to know).

As seen the pattern of the character codes in the lines already included within the plugin, character codes start with an ampersand (&) and end with a semicolon (;). The part in between goes as follows:

For a single quote (‘):
apos
#39

For a double quote (“):
quot
#34

Hope this helps somebody.

Leave a Reply

Your email address will not be published. Required fields are marked *