How do I filter all HTML tags except a certain whitelist?

后端 未结 8 1578
一整个雨季
一整个雨季 2020-11-27 12:07

This is for .NET. IgnoreCase is set and MultiLine is NOT set.

Usually I\'m decent at regex, maybe I\'m running low on caffeine...

Users are allowed to enter

8条回答
  •  不知归路
    2020-11-27 12:51

    I just noticed the current solution allows tags that start with any of the acceptable tags. Thus, if "b" is an acceptable tag, "blink" is too. Not a huge deal, but something to consider if you are strict about how you filter HTML. You certainly wouldn't want to allow "s" as an acceptable tag, as it would allow "script".

提交回复
热议问题