Skip to content

Commit

Permalink
#664 Fixed handling of the paths with + in them (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsideup committed Apr 29, 2018
1 parent bead0b3 commit 988e16a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.

### Fixed
- Retry any exceptions (not just `DockerClientException`) on image pull ([\#662](https://github.com/testcontainers/testcontainers-java/issues/662))
- Fixed handling of the paths with `+` in them ([\#664](https://github.com/testcontainers/testcontainers-java/issues/664))

### Changed
- Database container images are now pinned to a specific version rather than using `latest`. The tags selected are the most recent as of the time of this change. If a JDBC URL is used with no tag specified, a WARN level log message is output, pending a future change to make tags mandatory in the JDBC URL. ([\#671](https://github.com/testcontainers/testcontainers-java/issues/671))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private static URL getClasspathResource(@NotNull final String resourcePath, @Not
private static String unencodeResourceURIToFilePath(@NotNull final String resource) {
try {
// Convert any url-encoded characters (e.g. spaces) back into unencoded form
return URLDecoder.decode(resource, Charsets.UTF_8.name())
return URLDecoder.decode(resource.replaceAll("\\+", "%2B"), Charsets.UTF_8.name())
.replaceFirst("jar:", "")
.replaceFirst("file:", "")
.replaceAll("!.*", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ public void forHostPathWithSpaces() throws Exception {
assertFalse("The resolved path does not contain an escaped space", mountableFile.getResolvedPath().contains("\\ "));
}

@Test
public void forHostPathWithPlus() throws Exception {
final Path file = createTempFile("some+path");
final MountableFile mountableFile = MountableFile.forHostPath(file.toString());

performChecks(mountableFile);

assertTrue("The resolved path contains the original space", mountableFile.getResolvedPath().contains("+"));
assertFalse("The resolved path does not contain an escaped space", mountableFile.getResolvedPath().contains(" "));
}

@Test
public void forClasspathResourceWithPermission() throws Exception {
final MountableFile mountableFile = MountableFile.forClasspathResource("mappable-resource/test-resource.txt",
Expand Down Expand Up @@ -113,4 +124,4 @@ private void performChecks(final MountableFile mountableFile) {
assertFalse("The filesystem path '" + mountablePath + "' does not contain any URL escaping", mountablePath.contains("%20"));
}

}
}

0 comments on commit 988e16a

Please sign in to comment.