Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions java/org/apache/jasper/compiler/PageInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,10 @@ public void setBufferValue(String value, Node n, ErrorDispatcher err) throws Jas
try {
@SuppressWarnings("null") // value can't be null here
int k = Integer.parseInt(value.substring(0, value.length() - 2));
// JSP.7.2.1 requires a positive integer. Values outside this
// range are invalid in themselves and would additionally
// overflow the multiplication by 1024 below.
if (k <= 0 || k > Integer.MAX_VALUE / 1024) {
// Zero is a valid size and means no buffering. Negative sizes
// are invalid and larger sizes would overflow the
// multiplication by 1024 below.
if (k < 0 || k > Integer.MAX_VALUE / 1024) {
if (n == null) {
err.jspError("jsp.error.page.invalid.buffer");
} else {
Expand Down
5 changes: 2 additions & 3 deletions test/org/apache/jasper/compiler/TestPageInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ public void testBufferValid() throws Exception {

@Test
public void testBufferZero() throws Exception {
// JSP.7.2.1 requires a positive integer
doTestBuffer("zero", 500, "invalid value for buffer");
// A buffer size of 0kb is valid and means no buffering
doTestBuffer("zero", 200, null);
}

@Test
public void testBufferNegative() throws Exception {
// JSP.7.2.1 requires a positive integer
doTestBuffer("negative", 500, "invalid value for buffer");
}

Expand Down
5 changes: 5 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@
language specification when <code>expr-a</code> is a literal
<code>null</code>. (markt)
</fix>
<fix>
Accept a page directive buffer size of <code>0kb</code> again. The JSP
specification only requires the size to be expressed in kilobytes.
Pull request <pr>1271</pr> provided by Arturo Bernal.
</fix>
</changelog>
</subsection>
<subsection name="Cluster">
Expand Down
Loading