开发者

Is it necessary to html encode right angle brackets?

开发者 https://www.devze.com 2023-04-04 12:36 出处:网络
I\'m adding some meta description data to my header like so:开发者_开发技巧 HtmlMeta meta = new HtmlMeta();

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


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

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

精彩评论

暂无评论...
验证码 换一张
取 消