Skip to content

Commit

Permalink
Update XML entity refs to support jetty.org too.
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Jun 20, 2024
1 parent d764ed9 commit 73f28b4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 46 deletions.
8 changes: 8 additions & 0 deletions jetty-xml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
<argLine>@{argLine} ${jetty.surefire.argLine} --add-reads org.eclipse.jetty.xml=org.eclipse.jetty.logging</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
79 changes: 37 additions & 42 deletions jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -1949,54 +1949,49 @@ private ConfigurationParser(Pool<ConfigurationParser>.Entry entry)
_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);

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);

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);

Map<String, URL> 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);

dtdRefMap.forEach(this::redirectEntity);

// Register all variations of DOCTYPE entity references for Configure
List<String> schemes = List.of("http", "https");
List<String> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1894,16 +1894,16 @@ public static Stream<Arguments> xmlSystemIdSource()
List<Arguments> 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)));
}
}
}
Expand Down

0 comments on commit 73f28b4

Please sign in to comment.