内容数据库 - 可以存储HTML吗? [英] Database for Content - OK to store HTML?

查看:131
本文介绍了内容数据库 - 可以存储HTML吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本问题是 - 如果我限制谁可以提交HTML,是否可以将HTML存储在数据库中?

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

我有一个很简单的问题。我提供视频教程和其他内容。没有花几个月来写一个正确的BBCode解析器,我需要存储HTML,所以我可以让它看起来完全一样,当我从数据库中抓取它的方式。

I have a pretty simple question. I provide video tutorials and other content. Without spending months writing a proper BBCode parser, I would need to store the HTML so I can have it look exactly the way I want when I grab it from the database.

基本上我计划将所有信息存储在数据库中关于教程系列和每集。我想为它们的描述设置一些格式,以便我可以添加多个段落,有序和无序列表,所需资源的链接等。

Basically I plan to store all information in the database about a tutorial series and each episode. I would like to have some formatting for the descriptions for both so I can add multiple paragraphs, ordered and unordered lists, links to required resources, and so on.

我是使用PHP和创建我自己的数据库。我现在使用phpMyAdmin来存储信息在表中。我将使用一个只读权限的用户,当我拉取PHP代码中的信息。

I am using PHP and creating my own database. I am using phpMyAdmin to store the information in the table right now. I will use a user with read only rights when I pull the information in the PHP code.

这是最好的方法是什么?谢谢!

What is the best way to do this? Thank you!

推荐答案

像其他人一样,在数据库中存储 HTML没有什么危险。但是当你显示它,你需要知道HTML是安全的。看到你是唯一一个编辑HTML我没有问题。

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.

但是,我不会存储所有的HTML。如果你需要的是标题,段落,列表,链接,图像等,我想说Markdown是一个完美的合适。 Markdown的好处是,它看起来像正常的文本(即,您可以发送您的文章作为电子邮件或保存为txt文档),它占用比HTML 少的空间

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/

这篇关于内容数据库 - 可以存储HTML吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆