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
261ba464
Commit
261ba464
authored
Sep 16, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resources: support text chuck in binary xml (fix #84)
parent
2ab7524e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
StringUtils.java
jadx-core/src/main/java/jadx/core/utils/StringUtils.java
+19
-0
BinaryXMLParser.java
...-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
+25
-0
No files found.
jadx-core/src/main/java/jadx/core/utils/StringUtils.java
View file @
261ba464
...
...
@@ -95,4 +95,23 @@ public class StringUtils {
}
return
sb
.
toString
();
}
public
static
String
escapeXML
(
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
;
default
:
sb
.
append
(
c
);
break
;
}
}
return
sb
.
toString
();
}
}
jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
View file @
261ba464
...
...
@@ -6,6 +6,7 @@ import jadx.core.dex.instructions.args.ArgType;
import
jadx.core.dex.nodes.DexNode
;
import
jadx.core.dex.nodes.FieldNode
;
import
jadx.core.dex.nodes.RootNode
;
import
jadx.core.utils.StringUtils
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
jadx.core.xmlgen.entry.ValuesParser
;
...
...
@@ -123,6 +124,9 @@ public class BinaryXMLParser extends CommonBinaryParser {
case
RES_XML_START_NAMESPACE_TYPE:
parseNameSpace
();
break
;
case
RES_XML_CDATA_TYPE:
parseCData
();
break
;
case
RES_XML_END_NAMESPACE_TYPE:
parseNameSpaceEnd
();
break
;
...
...
@@ -181,6 +185,27 @@ public class BinaryXMLParser extends CommonBinaryParser {
nsURI
=
strings
[
endURI
];
}
private
void
parseCData
()
throws
IOException
{
if
(
is
.
readInt16
()
!=
0x10
)
{
die
(
"CDATA header is not 0x10"
);
}
if
(
is
.
readInt32
()
!=
0x1C
)
{
die
(
"CDATA header chunk is not 0x1C"
);
}
int
lineNumber
=
is
.
readInt32
();
is
.
skip
(
4
);
int
strIndex
=
is
.
readInt32
();
String
str
=
strings
[
strIndex
];
writer
.
startLine
().
addIndent
();
writer
.
attachSourceLine
(
lineNumber
);
writer
.
add
(
StringUtils
.
escapeXML
(
str
.
trim
()));
// TODO: wrap into CDATA for easier reading
int
size
=
is
.
readInt16
();
is
.
skip
(
size
-
2
);
}
private
void
parseElement
()
throws
IOException
{
if
(
firstElement
)
{
firstElement
=
false
;
...
...
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