Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
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
open-source
jadx
Commits
7c34be26
Commit
7c34be26
authored
Oct 17, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
res: fix escape for apostrophes and quotes in string resources
parent
04246443
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
StringUtils.java
jadx-core/src/main/java/jadx/core/utils/StringUtils.java
+25
-0
ResXmlGen.java
jadx-core/src/main/java/jadx/core/xmlgen/ResXmlGen.java
+5
-1
No files found.
jadx-core/src/main/java/jadx/core/utils/StringUtils.java
View file @
7c34be26
...
...
@@ -123,4 +123,29 @@ public class StringUtils {
}
return
sb
.
toString
();
}
public
static
String
escapeResStrValue
(
String
str
)
{
int
len
=
str
.
length
();
StringBuilder
sb
=
new
StringBuilder
(
len
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
c
=
str
.
charAt
(
i
);
switch
(
c
)
{
case
'&'
:
sb
.
append
(
"&"
);
break
;
case
'<'
:
sb
.
append
(
"<"
);
break
;
case
'>'
:
sb
.
append
(
">"
);
break
;
case
'"'
:
sb
.
append
(
"\\\""
);
break
;
case
'\''
:
sb
.
append
(
"\\'"
);
break
;
case
'\n'
:
sb
.
append
(
"\\n"
);
break
;
case
'\r'
:
sb
.
append
(
"\\r"
);
break
;
case
'\t'
:
sb
.
append
(
"\\t"
);
break
;
case
'\b'
:
sb
.
append
(
"\\b"
);
break
;
case
'\f'
:
sb
.
append
(
"\\f"
);
break
;
default
:
sb
.
append
(
c
);
break
;
}
}
return
sb
.
toString
();
}
}
jadx-core/src/main/java/jadx/core/xmlgen/ResXmlGen.java
View file @
7c34be26
...
...
@@ -105,7 +105,11 @@ public class ResXmlGen {
cw
.
add
(
' '
).
add
(
attrName
).
add
(
"=\""
).
add
(
attrValue
).
add
(
'"'
);
}
cw
.
add
(
'>'
);
cw
.
add
(
StringUtils
.
escapeResValue
(
valueStr
));
if
(
typeName
.
equals
(
"string"
))
{
cw
.
add
(
StringUtils
.
escapeResStrValue
(
valueStr
));
}
else
{
cw
.
add
(
StringUtils
.
escapeResValue
(
valueStr
));
}
cw
.
add
(
"</"
).
add
(
typeName
).
add
(
'>'
);
}
...
...
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