Is there a difference with the HTMLEditFormat function in ColdFusion CF9 versus CF10?

我只是一个虾纸丫 提交于 2019-12-23 14:02:32

问题


I'm seeing a difference in how HTMLEditFormat works in CF9 and CF10.

HTMLEditFormat(">")
  • In CF9: showing up as ">" (no difference)
  • In CF10: showing up as ">" (double-escaped, which seems correct to me)

I've looked through the CF10 notes and reviewed the HTMLEditFormat documentation, but cannot find any mention of there being a difference in how this function works. Does anyone know of a difference, or know of documentation that proves there is no difference? ...Or know of any other settings (ColdFusion or web server) that might cause this to work different?

(This question is not a duplicate because am not asking about encodeForHTML. I understand that is the ideal solution, but am asking to understand why HTMLEditFormat might be different in CF9 vs. CF10.)


回答1:


I can't imagine why that function would behave differently. Especially when it's was planned for deprecation going into CF 10. By chance, are you calling it from within a CFINPUT tag?

<cfinput id="foo" value="#htmlEditFormat(someValue)#" />

If so, in CF6 - CF9, that tag uses HTMLEditFormat() on values automatically. Calling a 2nd instance of HTMLEditFormat() doesn't affect the output. But CF 10+ updated the tag to use encodeForHTML() on values. If you also throw in an HTMLEditFormat(), then you're double-encoding the output.

For better security, you should stop using HTMLEditFormat() and start using encodeForHTML() if it's available (CF10+). As of ColdFusion 11, HTMLEditFormat() has been officially deprecated and by ColdFusion 12, the function should be removed completely.

HTMLEditFormat() only encodes 4 characters: <, >, &, ".

encodeForHTML() encodes almost every character, including UTF-8 characters. The updated "encodeFor" functions are contextual, so you have to pick the right on for the right context (html, htmlattribute, js, css, xml, etc.).



来源:https://stackoverflow.com/questions/23941113/is-there-a-difference-with-the-htmleditformat-function-in-coldfusion-cf9-versus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!