开发者

How to preserve tags inside pre or code while sanitizing?

开发者 https://www.devze.com 2023-04-03 15:14 出处:网络
I need some way to preserve tags inside a code or a pre block, while sanitizing. For example: <a href=\"http://sanitize.com\">link</开发者_运维技巧a>

I need some way to preserve tags inside a code or a pre block, while sanitizing.

For example:

<a href="http://sanitize.com">link</开发者_运维技巧a>

<code>
  <a href="http://donotsanitize.com">link</a>
  <p>The link above and this p should not be sanitized, just converted to html special chars.</p>
</code>

Should output something like:

link
<code>
  &lt;a href="http://donotsanitize.com"&gt;link&lt;/a&gt;
  &lt;p&gt;The link above and this p should not be sanitized, just converted to html special chars.&lt;/p&gt;
</code>

With common/regular sanitization methods the output is:

link
<code>
  link
  The link above and this p should not be sanitized, just converted to html special chars.
</code>
0

精彩评论

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