我正在生成一些HTML,我想生成一个XSS和数据库内容安全的mailto
链接。这里使用的编码是什么?怎么回事?
myLiteral.Text = string.Format(
"mailto:{0}?Content-Type=text/html&Subject={1}&body={2}",
HttpUtility.UrlEncode(email_address),
HttpUtility.UrlEncode(subject),
HttpUtility.UrlEncode(body_message));
我应该在这里使用UrlEncode
吗? HtmlEncode
?做我做的,然后HtmlEncode
整体?我正在写一个URL的HTML,所以我有点不清楚......
@Quentin,这就是你所描述的吗? (将&
更改为&
,因为我即将HtmlEncode
...)myLiteral.Text = HttpUtility.HtmlEncode(HttpUtility.UrlEncode( string.Format( "mailto:{0}?Content-Type=text/html&Subject={1}&body={2}", email_address, subject, body_message)));
答案 0 :(得分:6)
您正在将某些内容放入网址中,然后以HTML格式表示该网址。所以URLEncode然后HTMLEncode你从URLEncode获得的东西。