Escaping ansi escape sequences

Howdy !

Got an interesting few days ago in a chat room… Some user copied and paste console from a ruby on rails log (I presume), I was no tin the room but basically everybody in the room dropped and started to bounce from the server…

I mean litterally : people would disconnect, their client (Adium on mac, pidgin on windows) will reconnect, join the room, get the last 50 messages, see that string adn drop, ad nauseam.

The server became totally unresponsive, I had to remove the faulty entry from the room log in mysql and restart the service…

Here is the raw message (cat -e dbdump.sql)

*************************** 364. row ***************************$
  roomID: 43$
  sender: EDITED@acme.com/client.123$
nickname: Edited$
logTime: 001351186477143$
subject: NULL$
    body: ^[[0;34mHTTP/1.1,200,  0.01,   2854$

The string made it straight to the db unescaped, unaltered, I saw it affected the mysql client as well : all the text after that line in the record 364 turned blue

select * from ofMucConversationLog where roomId=43 \G

So :

delete from ofMucConversationLog where logTime=001351186477143 and roomID=43 limit 1;

got me out , but still had to restart the server. In the middle of the day, with 100 users, it was not a pleasant experience.

It could be a client side issue, server just passing the string as it sees it, but litterally all of our libpurple clients freaked out. An option/plugin to purge protect fragile client would be nice, as it represents 99% of the client base.
log.txt.zip (1085 Bytes)