Skip to content

Commit 1f335ae

Browse files
author
zhourenjian
committed
Remove unnecessary "@j2sIgnore"
Fixed bug that SimplePipe should not response with "Transfer-Encoding: chunked" header in cross site script (XSS) or query mode.
1 parent 55fe6e9 commit 1f335ae

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public static class PipeSessionClosedEvent extends CompoundSerializable {
1010

1111
@Override
1212
public void ajaxRun() {
13-
//pipeKey = SimplePipeHelper.registerPipe(this);
1413
SimplePipeRunnable pipe = SimplePipeHelper.getPipe(pipeKey);
1514
if (pipe != null) {
1615
pipeAlive = pipeSetup();
@@ -45,9 +44,6 @@ public void pipeDestroy() {
4544
}
4645
}
4746

48-
/**
49-
* @j2sIgnore
50-
*/
5147
@Override
5248
final public SimpleSerializable[] through(Object... args) {
5349
CompoundSerializable[] cs = convert(args);
@@ -63,9 +59,6 @@ final public SimpleSerializable[] through(Object... args) {
6359

6460
public abstract CompoundSerializable[] convert(Object... args);
6561

66-
/**
67-
* @j2sIgnore
68-
*/
6962
@Override
7063
protected void pipeThrough(Object... args) {
7164
SimplePipeRunnable pipe = SimplePipeHelper.getPipe(pipeKey);

sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/SimplePipeHttpServlet.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ public void init() throws ServletException {
7171
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
7272
throws ServletException, IOException {
7373
String key = req.getParameter(SimplePipeRequest.FORM_PIPE_KEY);
74+
if (key == null) {
75+
resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
76+
return;
77+
}
7478
String type = req.getParameter(SimplePipeRequest.FORM_PIPE_TYPE);
7579
if (type == null) {
7680
type = SimplePipeRequest.PIPE_TYPE_CONTINUUM;
@@ -118,8 +122,9 @@ protected void doPipe(final HttpServletResponse resp, String key, String type)
118122
writer.write("\");");
119123
return;
120124
}
121-
122-
resp.setHeader("Transfer-Encoding", "chunked");
125+
if (SimplePipeRequest.PIPE_TYPE_CONTINUUM.equals(type)) {
126+
resp.setHeader("Transfer-Encoding", "chunked");
127+
}
123128
if (SimplePipeRequest.PIPE_TYPE_SCRIPT.equals(type)) { // iframe
124129
resp.setContentType("text/html; charset=utf-8");
125130
writer = resp.getWriter();

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,10 @@ public static String parseReceived(final String string) {
668668
* @j2sNative
669669
* var key = string.substring(start, end);
670670
* var pipe = net.sf.j2s.ajax.SimplePipeHelper.getPipe(key)
671-
* pipe.pipeAlive = false;
672-
* pipe.pipeClosed();
671+
* if (pipe != null) {
672+
* pipe.pipeAlive = false;
673+
* pipe.pipeClosed();
674+
* }
673675
* net.sf.j2s.ajax.SimplePipeHelper.removePipe(key);
674676
*/ {}
675677
return destroyedKey + ":" + string.substring(start, end)

sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/SimplePipeRunnable.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ public void keepPipeLive() {
149149
* Start pipe monitor to monitor the pipe status. If pipe is non-active,
150150
* try to destroy pipe by calling {@link #pipeDestroy()}.
151151
* User may override this method to use its own monitoring method.
152-
* @j2sIgnore
153152
*/
154153
protected void pipeMonitoring() {
155154
new Thread(new Runnable() {
@@ -180,7 +179,6 @@ public void run() {
180179
* If return interval is less than or equals to 0, the interval time will
181180
* be set to 1000 in {@link #pipeMonitoring()}.
182181
* @return time interval in millisecond.
183-
* @j2sIgnore
184182
*/
185183
protected long pipeMonitoringInterval() {
186184
return 1000;
@@ -262,7 +260,6 @@ public boolean deal(SimpleSerializable ss) {
262260
*
263261
* Attention: Only visible inside {@link #pipeSetup()}.
264262
* @param args
265-
* @j2sIgnore
266263
*/
267264
protected void pipeThrough(Object ... args) {
268265
SimplePipeRunnable pipe = SimplePipeHelper.getPipe(pipeKey);

0 commit comments

Comments
 (0)