このシンプルな形を想像してみてください
<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()
。