ModSecurity and CodeColorer WordPress plugin conflict

Santosh

2013/04/27

Categories: General Tags: CodeColorer ModSecurity Wordpress

Few days back I got into strange trouble. I was not able to edit and update any of my post on this site which is a WordPress powered site. I tried several things and finally filed a ticket with my hosting provider. Based on their reply, it was a ModSecurity issue. My permalink settings were messing up their ModSecurity settings. I asked for the log files to check what was actual cause for the conflict. To my surprise I found that my code colorer plugin tags were causing the conflicts. I was using [cc] based tag system. Seems like it don’t like the cc part. So I decided to drop it and resort back to <code> and </code> based tags. Did anybody else have faced a similar issue?

To go back to <code> based tags, I had to do it on many of the posts. To ease out the task I wrote a small Perl script, which takes the file with old tags as input and generates the file with new tags(<code>. Hope you find it useful, if you get into the similar issue.

#!perl -w

use strict;
use warnings;

print "Converting";

open(INPUT, "input.txt");
open(OUTPUT, ">output.txt");

while(<INPUT>) {
    s/\[cci(.*?)\]/<code inline="true" $1>/gi;
    s/\[cc(.*?)\]/<code $1>/gi;
    s/\[\/cc\]/<\/code>/gi;
    s/\[\/cci\]/<\/code>/gi;
    
    print OUTPUT
}

Please let me know if you have faced some similar issue?