diff --git a/java/org/apache/jasper/compiler/PageInfo.java b/java/org/apache/jasper/compiler/PageInfo.java index a943f1f7e517..9162650c9d2b 100644 --- a/java/org/apache/jasper/compiler/PageInfo.java +++ b/java/org/apache/jasper/compiler/PageInfo.java @@ -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 { diff --git a/test/org/apache/jasper/compiler/TestPageInfo.java b/test/org/apache/jasper/compiler/TestPageInfo.java index 4a97557baee6..c6ccc424275d 100644 --- a/test/org/apache/jasper/compiler/TestPageInfo.java +++ b/test/org/apache/jasper/compiler/TestPageInfo.java @@ -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"); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index f0d04f8c55be..2ca6d963bb5a 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -458,6 +458,11 @@ language specification when expr-a is a literal null. (markt) + + Accept a page directive buffer size of 0kb again. The JSP + specification only requires the size to be expressed in kilobytes. + Pull request 1271 provided by Arturo Bernal. +