これは、たとえば、ユーザーが<script>top.location.href=’http://www.google.nl’;</script>
アプリケーションにプレーンテキストとしてエコーするように入力したときに発生する問題です。さて、これは実際に htmlspecialchars() で動作します
この例は私にとってはうまくいきます:
$test = "<script>top.location.href=’http://www.google.nl’;</script>";
echo htmlspecialchars($test);
しかし、ユーザーがフォームを送信すると、データは DB に送られ、「ダッシュボード」に戻ります。値は現在''
です。データを安全に DB に保存する方法はありますか?
SDK を使用して、この方法で C# アプリケーションの DB に値を追加します。
$onderwerp = htmlspecialchars(stripslashes(trim($_POST['onderwerp'])), ENT_QUOTES,'UTF-8',true);
$omschrijving = htmlspecialchars(stripslashes(trim($_POST['omschrijving'])), ENT_QUOTES,'UTF-8',true);
$im = array('description' => mysql_real_escape_string($onderwerp),
'message' => mysql_real_escape_string($omschrijving) ,
'relation' => $_SESSION['username'],
'messageType' => 70,
'documentName' => $_FILES["file"]["name"],
'documentData' => base64_encode(file_get_contents($_FILES["file"]["tmp_name"])));
$imresponse = $wcfclient->CreateInboundMessage($im);
echo $imresponse->CreateInboundMessageResult;
そして、この方法で私のダッシュボードでそれらを呼び出します:
$roc = array('relation' => $_SESSION['username']);
$rocresponse = $wcfclient->ReadOpenCalls($roc);
foreach ($rocresponse->ReadOpenCallsResult as $key => $calls){
echo $calls->Description;
}