是否需要对右尖括号进行html编码?
我在标题中添加了一些元描述数据,如下所示:
HtmlMeta meta = new HtmlMeta();
meta.Name = "description";
meta.Content = description; // this is unencoded
page.Header.Controls.Add(meta);
.net 有助于对诸如 & 之类的内容进行编码。和 <,但不是 >。现在,我无法想象这会是一个疏忽,所以我的结论是没有必要逃避它们。但在我向客户返回答案之前,最好先得到来自 Intarwebs 的一些陌生人的确认:)
I'm adding some meta description data to my header like so:
HtmlMeta meta = new HtmlMeta();
meta.Name = "description";
meta.Content = description; // this is unencoded
page.Header.Controls.Add(meta);
And .net helpfully encodes things like & and <, but not >. Now, I can't imagine that this would be an oversight, so I conclude that it's unnecessary to escape them. But before I go back to the client with that answer, it would be nice to get confirmation by Some Strangers From The Intarwebs first :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据XML规范
>
确实是对属性有效。只有<
、&
和"
或'
需要转义。According to the XML specification
>
is indeed valid for attributes. Only<
,&
and"
or'
need escaping.