From f65af2d50266ec15f833015d4f60cff5c2c5514c Mon Sep 17 00:00:00 2001 From: Christian Dupuis Date: Wed, 14 May 2014 15:45:35 +0200 Subject: [PATCH 1/4] Update CRaSH dependency to 1.3.0-beta20 fixes #849 --- spring-boot-dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index e3e1175da3..0a8ba3841a 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -49,7 +49,7 @@ 3.0.2 1.4 1.6 - 1.3.0-beta18 + 1.3.0-beta20 1.6 2.2.1 1.3.175 From cf2b2df2c83c48f39bf09d9ff75d14049a6a0362 Mon Sep 17 00:00:00 2001 From: Christian Dupuis Date: Thu, 15 May 2014 17:28:49 +0200 Subject: [PATCH 2/4] Correctly decode URL coming into the Jolokia endpoint fixes #869 --- .../boot/actuate/endpoint/mvc/JolokiaMvcEndpoint.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpoint.java index ae5b38d820..d0a586b7cc 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpoint.java @@ -36,6 +36,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.context.ServletContextAware; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.ServletWrappingController; +import org.springframework.web.util.UrlPathHelper; /** * {@link MvcEndpoint} to expose Jolokia. @@ -124,15 +125,18 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean, private static class PathStripper extends HttpServletRequestWrapper { private final String path; + private final UrlPathHelper urlPathHelper; public PathStripper(HttpServletRequest request, String path) { super(request); this.path = path; + this.urlPathHelper = new UrlPathHelper(); } @Override public String getPathInfo() { - String value = super.getRequestURI(); + String value = this.urlPathHelper.decodeRequestString( + (HttpServletRequest) getRequest(), super.getRequestURI()); if (value.contains(this.path)) { value = value.substring(value.indexOf(this.path) + this.path.length()); } @@ -145,6 +149,6 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean, } return value; } - } + } From 845a86d5488d93d4efc9addce43f502b150df89d Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Fri, 2 May 2014 15:02:25 +0100 Subject: [PATCH 3/4] Monkey with JarUrlConnection to make it work when LANG unset The problem all along has been in AsciiBytes, so the fix in commit ce3aaf was just a stop gap for a system where multi-byte characters are supported but the default encoding is not UTF-8 (e.g. most Windows systems). The real solution is not to leave it to chance and always pick an encoding for the JarEntry names (i.e. in AsciiBytes). (Cherry picked from commit 06e364a9ff5b5fce76ba93277ad6eb940f0dc1d3) Fixes gh-764 --- .../boot/loader/jar/JarURLConnection.java | 10 ++++++---- .../springframework/boot/loader/util/AsciiBytes.java | 4 ++-- .../springframework/boot/loader/jar/JarFileTests.java | 4 ++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 908d7bc511..5be57a0a38 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -22,9 +22,10 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; -import java.nio.charset.Charset; import java.util.jar.Manifest; +import org.springframework.boot.loader.util.AsciiBytes; + /** * {@link java.net.JarURLConnection} used to support {@link JarFile#getUrl()}. * @@ -65,11 +66,11 @@ class JarURLConnection extends java.net.JarURLConnection { * sensible for #getJarFileURL(). */ if (separator + SEPARATOR.length() != spec.length()) { - this.jarFileUrl = new URL("jar:" + spec); this.jarEntryName = decode(spec.substring(separator + 2)); + this.jarFileUrl = new URL("jar:" + spec.substring(0, separator) + SEPARATOR + + this.jarEntryName); } else { - // The root of the archive (!/) this.jarFileUrl = new URL("jar:" + spec.substring(0, separator)); } } @@ -182,7 +183,8 @@ class JarURLConnection extends java.net.JarURLConnection { } bos.write(ch); } - return new String(bos.toByteArray(), Charset.defaultCharset()); + // AsciiBytes is what is used to store the JarEntries so make it symmetric + return new AsciiBytes(bos.toByteArray()).toString(); } diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/AsciiBytes.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/AsciiBytes.java index be24bf8d56..15df426ffd 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/AsciiBytes.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/AsciiBytes.java @@ -45,7 +45,7 @@ public final class AsciiBytes { * @param string */ public AsciiBytes(String string) { - this(string.getBytes()); + this(string.getBytes(UTF_8)); this.string = string; } @@ -125,7 +125,7 @@ public final class AsciiBytes { if (string == null || string.length() == 0) { return this; } - return append(string.getBytes()); + return append(string.getBytes(UTF_8)); } public AsciiBytes append(byte[] bytes) { diff --git a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java index 8cf90d7295..beec31e977 100644 --- a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java +++ b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java @@ -91,6 +91,8 @@ public class JarFileTests { URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { jarUrl }); assertThat(urlClassLoader.getResource("special/\u00EB.dat"), notNullValue()); assertThat(urlClassLoader.getResource("d/9.dat"), notNullValue()); + jarFile.close(); + urlClassLoader.close(); } @Test @@ -133,6 +135,7 @@ public class JarFileTests { URLClassLoader urlClassLoader = new URLClassLoader( new URL[] { this.jarFile.getUrl() }); assertThat(urlClassLoader.getResource("special/\u00EB.dat"), notNullValue()); + urlClassLoader.close(); } @Test @@ -365,5 +368,6 @@ public class JarFileTests { jarEntry.getCertificates()); } } + jarFile.close(); } } From 6a644e2e23052c2ed42ff245729699b66750cdfa Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 16 May 2014 14:17:26 +0100 Subject: [PATCH 4/4] Protect against malformed URLs on Windows Update JarFile to correctly create system independent URLs to prevent potential URISyntaxExceptions when running on Windows. Fixes gh-836 --- .../boot/loader/jar/JarFile.java | 47 ++++++++++++++----- .../boot/loader/jar/JarFileTests.java | 2 - 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java index 78c417ce74..576f6c675e 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java @@ -365,11 +365,6 @@ public class JarFile extends java.util.jar.JarFile implements Iterable