Best way to safely read query string parameters?

前端 未结 5 1725
余生分开走
余生分开走 2020-12-30 16:58

We have a project that generates a code snippet that can be used on various other projects. The purpose of the code is to read two parameters from the query string and assig

5条回答
  •  [愿得一人]
    2020-12-30 17:44

    You can use regular expressions to validate that you have a P followed by 9 integers and that you have 15 alphanumeric values. I think that book that I have at my desk of RegEx has some examples in JavaScript to help you.

    Limiting the charset to only ASCII values will help, and follow all the advice above (whitelist, set src through DOM, etc.)

提交回复
热议问题