You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/05/02 12:30:51 UTC
[tomcat] branch 10.1.x updated: Fix BZ 66582 - not all static imports are valid for EL
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new afc0fd4c13 Fix BZ 66582 - not all static imports are valid for EL
afc0fd4c13 is described below
commit afc0fd4c1356953b71c1d879cdc2342d38d3fb49
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue May 2 13:30:30 2023 +0100
Fix BZ 66582 - not all static imports are valid for EL
https://bz.apache.org/bugzilla/show_bug.cgi?id=66582
---
.../org/apache/jasper/runtime/PageContextImpl.java | 6 +++++-
.../servlet/jsp/el/TestImportELResolver.java | 16 +++++++++++++++
.../apache/tomcat/unittest/TesterBug66582.java} | 24 +++-------------------
test/webapp/bug6nnnn/bug66582.jsp | 22 ++++++++++++++++++++
webapps/docs/changelog.xml | 9 ++++++++
5 files changed, 55 insertions(+), 22 deletions(-)
diff --git a/java/org/apache/jasper/runtime/PageContextImpl.java b/java/org/apache/jasper/runtime/PageContextImpl.java
index 13ea49587e..d2dbf8faf2 100644
--- a/java/org/apache/jasper/runtime/PageContextImpl.java
+++ b/java/org/apache/jasper/runtime/PageContextImpl.java
@@ -718,7 +718,11 @@ public class PageContextImpl extends PageContext {
for (String classImport : classImports) {
if (classImport.startsWith("static ")) {
classImport = classImport.substring(7);
- ih.importStatic(classImport);
+ try {
+ ih.importStatic(classImport);
+ } catch (ELException e) {
+ // Ignore - not all static imports are valid for EL
+ }
} else {
ih.importClass(classImport);
}
diff --git a/test/jakarta/servlet/jsp/el/TestImportELResolver.java b/test/jakarta/servlet/jsp/el/TestImportELResolver.java
index b68529d821..652f04dad1 100644
--- a/test/jakarta/servlet/jsp/el/TestImportELResolver.java
+++ b/test/jakarta/servlet/jsp/el/TestImportELResolver.java
@@ -16,6 +16,8 @@
*/
package jakarta.servlet.jsp.el;
+import jakarta.servlet.http.HttpServletResponse;
+
import org.junit.Assert;
import org.junit.Test;
@@ -36,4 +38,18 @@ public class TestImportELResolver extends TomcatBaseTest {
Assert.assertTrue(result.contains("EL - Long min value is -9223372036854775808"));
Assert.assertTrue(result.contains("JSP - Long min value is -9223372036854775808"));
}
+
+
+ // https://bz.apache.org/bugzilla/show_bug.cgi?id=66582
+ @Test
+ public void testImportStaticFieldFromInterface() throws Exception {
+ getTomcatInstanceTestWebapp(false, true);
+
+ ByteChunk res = new ByteChunk();
+ int rc = getUrl("http://localhost:" + getPort() + "/test/bug6nnnn/bug66582.jsp", res, null);
+
+ Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+ String result = res.toString();
+ Assert.assertFalse(result, result.contains("data"));
+ }
}
diff --git a/test/jakarta/servlet/jsp/el/TestImportELResolver.java b/test/org/apache/tomcat/unittest/TesterBug66582.java
similarity index 51%
copy from test/jakarta/servlet/jsp/el/TestImportELResolver.java
copy to test/org/apache/tomcat/unittest/TesterBug66582.java
index b68529d821..fb8c97116f 100644
--- a/test/jakarta/servlet/jsp/el/TestImportELResolver.java
+++ b/test/org/apache/tomcat/unittest/TesterBug66582.java
@@ -14,26 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package jakarta.servlet.jsp.el;
+package org.apache.tomcat.unittest;
-import org.junit.Assert;
-import org.junit.Test;
-
-import org.apache.catalina.startup.TomcatBaseTest;
-import org.apache.tomcat.util.buf.ByteChunk;
-
-public class TestImportELResolver extends TomcatBaseTest {
-
- // https://bz.apache.org/bugzilla/show_bug.cgi?id=66441
- @Test
- public void testImportStaticFields() throws Exception {
- getTomcatInstanceTestWebapp(false, true);
-
- ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug6nnnn/bug66441.jsp");
-
- String result = res.toString();
-
- Assert.assertTrue(result.contains("EL - Long min value is -9223372036854775808"));
- Assert.assertTrue(result.contains("JSP - Long min value is -9223372036854775808"));
- }
+public interface TesterBug66582 {
+ String DATA = "data";
}
diff --git a/test/webapp/bug6nnnn/bug66582.jsp b/test/webapp/bug6nnnn/bug66582.jsp
new file mode 100644
index 0000000000..4def99d32d
--- /dev/null
+++ b/test/webapp/bug6nnnn/bug66582.jsp
@@ -0,0 +1,22 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@ page import="static org.apache.tomcat.unittest.TesterBug66582.DATA"%>
+<html>
+ <body>
+ <p>${DATA}</p>
+ </body>
+</html>
\ No newline at end of file
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 2112a1c029..49c8db2319 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -144,6 +144,15 @@
</add>
</changelog>
</subsection>
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ <bug>66582</bug>: Account for EL having stricter requirements for static
+ imports than JSPs when adding JSP static imports to the EL context.
+ (markt)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="WebSocket">
<changelog>
<fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org