Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Commit abdb14e

Browse files
jayasheelankumaryaminikb
authored andcommitted
Fixes #21897: Update commons-fileupload version to 1.3.2 (#21901)
1 parent c60b806 commit abdb14e

File tree

4 files changed

+151
-6
lines changed

4 files changed

+151
-6
lines changed

appserver/admingui/war/src/main/webapp/WEB-INF/sun-web.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@
6161
<parameter-encoding default-charset="UTF-8" />
6262
</locale-charset-info>
6363

64-
<class-loader delegate="true" extra-class-path="WEB-INF/extra/webui-jsf-suntheme-4.0.2.10.jar:WEB-INF/extra/dojo-ajax-nodemo-0.4.1.jar:WEB-INF/extra/webui-jsf-4.0.2.10.jar:WEB-INF/extra/commons-fileupload-1.1.1.jar:WEB-INF/extra/commons-io-1.3.1.jar:WEB-INF/extra/json-1.0.jar:WEB-INF/extra/prototype-1.5.0.jar" />
64+
<class-loader delegate="true" extra-class-path="WEB-INF/extra/webui-jsf-suntheme-4.0.2.10.jar:WEB-INF/extra/dojo-ajax-nodemo-0.4.1.jar:WEB-INF/extra/webui-jsf-4.0.2.10.jar:WEB-INF/extra/commons-fileupload-1.3.2.jar:WEB-INF/extra/commons-io-1.3.1.jar:WEB-INF/extra/json-1.0.jar:WEB-INF/extra/prototype-1.5.0.jar" />
6565

6666
</sun-web-app>

appserver/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@
799799
<dependency>
800800
<groupId>commons-fileupload</groupId>
801801
<artifactId>commons-fileupload</artifactId>
802-
<version>1.1.1</version>
802+
<version>1.3.2</version>
803803
</dependency>
804804
<dependency>
805805
<groupId>com.sun.messaging.mq</groupId>

appserver/web/web-core/src/main/java/org/apache/catalina/fileupload/MultipartStream.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,9 @@ private void notifyListener() {
340340
byte[] boundary,
341341
int bufSize,
342342
ProgressNotifier pNotifier) {
343-
this.input = input;
344-
this.bufSize = bufSize;
345-
this.buffer = new byte[bufSize];
346-
this.notifier = pNotifier;
343+
if (boundary == null) {
344+
throw new IllegalArgumentException("boundary is null");
345+
}
347346

348347
// We prepend CR/LF to the boundary to chop trailng CR/LF from
349348
// body-data tokens.
@@ -352,6 +351,12 @@ private void notifyListener() {
352351
throw new IllegalArgumentException(
353352
"The buffer size specified for the MultipartStream is too small");
354353
}
354+
355+
this.input = input;
356+
this.bufSize = bufSize;
357+
this.buffer = new byte[bufSize];
358+
this.notifier = pNotifier;
359+
355360
this.boundary = new byte[this.boundaryLength];
356361
this.keepRegion = this.boundary.length;
357362
System.arraycopy(BOUNDARY_PREFIX, 0, this.boundary, 0,
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
12+
* or packager/legal/LICENSE.txt. See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at packager/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* Oracle designates this particular file as subject to the "Classpath"
20+
* exception as provided by Oracle in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*
40+
*
41+
* This file incorporates work covered by the following copyright and
42+
* permission notice:
43+
*
44+
* Licensed to the Apache Software Foundation (ASF) under one or more
45+
* contributor license agreements. See the NOTICE file distributed with
46+
* this work for additional information regarding copyright ownership.
47+
* The ASF licenses this file to You under the Apache License, Version 2.0
48+
* (the "License"); you may not use this file except in compliance with
49+
* the License. You may obtain a copy of the License at
50+
*
51+
* http://www.apache.org/licenses/LICENSE-2.0
52+
*
53+
* Unless required by applicable law or agreed to in writing, software
54+
* distributed under the License is distributed on an "AS IS" BASIS,
55+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
56+
* See the License for the specific language governing permissions and
57+
* limitations under the License.
58+
*/
59+
package org.apache.catalina.fileupload;
60+
61+
import static org.junit.Assert.assertNotNull;
62+
63+
import java.io.ByteArrayInputStream;
64+
import java.io.InputStream;
65+
66+
import org.junit.Test;
67+
68+
69+
/**
70+
* Unit tests {@link org.apache.commons.fileupload.MultipartStream}.
71+
*
72+
* @version $Id$
73+
*/
74+
public class MultipartStreamTest {
75+
76+
static private final String BOUNDARY_TEXT = "myboundary";
77+
78+
/**
79+
* The Carriage Return ASCII character value.
80+
*/
81+
public static final byte CR = 0x0D;
82+
83+
84+
/**
85+
* The Line Feed ASCII character value.
86+
*/
87+
public static final byte LF = 0x0A;
88+
89+
90+
/**
91+
* The dash (-) ASCII character value.
92+
*/
93+
public static final byte DASH = 0x2D;
94+
95+
@Test
96+
public void testThreeParamConstructor() throws Exception {
97+
final String strData = "foobar";
98+
final byte[] contents = strData.getBytes();
99+
InputStream input = new ByteArrayInputStream(contents);
100+
byte[] boundary = BOUNDARY_TEXT.getBytes();
101+
byte[] BOUNDARY_PREFIX = {CR, LF, DASH, DASH};
102+
int iBufSize =
103+
boundary.length + BOUNDARY_PREFIX.length + 1;
104+
MultipartStream ms = new MultipartStream(
105+
input,
106+
boundary,
107+
iBufSize,
108+
new MultipartStream.ProgressNotifier(null, contents.length));
109+
assertNotNull(ms);
110+
}
111+
112+
@Test(expected=IllegalArgumentException.class)
113+
public void testSmallBuffer() throws Exception {
114+
final String strData = "foobar";
115+
final byte[] contents = strData.getBytes();
116+
InputStream input = new ByteArrayInputStream(contents);
117+
byte[] boundary = BOUNDARY_TEXT.getBytes();
118+
int iBufSize = 1;
119+
@SuppressWarnings("unused")
120+
MultipartStream ms = new MultipartStream(
121+
input,
122+
boundary,
123+
iBufSize,
124+
new MultipartStream.ProgressNotifier(null, contents.length));
125+
}
126+
127+
@Test
128+
public void testTwoParamConstructor() throws Exception {
129+
final String strData = "foobar";
130+
final byte[] contents = strData.getBytes();
131+
InputStream input = new ByteArrayInputStream(contents);
132+
byte[] boundary = BOUNDARY_TEXT.getBytes();
133+
MultipartStream ms = new MultipartStream(
134+
input,
135+
boundary,
136+
new MultipartStream.ProgressNotifier(null, contents.length));
137+
assertNotNull(ms);
138+
}
139+
140+
}

0 commit comments

Comments
 (0)