Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
159ef8f1
Commit
159ef8f1
authored
Jun 15, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that URL returned from ExplodedArchive.getURL() is encoded
Closes gh-5971
parent
c808de00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
ExplodedArchive.java
.../springframework/boot/loader/archive/ExplodedArchive.java
+3
-2
ExplodedArchiveTests.java
...ngframework/boot/loader/archive/ExplodedArchiveTests.java
+21
-6
No files found.
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java
View file @
159ef8f1
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -41,6 +41,7 @@ import org.springframework.boot.loader.util.AsciiBytes;
...
@@ -41,6 +41,7 @@ import org.springframework.boot.loader.util.AsciiBytes;
* {@link Archive} implementation backed by an exploded archive directory.
* {@link Archive} implementation backed by an exploded archive directory.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Andy Wilkinson
*/
*/
public
class
ExplodedArchive
extends
Archive
{
public
class
ExplodedArchive
extends
Archive
{
...
@@ -116,7 +117,7 @@ public class ExplodedArchive extends Archive {
...
@@ -116,7 +117,7 @@ public class ExplodedArchive extends Archive {
public
URL
getUrl
()
throws
MalformedURLException
{
public
URL
getUrl
()
throws
MalformedURLException
{
FilteredURLStreamHandler
handler
=
this
.
filtered
?
new
FilteredURLStreamHandler
()
FilteredURLStreamHandler
handler
=
this
.
filtered
?
new
FilteredURLStreamHandler
()
:
null
;
:
null
;
return
new
URL
(
"file"
,
""
,
-
1
,
this
.
root
.
toURI
().
getPath
(),
handler
);
return
new
URL
(
"file"
,
""
,
-
1
,
this
.
root
.
toURI
().
toURL
().
getPath
(),
handler
);
}
}
@Override
@Override
...
...
spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java
View file @
159ef8f1
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -23,7 +23,6 @@ import java.io.InputStream;
...
@@ -23,7 +23,6 @@ import java.io.InputStream;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
import
java.net.URLClassLoader
;
import
java.net.URLDecoder
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -38,6 +37,7 @@ import org.junit.rules.TemporaryFolder;
...
@@ -38,6 +37,7 @@ import org.junit.rules.TemporaryFolder;
import
org.springframework.boot.loader.TestJarCreator
;
import
org.springframework.boot.loader.TestJarCreator
;
import
org.springframework.boot.loader.archive.Archive.Entry
;
import
org.springframework.boot.loader.archive.Archive.Entry
;
import
org.springframework.boot.loader.util.AsciiBytes
;
import
org.springframework.boot.loader.util.AsciiBytes
;
import
org.springframework.util.StringUtils
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
greaterThan
;
import
static
org
.
hamcrest
.
Matchers
.
greaterThan
;
...
@@ -50,6 +50,7 @@ import static org.junit.Assert.assertThat;
...
@@ -50,6 +50,7 @@ import static org.junit.Assert.assertThat;
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
* @author Dave Syer
* @author Andy Wilkinson
*/
*/
public
class
ExplodedArchiveTests
{
public
class
ExplodedArchiveTests
{
...
@@ -62,10 +63,20 @@ public class ExplodedArchiveTests {
...
@@ -62,10 +63,20 @@ public class ExplodedArchiveTests {
@Before
@Before
public
void
setup
()
throws
Exception
{
public
void
setup
()
throws
Exception
{
createArchive
();
}
private
void
createArchive
()
throws
Exception
{
createArchive
(
null
);
}
private
void
createArchive
(
String
folderName
)
throws
Exception
{
File
file
=
this
.
temporaryFolder
.
newFile
();
File
file
=
this
.
temporaryFolder
.
newFile
();
TestJarCreator
.
createTestJar
(
file
);
TestJarCreator
.
createTestJar
(
file
);
this
.
rootFolder
=
this
.
temporaryFolder
.
newFolder
();
this
.
rootFolder
=
StringUtils
.
hasText
(
folderName
)
?
this
.
temporaryFolder
.
newFolder
(
folderName
)
:
this
.
temporaryFolder
.
newFolder
();
JarFile
jarFile
=
new
JarFile
(
file
);
JarFile
jarFile
=
new
JarFile
(
file
);
Enumeration
<
JarEntry
>
entries
=
jarFile
.
entries
();
Enumeration
<
JarEntry
>
entries
=
jarFile
.
entries
();
while
(
entries
.
hasMoreElements
())
{
while
(
entries
.
hasMoreElements
())
{
...
@@ -107,9 +118,13 @@ public class ExplodedArchiveTests {
...
@@ -107,9 +118,13 @@ public class ExplodedArchiveTests {
@Test
@Test
public
void
getUrl
()
throws
Exception
{
public
void
getUrl
()
throws
Exception
{
URL
url
=
this
.
archive
.
getUrl
();
assertThat
(
this
.
archive
.
getUrl
(),
equalTo
(
this
.
rootFolder
.
toURI
().
toURL
()));
assertThat
(
new
File
(
URLDecoder
.
decode
(
url
.
getFile
(),
"UTF-8"
)),
}
equalTo
(
this
.
rootFolder
));
@Test
public
void
getUrlWithSpaceInPath
()
throws
Exception
{
createArchive
(
"spaces in the name"
);
assertThat
(
this
.
archive
.
getUrl
(),
equalTo
(
this
.
rootFolder
.
toURI
().
toURL
()));
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment