Why does this snippet in a blog post make WordPress crash?

Ok, this is seriously weird and I have no clue what’s going on here. I am using WordPress 3.0.1, I create a new blog post, give it a title, paste the following code into the blog post and hits Save Draft.

<code lang="php">
// Init curl
$request = curl_init();

// Set request options
curl_setopt_array($request, array
(
    CURLOPT_URL => 'https://www.sandbox.paypal.com/cgi-bin/webscr',
    CURLOPT_POST => TRUE,
    CURLOPT_POSTFIELDS => http_build_query(array
        (
            'cmd' => '_notify-synch',
            'tx' => $_GET['tx'],
            'at' => $your_pdt_identity_token,
        )),
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_HEADER => FALSE,
    CURLOPT_SSL_VERIFYPEER => TRUE,
    CURLOPT_CAINFO => 'cacert.pem',
));

// Execute and get the response and status code
$response = curl_exec($request);
$status   = curl_getinfo($request, CURLINFO_HTTP_CODE);

// Close
curl_close($request);
</code>

Just a code example in my head, but seems like WordPress thinks otherwise, cause when I hit Save Draft, Preview or Publish all I get is a blank page with the following text:

Read More

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

What in the world is going on here??

Related posts

Leave a Reply

1 comment

  1. And of course after I ask the question, I find the solution… Apparently it’s caused by a trigger happy Mod_Security.

    Adding these lines to the .htaccess file makes it go away nicely:

    <IfModule mod_security.c>
      SetEnvIfNoCase Request_URI ^/wp-admin/(?:post|async-upload).php$ MODSEC_ENABLE=Off
      SetEnvIfNoCase Request_URI ^/xmlrpc.php$ MODSEC_ENABLE=Off
      SecFilterDebugLevel 0
      SecFilterDefaultAction "deny,nolog,noauditlog,status:503"
    </IfModule>