开发者

How to preserve tags inside pre or code while sanitizing?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜