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
8031a1bd
Commit
8031a1bd
authored
Nov 12, 2017
by
Ali Kord
Committed by
Andy Wilkinson
Nov 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of spaces in container's document root
See gh-10706
parent
276a9a0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
6 deletions
+34
-6
AbstractEmbeddedServletContainerFactory.java
...ext/embedded/AbstractEmbeddedServletContainerFactory.java
+16
-6
AbstractEmbeddedServletContainerFactoryTests.java
...mbedded/AbstractEmbeddedServletContainerFactoryTests.java
+18
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactory.java
View file @
8031a1bd
...
...
@@ -19,6 +19,7 @@ package org.springframework.boot.context.embedded;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.JarURLConnection
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
import
java.net.URLConnection
;
...
...
@@ -87,7 +88,7 @@ public abstract class AbstractEmbeddedServletContainerFactory
}
private
File
getExplodedWarFileDocumentRoot
()
{
return
getExplodedWarFileDocumentRoot
(
getCodeSourceArchive
());
return
getExplodedWarFileDocumentRoot
(
getCodeSourceArchive
(
getCodeSource
()
));
}
protected
List
<
URL
>
getUrlsOfJarsWithMetaInfResources
()
{
...
...
@@ -172,7 +173,7 @@ public abstract class AbstractEmbeddedServletContainerFactory
}
private
File
getArchiveFileDocumentRoot
(
String
extension
)
{
File
file
=
getCodeSourceArchive
();
File
file
=
getCodeSourceArchive
(
getCodeSource
()
);
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
"Code archive: "
+
file
);
}
...
...
@@ -193,19 +194,21 @@ public abstract class AbstractEmbeddedServletContainerFactory
return
null
;
}
private
File
getCodeSourceArchive
(
)
{
File
getCodeSourceArchive
(
CodeSource
codeSource
)
{
try
{
CodeSource
codeSource
=
getClass
().
getProtectionDomain
().
getCodeSource
();
URL
location
=
(
codeSource
==
null
?
null
:
codeSource
.
getLocation
());
if
(
location
==
null
)
{
return
null
;
}
String
path
=
location
.
getPath
()
;
String
path
;
URLConnection
connection
=
location
.
openConnection
();
if
(
connection
instanceof
JarURLConnection
)
{
path
=
((
JarURLConnection
)
connection
).
getJarFile
().
getName
();
}
if
(
path
.
indexOf
(
"!/"
)
!=
-
1
)
{
else
{
path
=
location
.
toURI
().
getPath
();
}
if
(
path
.
contains
(
"!/"
))
{
path
=
path
.
substring
(
0
,
path
.
indexOf
(
"!/"
));
}
return
new
File
(
path
);
...
...
@@ -213,6 +216,13 @@ public abstract class AbstractEmbeddedServletContainerFactory
catch
(
IOException
ex
)
{
return
null
;
}
catch
(
URISyntaxException
e
)
{
return
null
;
}
}
private
CodeSource
getCodeSource
()
{
return
getClass
().
getProtectionDomain
().
getCodeSource
();
}
protected
final
File
getValidSessionStoreDir
()
{
...
...
spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java
View file @
8031a1bd
...
...
@@ -30,9 +30,11 @@ import java.net.URI;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.nio.charset.Charset
;
import
java.security.CodeSource
;
import
java.security.KeyStore
;
import
java.security.KeyStoreException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.cert.Certificate
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
import
java.util.Arrays
;
...
...
@@ -673,6 +675,22 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
assertThat
(
response
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
NOT_FOUND
);
}
@Test
public
void
codeSourceArchivePath
()
throws
Exception
{
AbstractEmbeddedServletContainerFactory
factory
=
getFactory
();
final
CodeSource
codeSource
=
new
CodeSource
(
new
URL
(
"file"
,
""
,
"/some/test/path/"
),
(
Certificate
[])
null
);
final
File
codeSourceArchive
=
factory
.
getCodeSourceArchive
(
codeSource
);
assertThat
(
codeSourceArchive
).
isEqualTo
(
new
File
(
"/some/test/path/"
));
}
@Test
public
void
codeSourceArchivePathContainingSpaces
()
throws
Exception
{
AbstractEmbeddedServletContainerFactory
factory
=
getFactory
();
final
CodeSource
codeSource
=
new
CodeSource
(
new
URL
(
"file"
,
""
,
"/test/path/with%20space/"
),
(
Certificate
[])
null
);
final
File
codeSourceArchive
=
factory
.
getCodeSourceArchive
(
codeSource
);
assertThat
(
codeSourceArchive
).
isEqualTo
(
new
File
(
"/test/path/with space/"
));
}
protected
Ssl
getSsl
(
ClientAuth
clientAuth
,
String
keyPassword
,
String
keyStore
)
{
return
getSsl
(
clientAuth
,
keyPassword
,
keyStore
,
null
,
null
,
null
);
}
...
...
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