diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java index b0f73abb8dc1..339512963a55 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java @@ -1892,15 +1892,18 @@ else if (scheme.equalsIgnoreCase("file")) } /** - *

Convert a String into a URI suitable for use as a Resource.

+ *

Convert a String into a URI in a sane way.

* - * @param resource If the string starts with one of the ALLOWED_SCHEMES, then it is assumed to be a - * representation of a {@link URI}, otherwise it is treated as a {@link Path}. + *

+ * This exits to take an end user provided String and make a usable URI out of it. + * It is capable of dealing with paths that have spaces, windows slashes, windows UNC references, + * relative paths, absolute paths, and much more. + *

+ * + * @param resource If the string starts with a recognized scheme, then it is assumed to be a representation + * of a {@link URI}, otherwise it is treated as a {@link Path} (which is then converted to a URI) * @return The {@link URI} form of the resource. - * @deprecated This method is currently resolving relative paths against the current directory, which is a mechanism - * that should be implemented by a {@link ResourceFactory}. All calls to this method need to be reviewed. */ - @Deprecated(since = "12.0.8") public static URI toURI(String resource) { Objects.requireNonNull(resource); diff --git a/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/URIUtilTest.java b/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/URIUtilTest.java index e482337f0b08..9b2c1bcf7037 100644 --- a/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/URIUtilTest.java +++ b/jetty-core/jetty-util/src/test/java/org/eclipse/jetty/util/URIUtilTest.java @@ -1086,6 +1086,7 @@ public static Stream toURICases() else { // URI (and unix) format (relative) + args.add(Arguments.of("/path/that has spaces/foo.jar", "file:///path/that%20has%20spaces/foo.jar")); args.add(Arguments.of("/path/to/foo.jar", "file:///path/to/foo.jar")); args.add(Arguments.of("/path/to/bogus.txt", "file:///path/to/bogus.txt")); } diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/invoker.properties b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/invoker.properties new file mode 100644 index 000000000000..998d6702ac57 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/invoker.properties @@ -0,0 +1 @@ +invoker.goals = test -e \ No newline at end of file diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/pom.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/pom.xml new file mode 100644 index 000000000000..036a65d4ce43 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + + org.eclipse.jetty.ee10.its.jetty-start-mojo-it + jetty-simple-project + 0.0.1-SNAPSHOT + + + jetty-simple-base + jar + + EE10 :: Simple :: Base + + + + jakarta.servlet + jakarta.servlet-api + provided + + + org.slf4j + slf4j-api + + + commons-io + commons-io + + + org.eclipse.jetty.toolchain + jetty-perf-helper + + + com.fasterxml.jackson.core + jackson-databind + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_start_mojo_it/Counter.java b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_start_mojo_it/Counter.java new file mode 100644 index 000000000000..89f6c4b0f058 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_start_mojo_it/Counter.java @@ -0,0 +1,38 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.its.jetty_start_mojo_it; + +@SuppressWarnings("serial") +public class Counter implements java.io.Serializable +{ + int counter = 0; + String last; + + public int getCount() + { + counter++; + return counter; + } + + public void setLast(String uri) + { + last = uri; + } + + public String getLast() + { + return last; + } +} + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_start_mojo_it/HelloServlet.java b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_start_mojo_it/HelloServlet.java new file mode 100644 index 000000000000..e653b64b0393 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_start_mojo_it/HelloServlet.java @@ -0,0 +1,40 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.its.jetty_start_mojo_it; + +import java.io.IOException; + +import jakarta.servlet.ServletException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + * + */ +@WebServlet("/hello") +public class HelloServlet + extends HttpServlet +{ + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException + { + String who = req.getParameter("name"); + + resp.getWriter().write("Hello " + (who == null ? "unknown" : who)); + } +} diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_start_mojo_it/PingServlet.java b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_start_mojo_it/PingServlet.java new file mode 100644 index 000000000000..995072a4c994 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_start_mojo_it/PingServlet.java @@ -0,0 +1,35 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.its.jetty_start_mojo_it; + +import java.io.IOException; + +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +public class PingServlet + extends HttpServlet +{ + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException + { + String who = req.getParameter("name"); + + resp.getWriter().write("pong " + (who == null ? "unknown" : who)); + } +} diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml new file mode 100644 index 000000000000..5a8075691c80 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml @@ -0,0 +1,32 @@ + + + + + FragmentA + + + + + + + Ping + org.eclipse.jetty.its.jetty_start_mojo_it.PingServlet + + extra1123 + + + extra2345 + + + + + Ping + /ping + + + + \ No newline at end of file diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/pom.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/pom.xml new file mode 100644 index 000000000000..879c9c0fc114 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + + org.eclipse.jetty.ee10.its.jetty-start-mojo-it + jetty-simple-project + 0.0.1-SNAPSHOT + + + jetty-simple-webapp + war + + EE10 :: Simple :: WebApp + + + ${project.build.directory}/jetty-start-port.txt + + + + + + org.eclipse.jetty.ee10.its.jetty-start-mojo-it + jetty-simple-base + + + + org.eclipse.jetty.ee10 + jetty-ee10-servlet + provided + + + + org.eclipse.jetty.ee10 + jetty-ee10-maven-plugin + tests + test-jar + test + + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.eclipse.jetty + jetty-client + test + + + org.awaitility + awaitility + test + + + + + + + + + + org.apache.maven.plugins + maven-war-plugin + + false + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + IntegrationTest*.java + + + ${jetty.port.file} + /setbycontextxml + true + true + Counter accessed 1 times. + /jsp/bean1.jsp + ${project.groupId}:${project.artifactId} + + + org.eclipse.jetty.ee10:jetty-ee10-maven-plugin + + + + + org.eclipse.jetty.ee10 + jetty-ee10-maven-plugin + + + start-jetty + test-compile + + start + + + ${basedir}/src/config/context.xml + + ${jetty.port.file} + EMBED + + + ${basedir}/src/config/jetty.xml + + + + Test Realm + + ${basedir}/src/config/realm.properties + + + + + ${basedir}/src/config/jetty-env.xml + + ${basedir}/src/main/webapp + + + + + + + + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/context.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/context.xml new file mode 100644 index 000000000000..2f12f68b1401 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/context.xml @@ -0,0 +1,7 @@ + + + + + /setbycontextxml + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/jetty-env.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/jetty-env.xml new file mode 100644 index 000000000000..8d0ddabb112b --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/jetty-env.xml @@ -0,0 +1,12 @@ + + + + + + + + fooBoolean + 100 + true + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/jetty.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/jetty.xml new file mode 100644 index 000000000000..abdc1c41898d --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/jetty.xml @@ -0,0 +1,40 @@ + + + + + + https + + 32768 + 8192 + 8192 + 1024 + + + + + + + + + + + + + + + + + + + + + + + + + 30000 + + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/realm.properties b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/realm.properties new file mode 100644 index 000000000000..2cfa722dd897 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/config/realm.properties @@ -0,0 +1,6 @@ +jetty: MD5:164c88b302622e17050af52c89945d44,user +admin: CRYPT:adpexzg3FUZAk,server-administrator,content-administrator,admin +other: OBF:1xmk1w261u9r1w1c1xmq,user +plain: plain,user +user: password,user + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..dd5eabf4a704 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,27 @@ + + + Jetty Simple Webapp run-mojo-it + + + + Any Authenticated User + /auth/* + + + * + + + + + FORM + Test Realm + + /logon.html?param=test + /logonError.html?param=test + + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/auth/index.html b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/auth/index.html new file mode 100644 index 000000000000..c8f121557372 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/auth/index.html @@ -0,0 +1,3 @@ + +

Authenticated

+ diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/jsp/bean1.jsp b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/jsp/bean1.jsp new file mode 100644 index 000000000000..586a27ebf2ec --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/jsp/bean1.jsp @@ -0,0 +1,13 @@ + +<%@ page session="true"%> + + + +

JSP1.2 Beans: 1

+ +Counter accessed times.
+Counter last accessed by
+ + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/logon.html b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/logon.html new file mode 100644 index 000000000000..6bededa576d4 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/logon.html @@ -0,0 +1,20 @@ + +

FORM Authentication demo

+
+ + + + + + + + + + + + +
Username:
Password:
+ +
+
+ \ No newline at end of file diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/logonError.html b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/logonError.html new file mode 100644 index 000000000000..66a838690614 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/jetty-simple-webapp/src/main/webapp/logonError.html @@ -0,0 +1,4 @@ + +

Authentication ERROR

+Username, password or role incorrect. + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/pom.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/pom.xml new file mode 100644 index 000000000000..e5f18f10b5fa --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + + org.eclipse.jetty.ee10.its + it-parent-pom + 0.0.1-SNAPSHOT + + + org.eclipse.jetty.ee10.its.jetty-start-mojo-it + jetty-simple-project + 0.0.1-SNAPSHOT + pom + + EE10 :: Simple + + + UTF-8 + UTF-8 + 1.8 + @project.version@ + + + + jetty-simple-base + jetty-simple-webapp + + + + + + org.eclipse.jetty.ee10.its.jetty-start-mojo-it + jetty-simple-base + ${project.version} + + + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/postbuild.groovy b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/postbuild.groovy new file mode 100644 index 000000000000..298c50f6092f --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-start with spaces mojo-it/postbuild.groovy @@ -0,0 +1,23 @@ +/* + * 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. + */ +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains( 'Started Server' ) +assert buildLog.text.contains( 'Running org.eclipse.jetty.ee10.maven.plugin.it.IntegrationTestGetContent') +assert buildLog.text.contains( 'pingServlet ok') +assert buildLog.text.contains( 'helloServlet') diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/MavenWebAppContext.java b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/MavenWebAppContext.java index 8f73478cd22e..a2ed233ce2b9 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/MavenWebAppContext.java +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/MavenWebAppContext.java @@ -231,7 +231,7 @@ public void setResourceBases(String[] resourceBases) // This is a user provided list of configurations. // We have to assume that mounting can happen. List uris = Stream.of(resourceBases) - .map(URI::create) + .map(URIUtil::toURI) .toList(); setBaseResource(this.getResourceFactory().newResource(uris)); diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/MavenWebAppContext.java b/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/MavenWebAppContext.java index 15a032166160..b65adcdf64e2 100644 --- a/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/MavenWebAppContext.java +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/MavenWebAppContext.java @@ -233,7 +233,7 @@ public void setResourceBases(String[] resourceBases) // This is a user provided list of configurations. // We have to assume that mounting can happen. List uris = Stream.of(resourceBases) - .map(URI::create) + .map(URIUtil::toURI) .toList(); Resource r = ResourceFactory.of(this).newResource(uris);