次のようなものがあるとします。
if ($command === 'txt') {
header('Content-type: text/plain;charset=utf-8');
echo $result;
exit();
} else ($command === 'js') {
$json = array( $result );
header('Content-type: text/javascript;charset=utf-8');
echo $callback . '(' . substr(json_encode($json), 1, -1) . ');';
exit();
}
echo ステートメントで使用できますか? htmlspecialchars
html として解釈されると台無しになります。一方、ブラウザーが html として解釈した場合に、誰かが xss 攻撃を試みるリスクを残すことはありません。
私は何をすべきか?心配しなくていいのhtmlspecialchars
?