是否有必要为HTML EN code右尖括号? [英] Is it necessary to html encode right angle brackets?

查看:127
本文介绍了是否有必要为HTML EN code右尖括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加一些元数据的描述我的头,像这样:

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);

和.NET有益EN codeS之类的东西和放大器;和<,而不是>。现在,我无法想象,这将是一个疏忽,所以我断定,这是不必要的逃避它们。但在此之前我回去与回答客户端,这将是很好,首先通过获取一些陌生人从Intarwebs确认:)

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 :)

推荐答案

按照XML规范 &GT; 确实是有效的属性。只有&LT; &安培; 需要转义。

According to the XML specification > is indeed valid for attributes. Only <, & and " or ' need escaping.

[10]    AttValue    ::=    '"' ([^<&"] | Reference)* '"'
                         | "'" ([^<&'] | Reference)* "'"

这篇关于是否有必要为HTML EN code右尖括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆