<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="/benchmark/js/jquery.min.js"></script>
<script type="text/javascript" src="/benchmark/js/js.cookie.js"></script>
<title>BenchmarkTest01209</title>
</head>
<body>
<form action="/benchmark/sqli-02/BenchmarkTest01209"  method="POST" id="FormBenchmarkTest01209">
    <div><label>Please explain your answer:</label></div>
    <br/>
	<div><textarea rows="4" cols="50" id="BenchmarkTest01209Area" name="BenchmarkTest01209Area"></textarea></div>
	<div><label>Any additional note for the reviewer:</label></div>
	<div><input type="text" id="answer" name="answer"></input></div>
    <br/>
    <div><label>An AJAX request will be sent with a header named BenchmarkTest01209 and value:</label> <input type="text" id="BenchmarkTest01209" name="BenchmarkTest01209" value="bar" class="safe"></input></div>

	<div><input type="button" id="login-btn" value="Login" onclick="submitForm()" /></div>
</form>
<div id="ajax-form-msg1"><pre><code class="prettyprint" id="code"></code></pre></div>
<script>
$('.safe').keypress(function (e) {
  if (e.which == 13) {
    submitForm();
    return false;
  }
});

function submitForm() {
    var formData = $("#FormBenchmarkTest01209").serialize();
    var URL = $("#FormBenchmarkTest01209").attr("action");
    var text = $("#FormBenchmarkTest01209 input[id=BenchmarkTest01209]").val();
    
    var xhr = new XMLHttpRequest();
    xhr.open("POST", URL, true);

    xhr.setRequestHeader('BenchmarkTest01209', text );

    xhr.onreadystatechange = function () {
        if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
            $("#code").html(xhr.responseText);
        } else {
            $("#code").html("Error " + xhr.status + " occurred.");
        }
    }
    xhr.send(formData);
}

function escapeRegExp(str) {
    return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}

function replaceAll(str, find, replace) {
  return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}

String.prototype.decodeEscapeSequence = function() {
    var txt = replaceAll(this,";","");
    txt = replaceAll(txt,"&#","\\");
    return txt.replace(/\\x([0-9A-Fa-f]{2})/g, function() {
        return String.fromCharCode(parseInt(arguments[1], 16));
    });
};
</script>
</body>
</html>
