How to allow code in htmlpurifier

后端 未结 1 844
野趣味
野趣味 2021-01-26 03:45

I am in the middle of creating a comment box where people can ask their questions.

I get a lot of people asking how do they do something which involves inputting code in

相关标签:
1条回答
  • 2021-01-26 04:09

    Your problem is, if the input is truly HTML, then any code fragments need to be escaped in order to show up in the result. We have special <![CDATA[ put code here ]]> syntax for just that, but sometimes, you don't want to bother users with extra syntax like that. In that case, you could do a preg_replace_callback on code tags, where the callback escapes the code between two code tags. But notice, now, there is no way to express a code fragment that contains code tags! So it is all tradeoffs.

    0 讨论(0)
提交回复
热议问题