..
....
VAR postData = "input="+ escape(inputJSON) +"&
amp;script="+escape(x
ML)+
"&fe
Edgeneral=" + escape(feedGeneral);
XmlHtt
PRequest.open("POST",url,true);
XmlHttpRequest.setRequestHeader("Content
-type","application/x-www-form-url
encoded");
XmlHttpRequest.send(postData);
台Servlet中得到得到数据+被空格代替,使得script中的index += 1;变成了index = 1;从而导致后台Java代码在跑script出现死循环。
[来自http://www.w3.
Control
names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as
described in [R
fc1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal
dig
ITs representing the ASCII code of the character. Line
breaks are represented as "CR LF" p
airs (i.e., `%0D%0A').
然而使用form来提交方式来发起request却不会出现类似的问题,而form默认的Content-Type也是application/x-www-form-urlencoded:
$('
test').innerHTML = "<form t
arget='_blank' id='test_form' action='./gen_feed' method='post'>"
+ "<input type='text' name='input' /><input type='text' name='script' />"
+ "<input type='text' name='feedGeneral' /><input type='hidden' name='format' value='" + this.feed_type + "'
/>"
+ "<input type='s
ubmit' value='gen' /></form>";
var test_form = $('test_form');
test_form.elements[0].value = inputJSON;
test_form.elements[1].value = script;
test_form.elements[2].value = feedGeneral;
test_form.submit();
仍未发现问题到底出在何处,暂做备忘。暂时把script中的‘+'都用‘-'代替,index += 1;改成index -= -1;呵呵,以后有人看到这段自动生成的诡异脚本,不