Advertisements

Techtites

Byte-sized bites of technology

Linux, PHP, WordPress

Fix the Windows Live Writer and WordPress stripping tags issue

I’ve been using Windows Live Writer to write posts for several months now. This has primarily been for my blog posts at Weblog Tools Collection. I decided to start using WLW for Techtites and AjayDSouza.com.

I was able to add both the blogs properly and made my first blog post. Uploaded the post to my website and noticed gibberish. On closer observation, I realized that the < and > were stripped out completely. As a result, code like <p><a href="http://techtites.com/">Techtites</a></p> became pa href="http://techtites.com/"Techtites/a/p. I manually had to edit the post to correct this post. I noticed the problem at both the blogs which are running WordPress 2.7. I initially suspected this to be the reason, and so decided to search.

Came across this article by Joseph Scott. Joseph is one of the developers of WordPress. He writes:

A gradually growing list of people have run into a very odd problem using XML-RPC methods in WordPress, where the left angle bracket ( < ) gets stripped. There’s been a fair bit of discussion about this on ticket #7771. The bottom line: the behavior of the PHP XML extension when built against newer versions of libxml2 changed, such that left angle brackets get stripped when parsing XML.

There’s been some back and forth between libxml2 folks (email list) and the PHP folks (bug 45996), with no real solution for those using the tainted versions of libxml2. So what are your options if you’ve got this problem?

There are currently two solutions to this problem.

  1. Downgrade to a lower version of libxml2. v2.6.30 has been known to work.
  2. Build PHP with expat parser instead of libxml2

Unfortunately, both solutions require you to have root access to your server. If you don’t you can write to your host and point them to this solution.

I decided to go ahead with option 1. Codehead has a good tutorial on downgrading to libxml v2.6.30 for users running cPanel. Non-cPanel users can check out the tutorial by Pete.

The procedure is rather simple. All I had to do was copy-paste the code into the Linux command prompt, edit two files and I was good to go. It’s been running fine for nearly a week now.

If you don’t have root access, you’ll have to just wait it out before the libxml2 and PHP folks sort their differences out!

Update: HooFoo.net has published a possible fix by editing three WordPress files. I haven’t tested this out myself. If any of you try it let me know. The following code has been added to the files:

//xmllib 2.7.0 -2.7.2 stripping leading angle brackets bug patch
if(LIBXML_DOTTED_VERSION == '2.7.0' ||
LIBXML_DOTTED_VERSION == '2.7.1' ||
LIBXML_DOTTED_VERSION == '2.7.2') {
$xml =str_replace("&lt;","&lt;",$xml );
$xml =str_replace("&gt;","&gt;",$xml );
$xml =str_replace("&amp;","&amp;",$xml );
}
//end Fix

I’ve modified the files myself and made them available for you. Download the zip and extract the files in your WordPress 2.7 root directory. The zip file maintains the necessary directory structure, so zipping in the root directory is sufficient. The files should work with only WordPress 2.7 and are not meant to be installed on any other version.

Update: Users have reported mixed results with the attached fix. It works for some and doesn’t for others. If it’s not working for you check if the files have been uploaded in the right place. Alternatively, try making the changes manually as listed in the tutorial by Hoofoo.

Download WordPress 2.7 XML Strip-tag Fix.zip from DivShare [25KB]

(Visited 1,961 times, 1 visits today)
Advertisements

20 Comments

  1. lickevin

    hello. Although upload the files, the characters are not found. There is nothing more to be done?. Thanks

  2. Hi.
    I download de zip and descompress. Later upload by ftp in the directory corresponding.

    I test with windows live writer and Scribe Fire (firefox plugin).

    My site is new, work in wordpress 2.7.

    You helpme?

    Thank.

  3. Connie

    I tried this fix also. It actually did nothing on my site. I use Windows Live Writer with the Ink Blog plugin. What happens for me is I send the post to publish and I get a huge chunk of \”stuff\” that I assume would actually be my ink blog post if it worked. I tried the workaround last night and nothing actually happened. I then had a friend modify the files (I had no idea these files I downloaded were actually the ones from hoofoo) according to hoofoo and my site broke. Luckily it’s back but I’m still not able to post ink blogs directly. I unzipped the files (when I tried this fix) and placed them in the appropriate directories via ftp . What a shame. My host doesn’t want to downgrade the lib so I am hoping that at some point in the future a viable solution can be found. Thanks for putting the files together though!

    • Guess, this isn’t really a working solution.

      It is really hard to actually find a host who will downgrade software, especially since this does require a good deal of work on their part.

      I guess it is wait until a truce is reached! 🙁

  4. Hi. By this bug i decided downgrade my wordpress 2.7 😐

    What versión i can be sure that no this problem?

  5. Ajay,

    I’ve downloaded your zip file, uncompressed it, uploaded the files to my server in the appropriate folders and haven’t had any luck with it. Have I missed something? I’m on a shared host so restarting PHP/Apache isn’t an option.

    • Hi,

      Can you manually modify the files with the code above or directly from the link and give it a shot. I’m not in a position to verify currently, simply because all my blogs reside on the same server where I downgraded libxml

      • Ajay,

        Yes, I’ve manually updated the files and uploaded them as well, still no luck. My host was even gracious enough to recompile PHP 5.2.8 with LibXML 2.7.3 and that didn’t do it. Supposedly this is fixed in PHP 5.2.9 with LibXML 2.7.3 so it sounds like I’ll just have to wait until the next build of PHP is available for my host to recompile.

  6. Hi, it’s unlucky on my site 🙁

    Is any new way to fix it?

  7. Неllo!
    Tell me, can I use this for WordPress MU?
    Thank you!

    • Don’t think anyone has tested it with WP MU. Also, there have been mixed results with this patch as well.

  8. My host updated PHP to 5.2.9 and the LibXML to version 2.7.3 and that was the fix for me.

  9. @Ajay, Scott released a new plugin for fixing this problem check it out here
    http://josephscott.org/code/wordpress/plugin-libxml2-fix/

    it worked for me, hope it works for you aswell.

  10. Anil

    Hi ,,,

    I just shifted my blog to another host … when i post via live writer i get this problemm ,,, its weird . ..

    can we have a fix for 2.8.1 version ..

    thanks
    anil chopra

  11. scorched

    thanks for posting. the hoofoo solution did the trick for me.
    i’m running whm/cpanel on redhat.

    happy new year!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Theme by Anders Norén