In our application, we have a XSS filter which handle every request and checks the values ..
But we discovered a case when the request is Ajax and our filter does not work ..
It does not work when AJAX request is done like :
$.ajax({
url: '${someUrl}' ,
type: 'POST',
cache: false,
data: JSON.stringify(checkForm),
dataType: 'json',
contentType: 'application/json',
Here the values are in JSON format, looks like:
{"poNumber":"123144","voucher":"","quoteNumber":"","collectNumber":"","otherCarrier":"","deliveryMethodCode":"21","paymentMethodCode":"invoice","concerns":""}
It does work when:
ACC.pg = {
addToCart: function() {
var productCode = $(this).data("productcode");
var params = {
"productCodePost": productCode,
"qty": 1
};
$.post("${url}", params, ACC.quickordercustom.handleSuccess);
qty=1&productCodePost=12123
The filter takes the params from the request like
Map<String,String[]> params = req.getParameterMap();
for (Map.Entry<String,String[]> entry : params.entrySet()) {
String v[] = entry.getValue();
....
}
But for case 1 , req.getParameterMap()
is empty .. any suggestions?
Thanks Y