Is $_SERVER['QUERY_STRING'] safe from XSS?

前端 未结 5 861
面向向阳花
面向向阳花 2020-12-18 04:15

I need to construct a form who\'s action takes you back to the exact same page - GET parameters included. I\'m thinking I can say something to the effect of:



        
5条回答
  •  萌比男神i
    2020-12-18 04:57

    First of all, you can not trust $_SERVER['PHP_SELF'] (1) - use $_SERVER['SCRIPT_NAME'] instead.

    As for $_SERVER['QUERY_STRING'], you should treat it as any other user input. Filter it before using it in your output. I would not recommend some sort of a general filter in this case. It would be better to reassemble the query string from specific pieces you expect to be there.

提交回复
热议问题