反XSS库解码
我正在使用 microsoft anti xss 库来形成安全性。我正在使用 HtmlFormUrlEncode 方法。
如何解码我记录的数据?
样本数据:
mail%40sample.com
%c3%96nder
I am using microsoft anti xss library to form security. I am using HtmlFormUrlEncode method.
How can I decode my recorded data?
sample data :
mail%40sample.com
%c3%96nder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AntiXSS 不提供解码 - .NET 框架往往会为您提供解码。事实上, UrlDecode 实际上应该正确。
但是,如果您想手动执行此操作,应该能够创建一个与原始字符串长度相同的 char[] 数组,然后循环遍历该字符串,查找 % ,然后抓取后面的两个字符,确保它们是有效的十六进制,然后执行以下操作来获取十六进制值
一旦您拥有这两个值,您就可以组合
并通过调用 UTF8Encoding.GetChars()
(注意:代码是我自己想出来的,没有经过正确的测试)
AntiXSS doesn't provide a decode - the .NET framework tends to do it for you. Indeed, UrlDecode should actually get it correct.
However, if you want to do it manually should be able to create a char[] array that's the same length as the original string, then loop through the string, looking for a % and then grabbing the two characters after, ensuring they're valid hex and then doing the following to get the hex value
Once you have both values you'd then combine
And append it to the array by calling UTF8Encoding.GetChars()
(note: Code is off the top of my head and not tested properly)