Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit997419d

Browse files
author
zhourenjian
committed
1. Fixing bug that SimplePipe/CompoundPipe is not stable and may generate lots of IFRAME elements.
2. Support SimpleSerializable to generate a much smaller serialized string by ignoring fields with default values.
1 parent7b47e96 commit997419d

File tree

4 files changed

+33
-16
lines changed

4 files changed

+33
-16
lines changed

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/CompoundPipeRequest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ private static CompoundPipeRunnable createPipe(String id) {
8888
@Override
8989
publicvoidajaxOut() {
9090
super.ajaxOut();
91+
if (!pipeAlive) {
92+
return;// Not setup yet!
93+
}
9194
for (inti =0;i <pipes.length;i++) {
9295
if (pipes[i] !=null) {
9396
pipes[i].pipeKey =pipeKey;

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/CompoundPipeRunnable.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ public boolean pipeSetup() {
6767

6868
@Override
6969
publicbooleanisPipeLive() {
70-
if (status <3) {// connected
70+
if (pipeAlive &&status <3) {// connected
7171
returntrue;// still in starting status
7272
}
7373
if (super.isPipeLive()) {
7474
for (inti =0;i <pipes.length;i++) {
75-
if (pipes[i] !=null) {
76-
if (pipes[i].isPipeLive()) {
77-
returntrue;
78-
}
75+
if (pipes[i] !=null &&pipes[i].isPipeLive()) {
76+
returntrue;
7977
}
8078
}
8179
}

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/CompoundPipeSession.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ public boolean pipeDestroy() {
5151
returntrue;
5252
}
5353

54+
@Override
55+
publicvoidpipeFailed() {
56+
SimplePipeRunnablepipe =SimplePipeHelper.getPipe(pipeKey);
57+
if (pipeinstanceofCompoundPipeRunnable) {
58+
CompoundPipeRunnablecp = (CompoundPipeRunnable)pipe;
59+
if (cp.status <3) {
60+
cp.status =3;// connected but failed to create child pipe
61+
}
62+
updateStatus(false);
63+
}
64+
}
65+
5466
@Override
5567
finalpublicSimpleSerializable[]through(Object...args) {
5668
CompoundSerializable[]cs =convert(args);

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/SimplePipeRequest.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,14 @@ static void pipeScript(SimplePipeRunnable runnable) { // xss
472472
* @param runnable
473473
* @param domain
474474
* @j2sNative
475+
var pipeKey = runnable.pipeKey;
476+
var ifrEl = document.getElementById (pipeKey);
477+
if (ifrEl != null) {
478+
ifrEl.parentNode.removeChild (ifrEl);
479+
ifrEl = null;
480+
}
475481
var ifr = document.createElement ("IFRAME");
476482
ifr.style.display = "none";
477-
var pipeKey = runnable.pipeKey;
478483
var spr = net.sf.j2s.ajax.SimplePipeRequest;
479484
var url = runnable.getPipeURL();
480485
var src = url + (url.indexOf('?') != -1 ? "&" : "?")
@@ -855,8 +860,9 @@ static void ajaxPipe(final SimplePipeRunnable runnable) {
855860
if ((!isXSS ||isSubdomain) &&pipeMode ==MODE_PIPE_CONTINUUM)
856861
/**
857862
* @j2sNative
858-
* var subdomain = net.sf.j2s.ajax.SimplePipeRequest.adjustSubdomain (isSubdomain);
859-
* net.sf.j2s.ajax.SimplePipeRequest.pipeContinuum (runnable, subdomain);
863+
* var spr = net.sf.j2s.ajax.SimplePipeRequest;
864+
* var subdomain = spr.adjustSubdomain (isSubdomain);
865+
* spr.pipeContinuum (runnable, subdomain);
860866
*/
861867
{
862868
//pipeQuery(runnable, "continuum");
@@ -868,14 +874,13 @@ public void run() {
868874
}else
869875
/**
870876
* @j2sNative
871-
if (isXSS && isSubdomain
872-
&&net.sf.j2s.ajax.SimplePipeRequest.isSubdomainXSSSupported ()) {
873-
var subdomain =net.sf.j2s.ajax.SimplePipeRequest.adjustSubdomain (isSubdomain);
874-
net.sf.j2s.ajax.SimplePipeRequest.pipeSubdomainQuery (runnable, subdomain);
877+
var spr = net.sf.j2s.ajax.SimplePipeRequest;
878+
if (isXSS&&isSubdomain && spr.isSubdomainXSSSupported ()) {
879+
var subdomain =spr.adjustSubdomain (isSubdomain);
880+
spr.pipeSubdomainQuery (runnable, subdomain);
875881
return;
876882
}
877883
runnable.queryEnded = true;
878-
var spr = net.sf.j2s.ajax.SimplePipeRequest;
879884
(function (pipeFun, key, created) { // Function that simulate a thread
880885
return function () {
881886
var sph = net.sf.j2s.ajax.SimplePipeHelper;
@@ -1073,7 +1078,6 @@ public void run() {
10731078
try {
10741079
p.pipeXHRQuery (p.xhrHandle, method, url, data);
10751080
} catch (e) {
1076-
alert (e);
10771081
p.xhrHandle.onreadystatechange = function () {};
10781082
p.xhrHandle = null;
10791083
document.domain = p.parentDomain;
@@ -1090,8 +1094,8 @@ public void run() {
10901094
document.domain = p.parentDomain;
10911095
with (window.parent) {
10921096
runnable.pipeAlive = false;
1093-
runnable.pipeClosed();
1094-
net.sf.j2s.ajax.SimplePipeHelper.removePipe(p.key);
1097+
runnable.pipeClosed();
1098+
net.sf.j2s.ajax.SimplePipeHelper.removePipe(p.key);
10951099
net.sf.j2s.ajax.SimplePipeRequest.pipeIFrameClean (p.key);
10961100
}
10971101
} else {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp