编码隐藏的表单字段值 [英] Encode hidden form field value
问题描述
lockquote
这是一个带引号和特殊字符的真正的长字符串(〜!@ #$%^& *()_ + {}),它可能在它的中间有一个随机引号(),使得HTML无效。
我们使用ASP.net设置值:
< input type =hidden value =<%= Model.UnencodedTextData%>name =askingForTrouble/>
<我相信如果我们用HTML编码它,它会解决这个问题,但是这个表单会被发布到另一个我们没有控制的应用程序。那么接收应用程序(Marketo)会自动知道如何解码它? / p>
谢谢。
Marketo开发者传福音。 Marketo,最好使用特殊字符的HTML URL编码。例如,下面的JavaScript代码示例将URL编码为&和%字符。
函数htmlEscape(str){
返回String(str)
.replace(/& / g,'%26')
.replace(/%/ g,'%20');
}
What method should I use to encode hidden a form field value? Assume that I am storing text like this:
This is a "really" long string with 'quotes' and special characters (~!@#$%^&*()_+{}), which might have a random quote (") in the middle of it, making the HTML invalid.
We are using ASP.net to set the value:
<input type="hidden" value="<%= Model.UnencodedTextData %>" name="askingForTrouble" />
I believe if we HTML encoded it, it would solve the problem, but this form will be posted to another application, which we do not have control over. So will the receiving application (Marketo) automatically know how to decode this?
Thank you.
Marketo developer evangelist here. Before posting to Marketo, it is best to use HTML URL encoding for special characters. For example, the JavaScript code sample below would URL encode "&" and "%" characters.
function htmlEscape(str) {
return String(str)
.replace(/&/g, '%26')
.replace(/%/g, '%20');
}
这篇关于编码隐藏的表单字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!