@@ -160,6 +160,7 @@ protected static boolean checkXSS(String url, String serialize, SimpleRPCRunnabl
160
160
var ua = navigator.userAgent.toLowerCase ();
161
161
if (ua.indexOf ("msie")!=-1 && ua.indexOf ("opera") == -1){
162
162
limit = 2048;
163
+ limit = 2048 - 44; // ;jsessionid=
163
164
}
164
165
limit -= url.length + 36; // 5 + 6 + 5 + 2 + 5 + 2 + 5;
165
166
var contents = [];
@@ -186,11 +187,33 @@ protected static boolean checkXSS(String url, String serialize, SimpleRPCRunnabl
186
187
} else {
187
188
contents[0] = content;
188
189
}
189
- for (var i = 0; i < contents.length; i++) {
190
+ g.idSet["x" + rnd] = contents;
191
+ // Only send the first request, later server return "continue", and client will get
192
+ // the session id and continue later requests.
193
+ net.sf.j2s.ajax.SimpleRPCRequest.callByScript(rnd, contents.length, 0, contents[0]);
194
+ contents[0] = null;
195
+ return true; // cross site script!
196
+ }
197
+ }
198
+ */ { }
199
+ return false ;
200
+ }
201
+
202
+ static void callByScript (String rnd , String length , String i , String content ) {
203
+ /**
204
+ * @j2sNative
205
+ var g = net.sf.j2s.ajax.SimpleRPCRequest;
206
+ var runnable = g.idSet["o" + rnd];
207
+ if (runnable == null) return;
208
+ var url = runnable.getHttpURL();
209
+ var session = g.idSet["s" + rnd];
210
+ if (session != null && window["script.get.session.url"] != false) {
211
+ url += ";jsessionid=" + session;
212
+ }
190
213
var script = document.createElement ("SCRIPT");
191
214
script.type = "text/javascript";
192
- script.src = url + "?jzn=" + rnd + "&jzp=" + contents. length
193
- + "&jzc=" + (i + 1) + "&jzz=" + contents[i] ;
215
+ script.src = url + "?jzn=" + rnd + "&jzp=" + length
216
+ + "&jzc=" + (i + 1) + "&jzz=" + content ;
194
217
if (typeof (script.onreadystatechange) == "undefined") { // W3C
195
218
script.onerror = function () {
196
219
this.onerror = null;
@@ -223,12 +246,25 @@ protected static boolean checkXSS(String url, String serialize, SimpleRPCRunnabl
223
246
}
224
247
var head = document.getElementsByTagName ("HEAD")[0];
225
248
head.appendChild (script);
226
- }
227
- return true; // cross site script!
228
- }
229
- }
230
- */ { }
231
- return false ;
249
+ */ {}
250
+ }
251
+
252
+ static void sendRestRequests (String nameID ) {
253
+ /**
254
+ * The following codes may be modified to send out requests one by one.
255
+ * @j2sNative
256
+ * var g = net.sf.j2s.ajax.SimpleRPCRequest;
257
+ * var xcontent = g.idSet["x" + nameID];
258
+ * if (xcontent != null) {
259
+ * for (var i = 0; i < xcontent.length; i++) {
260
+ * if (xcontent[i] != null) {
261
+ * g.callByScript(nameID, xcontent.length, i, xcontent[i]);
262
+ * xcontent[i] = null;
263
+ * }
264
+ * }
265
+ * g.idSet["x" + nameID] = null;
266
+ * }
267
+ */ {}
232
268
}
233
269
234
270
/**
@@ -258,13 +294,27 @@ static void xssNotify(String nameID, String response) {
258
294
}
259
295
}
260
296
*/ { }
261
- if (response == "continue" ) return ;
297
+ if (response == "continue" ) {
298
+ boolean restNotEmpty = false ;
299
+ /**
300
+ * @j2sNative
301
+ * var g = net.sf.j2s.ajax.SimpleRPCRequest;
302
+ * if (g.idSet["x" + nameID] != null) {
303
+ * restNotEmpty = true;
304
+ * }
305
+ */ {}
306
+ if (restNotEmpty ) sendRestRequests (nameID );
307
+ return ;
308
+ }
262
309
SimpleRPCRunnable runnable = null ;
263
310
/**
264
311
* @j2sNative
265
312
var g = net.sf.j2s.ajax.SimpleRPCRequest;
266
313
runnable = g.idSet["o" + nameID];
267
314
g.idSet["o" + nameID] = null;
315
+ if (g.idSet["s" + nameID] != null) {
316
+ g.idSet["s" + nameID] = null;
317
+ }
268
318
if (response == null && runnable != null) { // error!
269
319
runnable.ajaxFail();
270
320
return;
@@ -305,4 +355,12 @@ static void xssNotify(String nameID, String response) {
305
355
runnable .ajaxOut ();
306
356
}
307
357
}
358
+
359
+ static void xssSession (String nameID , String sessionID ) {
360
+ /**
361
+ * @j2sNative
362
+ var g = net.sf.j2s.ajax.SimpleRPCRequest;
363
+ g.idSet["s" + nameID] = sessionID;
364
+ */ {}
365
+ }
308
366
}
0 commit comments