Database for Content - OK to store HTML?

后端 未结 5 1158
失恋的感觉
失恋的感觉 2021-01-04 03:24

Basic question is - is it safe to store HTML in a database if I restrict who can submit to it?

I have a pretty simple question. I provide video tutorials and other

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-04 03:37

    Like others have pointed out there's nothing dangerous about storing HTML in the DB. But when you display it you need to know the HTML is safe. Seeing as you're the only one editing the HTML I see no problem.

    However, I wouldn't store HTML at all. If all you need are headings, paragraphs, lists, links, images etc I'd say Markdown is a perfect fit. The benefit with Markdown is that it looks just like normal text (ie you could send your articles as e-mails or save them as txt-documents), it takes up a lot less space than HTML and you don't have to change it once HTML gets updated.

    http://michelf.ca/projects/php-markdown/

提交回复
热议问题