是否需要html编码直角括号?

时间:2011-09-12 14:58:54

标签: asp.net html-encode

我正在向我的标题中添加一些元描述数据,如下所示:

HtmlMeta meta = new HtmlMeta();
meta.Name = "description";
meta.Content = description; // this is unencoded
page.Header.Controls.Add(meta);

.net帮助编码像&和和<,但不是>。现在,我无法想象这将是一个疏忽,所以我得出结论,没有必要逃避它们。但在我回答客户的答案之前,最好先从The Intarwebs获得一些陌生人的确认:)

1 个答案:

答案 0 :(得分:4)

According to the XML specification >确实对属性有效。只有<&"'需要转义。

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