From fc1e21e9ed6f15ac64014e9005e423cc60098b47 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Tue, 20 Sep 2022 07:19:28 -0400 Subject: [PATCH] fix: correct npe if null is returned from attribute value (#2889) --- .../androlib/res/decoder/AndroidManifestResourceParser.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/AndroidManifestResourceParser.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/AndroidManifestResourceParser.java index 6011ed4c..4cceb565 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/AndroidManifestResourceParser.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/AndroidManifestResourceParser.java @@ -37,6 +37,9 @@ public class AndroidManifestResourceParser extends AXmlResourceParser { @Override public String getAttributeValue(int index) { String value = super.getAttributeValue(index); + if (value == null) { + return ""; + } if (!isNumericStringMetadataAttributeValue(index, value)) { return value; @@ -46,7 +49,7 @@ public class AndroidManifestResourceParser extends AXmlResourceParser { // Otherwise, when the decoded app is rebuilt, aapt will incorrectly encode // the value as an int or float (depending on aapt version), breaking the original // app functionality. - return "\\ " + super.getAttributeValue(index).trim(); + return "\\ " + value.trim(); } private boolean isNumericStringMetadataAttributeValue(int index, String value) {