05
Jun

Bad Behavior does not like Windows Live Writer

There is a bug in the newly released Windows Live Writer beta 2 that causes it to choke if you are also using Bad Behavior on your blog.

I first discovered this when I installed it yesterday to check it out. When it refused to update the theme from my blog, I wondered at first if there was a problem with my custom theme, but then half an hour later I looked at my home page again to find that all the comments on my blog had closed. A quick investigation showed that Bad Behavior had been choking on the requests from Windows Live Writer and logging the failed attempts, which were then being picked up by my new plugin, Three Strikes and You’re Out.

It turns out that the problem stems from the fact that Bad Behavior expects Internet Explorer to include an “Accept” header with every HTTP request, and if it gets something that claims to be Internet Explorer yet doesn’t match up to its expectation, it throws an error.

Fortunately, it is not too difficult to fix this, though you do need to tweak the code base of Bad Behavior. Open the file msie.php in the bad-behavior subdirectory of your Bad Behavior plugin and find the lines which say:

if (!array_key_exists('Accept', $package['headers_mixed'])) {
    return "17566707";
}

Change this to read as follows:

if (strpos($package['headers_mixed']['User-Agent'], "Windows Live Writer")
    === FALSE && !array_key_exists('Accept', $package['headers_mixed'])) {
    return "17566707";
}

You should then be able to use Windows Live Writer on your blog once again, without losing the protection offered by the Bad Behavior plugin.

9 comments:

  • 18 Jun 2007
    13:33

    Good on you! It works! Thanks heaps…

  • 21 Jun 2007
    20:00

    I’ve been going crazy trying to figure out what was wrong with my wordpress setup. I thought it was some weird permission error on my webhosting side. Thanks for posting this up.

  • 25 Jun 2007
    03:50

    Any ideas if you get this 403 error and you do NOT have the bad behavior plugin? My wife posted using Live Writer just 2 days ago and now I’m getting 403 errors.

  • 27 Jun 2007
    14:20

    Thanks for this - it works as advertised. However my file was named msie.inc.php, not msie.php.

  • 27 Jun 2007
    14:36

    Sorry, you’re right. It should be msie.inc.php not msie.php.

  • 12 Jul 2007
    02:44

    Thanks for the fix. You’re a saviour. -)

  • 14 Aug 2007
    12:57

    Thanks for the help James.

  • 21 Aug 2007
    09:37

    Followed a link from the Wordpress forums to your site. It solved my problem with WLW. Thanks for figuring it out!

  • Leo F. Swiontek
    31 Mar 2008
    08:15

    I’ve been going crazy trying to figure out what was wrong with my wordpress setup. I thought it was some weird permission error on my webhosting side. Thanks for posting this up.

RSS feed for comments on this entryAdd your comments



(Personal blogs only please: leave blank if you don't have one)

Your comments:

-) razz mad lol cool ??? shock sad smile

Maximum 2 links per comment. Do not use BBCode.