From 5076612c873460e8cfe7580db49873ed47269a7a Mon Sep 17 00:00:00 2001 From: Jeremy Hornberger Date: Sun, 1 Mar 2015 00:28:03 -0600 Subject: [PATCH 1/2] Ampersand in "<" gets replaced with "&" in plural strings --- CHANGES | 1 + .../org/xmlpull/mxp1_serializer/MXSerializer.java | 11 +++++++---- .../apktool/testapp/res/values-mcc001/plurals.xml | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index be722c53..95fe0005 100644 --- a/CHANGES +++ b/CHANGES @@ -60,6 +60,7 @@ v2.0.0 (TBA) -Fixed (issue #757) - Download gradle binaries over https -Fixed (issue #402) - Fix issues when running user has no access to $HOME. -Fixed (issue #761) - Added proper support for BCP47 localization tags +-Fixed (issue #658) - Fixes Ampersand in "<" gets replaced with "&" in plural strings -Fixed issue with attempting to decode .spi files as 9 patches (Thanks Furniel) -Fixed issue with APKs with multiple dex files. -Fixed issue with using Apktool without smali/baksmali for ApktoolProperties (Thanks teprrr) diff --git a/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java b/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java index cee38c7f..10fbab84 100644 --- a/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java +++ b/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java @@ -1009,10 +1009,13 @@ public class MXSerializer implements XmlSerializer { } } else { if (ch == '&') { - if (i > pos) - out.write(text.substring(pos, i)); - out.write("&"); - pos = i + 1; + if(!(i < text.length() - 3 && text.charAt(i+1) == 'l' + && text.charAt(i+2) == 't' && text.charAt(i+3) == ';')){ + if (i > pos) + out.write(text.substring(pos, i)); + out.write("&"); + pos = i + 1; + } } else if (ch == '<') { if (i > pos) out.write(text.substring(pos, i)); diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc001/plurals.xml b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc001/plurals.xml index 685c7623..1c5ff193 100644 --- a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc001/plurals.xml +++ b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc001/plurals.xml @@ -16,4 +16,7 @@ foo %d foo 1 + + <b>%d</b> guide123 + \ No newline at end of file From d9fda1feda072086bb47c89bbe4a973d660aa4e4 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 1 Mar 2015 10:11:33 -0600 Subject: [PATCH 2/2] added additional unit-test, cleaned up spacing --- .../xmlpull/mxp1_serializer/MXSerializer.java | 16 ++++++++-------- .../testapp/res/values-mcc001/plurals.xml | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java b/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java index 10fbab84..66c69574 100644 --- a/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java +++ b/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java @@ -10,7 +10,7 @@ import org.xmlpull.v1.XmlSerializer; /** * Implementation of XmlSerializer interface from XmlPull V1 API. This * implementation is optimzied for performance and low memory footprint. - * + * *

* Implemented features: *

- * + * */ public class MXSerializer implements XmlSerializer { protected final static String XML_URI = "http://www.w3.org/XML/1998/namespace"; @@ -1009,12 +1009,12 @@ public class MXSerializer implements XmlSerializer { } } else { if (ch == '&') { - if(!(i < text.length() - 3 && text.charAt(i+1) == 'l' - && text.charAt(i+2) == 't' && text.charAt(i+3) == ';')){ - if (i > pos) - out.write(text.substring(pos, i)); - out.write("&"); - pos = i + 1; + if (!(i < text.length() - 3 && text.charAt(i+1) == 'l' + && text.charAt(i+2) == 't' && text.charAt(i+3) == ';')) { + if (i > pos) + out.write(text.substring(pos, i)); + out.write("&"); + pos = i + 1; } } else if (ch == '<') { if (i > pos) diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc001/plurals.xml b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc001/plurals.xml index 1c5ff193..338481cd 100644 --- a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc001/plurals.xml +++ b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-mcc001/plurals.xml @@ -16,7 +16,8 @@ foo %d foo 1 - - <b>%d</b> guide123 + + <b>%d</b> guide123 + <b>%d</b> 1 \ No newline at end of file