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
a657a28f
Commit
a657a28f
authored
Apr 02, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix properties unicode value decoding
Fix a range error when checking for unicode hex chars. Fixes gh-12716
parent
6831628f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
OriginTrackedPropertiesLoader.java
...ringframework/boot/env/OriginTrackedPropertiesLoader.java
+4
-4
OriginTrackedPropertiesLoaderTests.java
...ramework/boot/env/OriginTrackedPropertiesLoaderTests.java
+14
-0
test-properties-malformed-unicode.properties
...ork/boot/env/test-properties-malformed-unicode.properties
+1
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedPropertiesLoader.java
View file @
a657a28f
...
...
@@ -224,17 +224,17 @@ class OriginTrackedPropertiesLoader {
this
.
character
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
int
digit
=
this
.
reader
.
read
();
if
(
digit
>
-
'0'
&&
digit
<=
'9'
)
{
if
(
digit
>
=
'0'
&&
digit
<=
'9'
)
{
this
.
character
=
(
this
.
character
<<
4
)
+
digit
-
'0'
;
}
else
if
(
digit
>
-
'a'
&&
digit
<=
'f'
)
{
else
if
(
digit
>
=
'a'
&&
digit
<=
'f'
)
{
this
.
character
=
(
this
.
character
<<
4
)
+
digit
-
'a'
+
10
;
}
else
if
(
digit
>
-
'A'
&&
digit
<=
'F'
)
{
else
if
(
digit
>
=
'A'
&&
digit
<=
'F'
)
{
this
.
character
=
(
this
.
character
<<
4
)
+
digit
-
'A'
+
10
;
}
else
{
throw
new
Illegal
Argument
Exception
(
"Malformed \\uxxxx encoding."
);
throw
new
Illegal
State
Exception
(
"Malformed \\uxxxx encoding."
);
}
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java
View file @
a657a28f
...
...
@@ -20,7 +20,9 @@ import java.util.Map;
import
java.util.Properties
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.boot.origin.OriginTrackedValue
;
import
org.springframework.boot.origin.TextResourceOrigin
;
...
...
@@ -37,6 +39,9 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public
class
OriginTrackedPropertiesLoaderTests
{
@Rule
public
ExpectedException
thrown
=
ExpectedException
.
none
();
private
ClassPathResource
resource
;
private
Map
<
String
,
OriginTrackedValue
>
properties
;
...
...
@@ -85,6 +90,15 @@ public class OriginTrackedPropertiesLoaderTests {
assertThat
(
getLocation
(
value
)).
isEqualTo
(
"12:14"
);
}
@Test
public
void
getMalformedUnicodeProperty
()
throws
Exception
{
// gh-2716
this
.
thrown
.
expect
(
IllegalStateException
.
class
);
this
.
thrown
.
expectMessage
(
"Malformed \\uxxxx encoding"
);
new
OriginTrackedPropertiesLoader
(
new
ClassPathResource
(
"test-properties-malformed-unicode.properties"
,
getClass
())).
load
();
}
@Test
public
void
getEscapedProperty
()
{
OriginTrackedValue
value
=
this
.
properties
.
get
(
"test=property"
);
...
...
spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/env/test-properties-malformed-unicode.properties
0 → 100644
View file @
a657a28f
test-malformed-unicode
=
properties
\u
(026test
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