August 12, 2003 | Category:

Commenting On Comments

I’ve been doing a lot of thinking about commenting systems lately (no prizes for guessing why.) It occurs to me that my biggest problem with allowing comments is the vulnerability that it gives the site. By letting others post (in reply to my entries), I allow them the opportunity to inject malicious or malformed code.

To bypass this, I could strip_tags(). But that rather limits the ability of people to express themselves fully; I know I’d hate to have most of my XHTML vocabularly pulled out from underneath me. I could allow a limited textile style pseudo-markup language (which I probably will), but many are set in writing proper HTML.

I’ve settled on my last option: processing comments with various regular expressions (to get rid of the dangerous) and then sending it through Simon Willison’s safe HTML checker class. Playing with it earlier, it works a treat.

Now, I just need to find the time to implement it and the rest of the commenting system.