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
31a02a70
Commit
31a02a70
authored
May 10, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: rename class if all chars not printable (#622)
parent
8e0df4c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
RenameReasonAttr.java
...java/jadx/core/dex/attributes/nodes/RenameReasonAttr.java
+2
-2
RenameVisitor.java
...e/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
+11
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/attributes/nodes/RenameReasonAttr.java
View file @
31a02a70
...
...
@@ -35,11 +35,11 @@ public class RenameReasonAttr implements IAttribute {
}
}
p
rivate
RenameReasonAttr
notValid
()
{
p
ublic
RenameReasonAttr
notValid
()
{
return
append
(
"not valid java name"
);
}
p
rivate
RenameReasonAttr
notPrintable
()
{
p
ublic
RenameReasonAttr
notPrintable
()
{
return
append
(
"contains not printable characters"
);
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
View file @
31a02a70
...
...
@@ -79,6 +79,13 @@ public class RenameVisitor extends AbstractVisitor {
String
clsName
=
classInfo
.
getAliasShortName
();
String
newShortName
=
fixClsShortName
(
args
,
clsName
);
if
(
newShortName
==
null
)
{
// rename failed, use deobfuscator
String
deobfName
=
deobfuscator
.
getClsAlias
(
cls
);
classInfo
.
changeShortName
(
deobfName
);
cls
.
addAttr
(
new
RenameReasonAttr
(
cls
).
notPrintable
());
return
;
}
if
(!
newShortName
.
equals
(
clsName
))
{
classInfo
.
changeShortName
(
newShortName
);
cls
.
addAttr
(
new
RenameReasonAttr
(
cls
).
append
(
"invalid class name"
));
...
...
@@ -104,6 +111,7 @@ public class RenameVisitor extends AbstractVisitor {
}
}
@Nullable
private
static
String
fixClsShortName
(
JadxArgs
args
,
String
clsName
)
{
char
firstChar
=
clsName
.
charAt
(
0
);
boolean
renameValid
=
args
.
isRenameValid
();
...
...
@@ -116,6 +124,9 @@ public class RenameVisitor extends AbstractVisitor {
String
cleanClsName
=
args
.
isRenamePrintable
()
?
NameMapper
.
removeInvalidChars
(
clsName
,
"C"
)
:
clsName
;
if
(
cleanClsName
.
isEmpty
())
{
return
null
;
}
if
(
renameValid
&&
!
NameMapper
.
isValidIdentifier
(
cleanClsName
))
{
return
'C'
+
cleanClsName
;
}
...
...
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