How do I textile and sanitize html?

前端 未结 3 750
孤城傲影
孤城傲影 2020-12-18 05:50

Now i ran into some stupid situation. I want the users to be able to use textile, but they shouldn\'t mess around with my valid HTML around their entry. So I have to escape

3条回答
  •  旧巷少年郎
    2020-12-18 06:53

    Looks like textile simply doesn't support what you want.

    You really want to only allow a carefully controlled subset of HTML, but textile is designed to allow arbitrary HTML. I don't think you can use textile at all in this situation (unless it supports that kind of restriction).

    What you need is probably a special "restricted" version of textile, that only allows "safe" markup (defining that however might already be tricky). I do not know if that exists, however.

    You might have a look at BBCode, that allows to restrict the possible markup.

提交回复
热议问题