From f3e21023ac25a09e662aa876cd0a62db34e4e5a4 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Wed, 10 Feb 2016 08:05:54 -0500 Subject: [PATCH] Prefix integers only exceeding 9 digits to treat as string - This prevents small numbers like "1" to become "\ 1" - added unit tests - fixes #1130 --- .../java/brut/androlib/res/data/value/ResStringValue.java | 2 +- .../src/test/java/brut/androlib/BuildAndDecodeTest.java | 5 +++++ .../brut/apktool/testapp/res/layout/issue1130.xml | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/layout/issue1130.xml diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStringValue.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStringValue.java index 94f568c8..5a07bde1 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStringValue.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStringValue.java @@ -71,5 +71,5 @@ public class ResStringValue extends ResScalarValue { return allDigits.matcher(val).matches() ? "\\ " + val : val; } - private static Pattern allDigits = Pattern.compile("\\d+"); + private static Pattern allDigits = Pattern.compile("\\d{9,}"); } diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java index 22fc2f3d..b2144c81 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java @@ -181,6 +181,11 @@ public class BuildAndDecodeTest { compareXmlFiles("res/layout/issue1063.xml"); } + @Test + public void xmlSmallNumbersDontEscapeTest() throws BrutException { + compareXmlFiles("res/layout/issue1130.xml"); + } + @Test public void qualifiersTest() throws BrutException { compareValuesFiles("values-mcc004-mnc4-en-rUS-ldrtl-sw100dp-w200dp-h300dp" diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/layout/issue1130.xml b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/layout/issue1130.xml new file mode 100644 index 00000000..ce05fbc3 --- /dev/null +++ b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/layout/issue1130.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file