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
5169dc52
Commit
5169dc52
authored
Mar 22, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: remove invalid chars from class names (#488)
parent
f72abb28
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
4 deletions
+45
-4
NameMapper.java
jadx-core/src/main/java/jadx/core/deobf/NameMapper.java
+1
-1
RenameVisitor.java
...e/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
+4
-3
TestClassNameWithInvalidChar.java
...tests/integration/names/TestClassNameWithInvalidChar.java
+36
-0
a.smali
...src/test/smali/names/TestClassNameWithInvalidChar/a.smali
+2
-0
b.smali
...src/test/smali/names/TestClassNameWithInvalidChar/b.smali
+2
-0
No files found.
jadx-core/src/main/java/jadx/core/deobf/NameMapper.java
View file @
5169dc52
...
...
@@ -126,7 +126,7 @@ public class NameMapper {
* </ul><p>
*/
public
static
String
removeInvalidCharsMiddle
(
String
name
)
{
if
(
isValidIdentifier
(
name
)
&&
isAllCharsPrintable
(
name
)
)
{
if
(
isValidIdentifier
(
name
))
{
return
name
;
}
int
len
=
name
.
length
();
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
View file @
5169dc52
...
...
@@ -92,10 +92,11 @@ public class RenameVisitor extends AbstractVisitor {
if
(
firstChar
==
'$'
)
{
return
'C'
+
NameMapper
.
removeInvalidCharsMiddle
(
clsName
);
}
if
(!
NameMapper
.
isValidIdentifier
(
clsName
))
{
return
'C'
+
clsName
;
String
cleanClsName
=
NameMapper
.
removeInvalidChars
(
clsName
,
"C"
);
if
(!
NameMapper
.
isValidIdentifier
(
cleanClsName
))
{
return
'C'
+
cleanClsName
;
}
return
NameMapper
.
removeInvalidChars
(
clsName
,
"C"
)
;
return
cleanClsName
;
}
private
void
checkFields
(
ClassNode
cls
)
{
...
...
jadx-core/src/test/java/jadx/tests/integration/names/TestClassNameWithInvalidChar.java
0 → 100644
View file @
5169dc52
package
jadx
.
tests
.
integration
.
names
;
import
org.junit.jupiter.api.Test
;
import
jadx.api.JadxDecompiler
;
import
jadx.api.JadxInternalAccess
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.RootNode
;
import
jadx.tests.api.SmaliTest
;
public
class
TestClassNameWithInvalidChar
extends
SmaliTest
{
/*
public class do- {}
public class i-f {}
*/
@Test
public
void
test
()
{
JadxDecompiler
d
=
loadSmaliFiles
(
"names"
,
"TestClassNameWithInvalidChar"
);
RootNode
root
=
JadxInternalAccess
.
getRoot
(
d
);
for
(
ClassNode
cls
:
root
.
getClasses
(
false
))
{
decompileAndCheckCls
(
d
,
cls
);
}
}
@Test
public
void
testWithDeobfuscation
()
{
enableDeobfuscation
();
JadxDecompiler
d
=
loadSmaliFiles
(
"names"
,
"TestClassNameWithInvalidChar"
);
RootNode
root
=
JadxInternalAccess
.
getRoot
(
d
);
for
(
ClassNode
cls
:
root
.
getClasses
(
false
))
{
decompileAndCheckCls
(
d
,
cls
);
}
}
}
jadx-core/src/test/smali/names/TestClassNameWithInvalidChar/a.smali
0 → 100644
View file @
5169dc52
.class public Ldo-;
.super Ljava/lang/Object;
jadx-core/src/test/smali/names/TestClassNameWithInvalidChar/b.smali
0 → 100644
View file @
5169dc52
.class public Li-f;
.super Ljava/lang/Object;
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