From 73f28b4ab0a54c6a26cc5f8ae7ccc77c7dacad02 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 20 Jun 2024 09:32:47 -0500 Subject: [PATCH] Update XML entity refs to support jetty.org too. --- jetty-xml/pom.xml | 8 ++ .../eclipse/jetty/xml/XmlConfiguration.java | 73 +++++++++---------- .../jetty/xml/XmlConfigurationTest.java | 8 +- 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index f3dc3292203..ec601f8ddb6 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -52,6 +52,14 @@ @{argLine} ${jetty.surefire.argLine} --add-reads org.eclipse.jetty.xml=org.eclipse.jetty.logging + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index 31899d1a3f9..9e274cbcda5 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -1949,54 +1949,49 @@ public class XmlConfiguration _entry = entry; Class klass = XmlConfiguration.class; + URL config60 = klass.getResource("configure_6_0.dtd"); URL config76 = klass.getResource("configure_7_6.dtd"); URL config90 = klass.getResource("configure_9_0.dtd"); URL config93 = klass.getResource("configure_9_3.dtd"); URL config100 = klass.getResource("configure_10_0.dtd"); - redirectEntity("configure.dtd", config93); - redirectEntity("configure_1_0.dtd", config60); - redirectEntity("configure_1_1.dtd", config60); - redirectEntity("configure_1_2.dtd", config60); - redirectEntity("configure_1_3.dtd", config60); - redirectEntity("configure_6_0.dtd", config60); - redirectEntity("configure_7_6.dtd", config76); - redirectEntity("configure_9_0.dtd", config90); - redirectEntity("configure_9_3.dtd", config93); - redirectEntity("configure_10_0.dtd", config100); + Map dtdRefMap = new HashMap<>(); + dtdRefMap.put("configure.dtd", config93); + dtdRefMap.put("configure_1_0.dtd", config60); + dtdRefMap.put("configure_1_1.dtd", config60); + dtdRefMap.put("configure_1_2.dtd", config60); + dtdRefMap.put("configure_1_3.dtd", config60); + dtdRefMap.put("configure_6_0.dtd", config60); + dtdRefMap.put("configure_7_6.dtd", config76); + dtdRefMap.put("configure_9_0.dtd", config90); + dtdRefMap.put("configure_9_3.dtd", config93); + dtdRefMap.put("configure_10_0.dtd", config100); - redirectEntity("http://jetty.mortbay.org/configure.dtd", config93); - redirectEntity("http://jetty.eclipse.org/configure.dtd", config93); - redirectEntity("https://jetty.eclipse.org/configure.dtd", config93); - redirectEntity("http://www.eclipse.org/jetty/configure.dtd", config93); - redirectEntity("https://www.eclipse.org/jetty/configure.dtd", config93); - redirectEntity("http://eclipse.org/jetty/configure.dtd", config93); - redirectEntity("https://eclipse.org/jetty/configure.dtd", config93); - redirectEntity("http://www.eclipse.dev/jetty/configure.dtd", config93); - redirectEntity("https://www.eclipse.dev/jetty/configure.dtd", config93); - redirectEntity("http://eclipse.dev/jetty/configure.dtd", config93); - redirectEntity("https://eclipse.dev/jetty/configure.dtd", config93); + dtdRefMap.forEach(this::redirectEntity); - redirectEntity("http://jetty.mortbay.org/configure_9_3.dtd", config93); - redirectEntity("http://www.eclipse.org/jetty/configure_9_3.dtd", config93); - redirectEntity("https://www.eclipse.org/jetty/configure_9_3.dtd", config93); - redirectEntity("http://eclipse.org/jetty/configure_9_3.dtd", config93); - redirectEntity("https://eclipse.org/jetty/configure_9_3.dtd", config93); - redirectEntity("http://www.eclipse.dev/jetty/configure_9_3.dtd", config93); - redirectEntity("https://www.eclipse.dev/jetty/configure_9_3.dtd", config93); - redirectEntity("http://eclipse.dev/jetty/configure_9_3.dtd", config93); - redirectEntity("https://eclipse.dev/jetty/configure_9_3.dtd", config93); - - redirectEntity("http://www.eclipse.org/jetty/configure_10_0.dtd", config100); - redirectEntity("https://www.eclipse.org/jetty/configure_10_0.dtd", config100); - redirectEntity("http://eclipse.org/jetty/configure_10_0.dtd", config100); - redirectEntity("https://eclipse.org/jetty/configure_10_0.dtd", config100); - redirectEntity("http://www.eclipse.dev/jetty/configure_10_0.dtd", config100); - redirectEntity("https://www.eclipse.dev/jetty/configure_10_0.dtd", config100); - redirectEntity("http://eclipse.dev/jetty/configure_10_0.dtd", config100); - redirectEntity("https://eclipse.dev/jetty/configure_10_0.dtd", config100); + // Register all variations of DOCTYPE entity references for Configure + List schemes = List.of("http", "https"); + List contexts = List.of( + "jetty.mortbay.org", + "jetty.eclipse.org", + "www.eclipse.org/jetty", + "eclipse.org/jetty", + "www.eclipse.dev/jetty", + "eclipse.dev/jetty", + "jetty.org"); + for (String scheme : schemes) + { + for (String context : contexts) + { + dtdRefMap.forEach((dtdName, dtdUrl) -> + { + String refUrl = String.format("%s://%s/%s", scheme, context, dtdName); + redirectEntity(refUrl, dtdUrl); + }); + } + } redirectEntity("-//Mort Bay Consulting//DTD Configure//EN", config100); redirectEntity("-//Jetty//Configure//EN", config100); } diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java index fcbbed2a6b8..348eaa97e79 100644 --- a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java +++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java @@ -1894,16 +1894,16 @@ public class XmlConfigurationTest List ids = new ArrayList<>(); String[] schemes = {"http", "https"}; - String[] hosts = {"eclipse.org", "www.eclipse.org", "eclipse.dev", "www.eclipse.dev"}; - String[] paths = {"/jetty/configure.dtd", "/jetty/configure_9_3.dtd", "/jetty/configure_10_0.dtd"}; + String[] contexts = {"eclipse.org/jetty", "www.eclipse.org/jetty", "eclipse.dev/jetty", "www.eclipse.dev/jetty", "jetty.org"}; + String[] paths = {"configure.dtd", "configure_9_3.dtd", "configure_10_0.dtd"}; for (String scheme: schemes) { - for (String host: hosts) + for (String host: contexts) { for (String path: paths) { - ids.add(Arguments.of(String.format("%s://%s%s", scheme, host, path))); + ids.add(Arguments.of(String.format("%s://%s/%s", scheme, host, path))); } } }