Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
Metrics
Onionoo
Commits
947ce706
Commit
947ce706
authored
Apr 06, 2018
by
iwakeh
Committed by
Karsten Loesing
Apr 16, 2018
Browse files
Provide utf-characters instead of escape strings.
Also adapt tests to check the new functionality. Implements task-25740.
parent
59eb04b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
947ce706
# Changes in version 6.0-1.13.0 - 2018-04-??
*
Minor changes
-
Turn valid utf-8 escape sequences into utf-8 characters.
# Changes in version 5.2-1.12.0 - 2018-04-06
*
Medium changes
...
...
src/main/java/org/torproject/onionoo/util/FormattingUtils.java
View file @
947ce706
...
...
@@ -3,6 +3,8 @@
package
org.torproject.onionoo.util
;
import
static
org
.
apache
.
commons
.
lang3
.
StringEscapeUtils
.
unescapeJava
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -58,8 +60,8 @@ public class FormattingUtils {
StringBuffer
sb
=
new
StringBuffer
();
Matcher
mat
=
escapePattern
.
matcher
(
text
);
while
(
mat
.
find
())
{
String
unescaped
=
mat
.
group
(
1
);
mat
.
appendReplacement
(
sb
,
unescape
d
);
String
unescaped
=
mat
.
group
(
1
)
.
substring
(
1
)
;
mat
.
appendReplacement
(
sb
,
unescape
Java
(
unescaped
)
);
}
mat
.
appendTail
(
sb
);
return
sb
.
toString
();
...
...
src/test/resources/lines-for-escape-tests.txt
View file @
947ce706
...
...
@@ -2,15 +2,21 @@
abc
abc
\\\\u
\\\\u
\\\\u
00bb \\\\u \\\\u00ab
»
\\\\u
«
Haha/\\\\@/\\\\live/\\\\./\\\\co/\\\\./\\\uk
Haha/\\\\@/\\\\live/\\\\./\\\\co/\\\\./\\\uk
\\\\u20ac
\\u20ac
\\\\u0024
\\u0024
some \\\\u20ac other string \\\\u0024 to unescape
some \\u20ac other string \\u0024 to unescape
abcd efg\\\\u0024xyz\\\\uxxxx
abcd efg\\u0024xyz\\\\uxxxx
Euro \\\\u20ac
Euro €
Dollar \\\\u0024
Dollar $
Pound \\\\u00a3
Pound £
Yen \\\\u00a5
Yen ¥
\\\\u00a1some \\\\u00dE other string \\\\u00e7 to unescape!
¡some Þ other string ç to unescape!
abcd efg cent \\\\u00a2xyz\\\\uxxxx
abcd efg cent ¢xyz\\\\uxxxx
Telef\\\\u00F4nica
Telefônica
Write
Preview
Supports
Markdown
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