From fe48dde5866ab8eb03d2a3498cbd30dc4666c630 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 16 Oct 2023 12:35:27 +0200 Subject: [PATCH 1/3] Issue #10731 wrong context attribute name javax.servlet instead of jakarta.servlet (#10735) * Issue #10731 wrong context attribute name javax.servlet instead of jakarta.servlet Signed-off-by: Olivier Lamy * Update jetty-server/src/main/java/org/eclipse/jetty/server/MultiPartFormInputStream.java Co-authored-by: Simone Bordet * Update jetty-server/src/main/java/org/eclipse/jetty/server/Request.java Co-authored-by: Simone Bordet * fix javadoc Signed-off-by: Olivier Lamy * more usage of constant Signed-off-by: Olivier Lamy --------- Signed-off-by: Olivier Lamy Co-authored-by: Simone Bordet --- .../src/test/java/org/eclipse/jetty/ee10/jstl/JspConfig.java | 3 ++- .../src/test/java/org/eclipse/jetty/ee9/jstl/JspConfig.java | 3 ++- .../eclipse/jetty/ee9/nested/MultiPartFormInputStream.java | 5 +++-- .../java/org/eclipse/jetty/ee9/webapp/WebAppContext.java | 2 +- .../org/eclipse/jetty/ee9/webapp/WebInfConfiguration.java | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/jetty-ee10/jetty-ee10-glassfish-jstl/src/test/java/org/eclipse/jetty/ee10/jstl/JspConfig.java b/jetty-ee10/jetty-ee10-glassfish-jstl/src/test/java/org/eclipse/jetty/ee10/jstl/JspConfig.java index f5b906e75abb..c36ff2aa5708 100644 --- a/jetty-ee10/jetty-ee10-glassfish-jstl/src/test/java/org/eclipse/jetty/ee10/jstl/JspConfig.java +++ b/jetty-ee10/jetty-ee10-glassfish-jstl/src/test/java/org/eclipse/jetty/ee10/jstl/JspConfig.java @@ -17,6 +17,7 @@ import java.net.URI; import java.nio.file.Path; +import jakarta.servlet.ServletContext; import org.eclipse.jetty.ee10.webapp.WebAppContext; /** @@ -27,7 +28,7 @@ public class JspConfig { public static void init(WebAppContext context, URI baseUri, File scratchDir) { - context.setAttribute("jakarta.servlet.context.tempdir", scratchDir); + context.setAttribute(ServletContext.TEMPDIR, scratchDir); context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/jetty-jakarta-servlet-api-[^/]*\\.jar$|.*jakarta.servlet.jsp.jstl-[^/]*\\.jar|.*taglibs-standard.*\\.jar"); context.setWar(baseUri.toASCIIString()); diff --git a/jetty-ee9/jetty-ee9-glassfish-jstl/src/test/java/org/eclipse/jetty/ee9/jstl/JspConfig.java b/jetty-ee9/jetty-ee9-glassfish-jstl/src/test/java/org/eclipse/jetty/ee9/jstl/JspConfig.java index b346ee7ddb01..2dd1052f05cb 100644 --- a/jetty-ee9/jetty-ee9-glassfish-jstl/src/test/java/org/eclipse/jetty/ee9/jstl/JspConfig.java +++ b/jetty-ee9/jetty-ee9-glassfish-jstl/src/test/java/org/eclipse/jetty/ee9/jstl/JspConfig.java @@ -16,6 +16,7 @@ import java.io.File; import java.net.URI; +import jakarta.servlet.ServletContext; import org.eclipse.jetty.ee9.webapp.WebAppContext; /** @@ -26,7 +27,7 @@ public class JspConfig { public static void init(WebAppContext context, URI baseUri, File scratchDir) { - context.setAttribute("jakarta.servlet.context.tempdir", scratchDir); + context.setAttribute(ServletContext.TEMPDIR, scratchDir); context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", System.getProperty("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern")); context.setWar(baseUri.toASCIIString()); diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/MultiPartFormInputStream.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/MultiPartFormInputStream.java index 2f30342b8354..6371dc63ac9a 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/MultiPartFormInputStream.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/MultiPartFormInputStream.java @@ -386,7 +386,7 @@ public String getContentDispositionFilename() * @param in Request input stream * @param contentType Content-Type header * @param config MultipartConfigElement - * @param contextTmpDir javax.servlet.context.tempdir + * @param contextTmpDir {@value jakarta.servlet.ServletContext#TEMPDIR} */ public MultiPartFormInputStream(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir) { @@ -397,7 +397,8 @@ public MultiPartFormInputStream(InputStream in, String contentType, MultipartCon * @param in Request input stream * @param contentType Content-Type header * @param config MultipartConfigElement - * @param contextTmpDir javax.servlet.context.tempdir + * @param contextTmpDir {@value jakarta.servlet.ServletContext#TEMPDIR} + * @param maxParts the maximum number of parts that can be parsed from the multipart content (0 for no parts allowed, -1 for unlimited parts). */ public MultiPartFormInputStream(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir, int maxParts) { diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java index 31460dafdd2b..c76a53dfe2f7 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java @@ -1157,7 +1157,7 @@ public void setContextWhiteList(String... contextWhiteList) /** * Set temporary directory for context. - * The jakarta.servlet.context.tempdir attribute is also set. + * The {@value jakarta.servlet.ServletContext#TEMPDIR} attribute is also set. * * @param dir Writable temporary directory. */ diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebInfConfiguration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebInfConfiguration.java index ddc6a6b324db..77e37f4fee59 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebInfConfiguration.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebInfConfiguration.java @@ -113,7 +113,7 @@ public void cloneConfigure(WebAppContext template, WebAppContext context) throws * exit depends on value of persistTempDirectory. * *
  • - * Iff jakarta.servlet.context.tempdir context attribute is set for + * Iff {@value jakarta.servlet.ServletContext#TEMPDIR} context attribute is set for * this webapp && exists && writeable, then use it. Set delete on exit depends on * value of persistTempDirectory. *
  • From c210043a227c41a8bf72ab8368d6e1a1151a8498 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 16 Oct 2023 20:48:28 -0500 Subject: [PATCH 2/3] Address build/test failure against bad entities. (#10742) Bad entities in test case can lead to: * external URL references * required HTTP GET requests * not testing redirectEntity / resolveEntity (the whole point of the test) Signed-off-by: Joakim Erdfelt --- .../java/org/eclipse/jetty/xml/XmlParserTest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jetty-core/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlParserTest.java b/jetty-core/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlParserTest.java index 3a84117d0d9b..6ad092da109f 100644 --- a/jetty-core/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlParserTest.java +++ b/jetty-core/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlParserTest.java @@ -20,6 +20,7 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.junit.jupiter.api.Test; +import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; @@ -35,7 +36,16 @@ public void testXmlParser() throws Exception { // we want to parse a simple XML, no dtds, no xsds. // just do it, without validation - XmlParser parser = new XmlParser(false); + XmlParser parser = new XmlParser(false) + { + @Override + protected InputSource resolveEntity(String pid, String sid) + { + InputSource inputSource = super.resolveEntity(pid, sid); + assertNotNull(inputSource, "You are using entities in your XML that don't match your redirectEntity mappings: pid=" + pid + ", sid=" + sid); + return inputSource; + } + }; URL url = XmlParserTest.class.getResource("configureSimple.xml"); assertNotNull(url); XmlParser.Node testDoc = parser.parse(url.toString()); From fe0fbdda325409b43e7918af5c9ee82ac112d55c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 17 Oct 2023 13:58:34 +1000 Subject: [PATCH 3/3] use constant Signed-off-by: Olivier Lamy --- .../java/org/eclipse/jetty/ee10/webapp/WebInfConfiguration.java | 2 +- .../src/main/java/org/eclipse/jetty/ee9/nested/Request.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebInfConfiguration.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebInfConfiguration.java index 661592956272..6b793044a41d 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebInfConfiguration.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebInfConfiguration.java @@ -111,7 +111,7 @@ public void deconfigure(WebAppContext context) throws Exception * exit depends on value of persistTempDirectory. * *
  • - * Iff jakarta.servlet.context.tempdir context attribute is set for + * If {@value jakarta.servlet.ServletContext#TEMPDIR} context attribute is set for * this webapp && exists && writeable, then use it. Set delete on exit depends on * value of persistTempDirectory. *
  • diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Request.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Request.java index c09a8c4291a5..635355a3cdfc 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Request.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Request.java @@ -1997,7 +1997,7 @@ private void setNonComplianceViolationsOnRequest() private MultiPartFormInputStream newMultiParts(MultipartConfigElement config, int maxParts) throws IOException { return new MultiPartFormInputStream(getInputStream(), getContentType(), config, - (_context != null ? (File)_context.getAttribute("jakarta.servlet.context.tempdir") : null), maxParts); + (_context != null ? (File)_context.getAttribute(ServletContext.TEMPDIR) : null), maxParts); } @Override