[thelist] bbCode or HTML in DB?

Paul Waring paul at xk7.net
Thu Oct 13 10:47:15 CDT 2005


On Thu, Oct 13, 2005 at 10:07:09AM -0400, Brooking, John wrote:
> thought through the following design decision: Should I translate the
> bbCode to HTML *before* storing it in the DB, so that the HTML tags are
> stored in the DB, or should I store the bbCode in the DB and translate
> it to HTML after retrieval? Are there more security issues one way than
> the other?

I personally store all the text for my blog in the format that it is
originally entered. In my case this is with Textile formatting, but it's
the same principle as BBCode. However, I have seen a good suggestion on
Maniacal Rage[1] which was to store both formats in the database - i.e.
the BBCode and the HTML equivalent. This way if you ever want to edit
posts or articles you have the original text in BBCode format, but
whenever someone visits a page you'll select the HTML instead. This cuts
down the time required to display the page because you haven't got a
relatively costly conversion between BBCode and HTML to perform.

Of course, the problems with this approach are that you're storing
everything twice in the database, and you need to remember to regenerate
the HTML every time the BBCode is changed.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk


More information about the thelist mailing list