开发者

Injecting UrlEncoded string into page - Firefox vs Chrome

It seems the following markup is rendered differently in Firefox and Chrome, an开发者_Python百科d I'm not sure how to prevent it:

<%= HttpUtility.UrlEncode("+") %>
<%= "<a href='#' name='" + HttpUtility.UrlEncode("+") + "'>stuff</a>"%>

In Firefox it looks like: %2b<a name="+" href="#">stuff</a>

In Chrome it looks like: %2b<a name="%2b" href="#">stuff</a>

Is there a way around it?


This is just a difference in the way Firebug and the Chrome developer tools display the name. If you view the source you'll find %2b in both, and that's what it'll be if you're referring to it in script (or in a link such as <a href="#%2b">).


I got around this issue by manually checking in code behind whether returned string contained '+' or '=' and UrlEncoded appropriately. While this is not a great solution, it was acceptable in my case since I know decoded string contained both '+' and '=', so I could infer whether it was encoded depending on whether they were present.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜