开发者

Escape HTML using a whitelist

There are some very comfortable whitelist sanitizers for Ruby, but I can开发者_如何学Go't find a tool that does HTML escaping using a whitelist. All Ruby HTML escape libraries do only escape all HTML tags in a provided text. Is there a library that let me choose which tags to escape?


The Sanitize library you linked to supports custom configurations. See the "Custom Configuration" heading in the readme. The "elements" option sounds just like what you're looking for — you can specify an array of tags to allow.

  :elements => %w[
    a abbr b blockquote br cite code dd dfn dl dt em i kbd li mark ol p pre
    q s samp small strike strong sub sup time u ul var
  ]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜