想象一下这个简单的形式
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
<fieldset>
<legend>Contact Me</legend>
<label for="email">Email:</label>
<input type="text" name="email" id="email" />
<button type="submit">Submit</button>
</fieldset>
</form>
现在想象它是通过form.php?hack=" onsubmit="alert('xss')
我查看源代码时的输出是
<form action="/things/?hack=%22%20onsubmit=%22alert(%27xss%27)" method="post">
这是什么编码 - 是浏览器还是 PHP?
出于好奇,我总是$_SERVER['REQUEST_URI']
在内心附和htmlspecialchars()
。