提交 ee74c4d8 编写于 作者: S Skylot

core: ignore debug info with bad variable names

上级 45f5e0cb
......@@ -5,6 +5,8 @@ import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import static jadx.core.utils.StringUtils.notEmpty;
public class NameMapper {
private static final Pattern VALID_JAVA_IDENTIFIER = Pattern.compile(
......@@ -76,11 +78,15 @@ public class NameMapper {
}
public static boolean isValidIdentifier(String str) {
return VALID_JAVA_IDENTIFIER.matcher(str).matches() && isAllCharsPrintable(str);
return notEmpty(str)
&& VALID_JAVA_IDENTIFIER.matcher(str).matches()
&& isAllCharsPrintable(str);
}
public static boolean isValidFullIdentifier(String str) {
return VALID_JAVA_FULL_IDENTIFIER.matcher(str).matches() && isAllCharsPrintable(str);
return notEmpty(str)
&& VALID_JAVA_FULL_IDENTIFIER.matcher(str).matches()
&& isAllCharsPrintable(str);
}
public static boolean isPrintableChar(int c) {
......
......@@ -4,6 +4,7 @@ import java.util.List;
import com.android.dex.Dex.Section;
import jadx.core.deobf.NameMapper;
import jadx.core.dex.attributes.nodes.SourceFileAttr;
import jadx.core.dex.instructions.args.InsnArg;
import jadx.core.dex.instructions.args.RegisterArg;
......@@ -280,7 +281,14 @@ public class DebugInfoParser {
}
if (mergeRequired) {
reg.mergeDebugInfo(var.getType(), var.getName());
applyDebugInfo(reg, var);
}
}
private static void applyDebugInfo(RegisterArg reg, LocalVar var) {
String varName = var.getName();
if (NameMapper.isValidIdentifier(varName)) {
reg.mergeDebugInfo(var.getType(), varName);
}
}
}
......@@ -198,4 +198,8 @@ public class StringUtils {
sb.append(c);
}
}
public static boolean notEmpty(String str) {
return str != null && !str.isEmpty();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册