简体   繁体   English

URI编码和HTML编码

[英]URI encode and HTML encode

If I have the xml/html data to post we need to encode the data to avoid the XSS validation. 如果我要发布xml / html数据,则需要对数据进行编码,以避免XSS验证。 So should we use HTMLencode or URI encoding for this. 因此,我们应该为此使用HTMLencode或URI编码。

If URI encoding is used will it cause issues as form POST automatically URI encode all the data before sending. 如果使用URI编码,则会导致问题,因为POST形式会在发送前自动URI编码所有数据。

XSS is a problem caused by giving tainted data to the client. XSS是由于将污染的数据提供给客户端而引起的问题。 It can't be solved at the point where data is posted. 在发布数据时无法解决。

To protect against it, HTML encode the data (immediately) before placing it in an HTML document. 为了防止这种情况,HTML将数据编码(立即),然后再将其放入HTML文档中。

Remember: filter input, escape output . 切记: 过滤器输入,转义输出

  1. Always filter input before placing it in a database (to avoid SQL injection etc) 在将输入放入数据库之前,请始终对其进行过滤(以避免SQL注入等)
  2. Escape output before sending it to the client by filtering / encoding any HTML in the dynamic content. 通过对动态内容中的任何HTML进行过滤/编码,将输出发送到客户端之前先对其进行转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM