diff --git a/apktool-lib/src/main/java/brut/androlib/res/data/value/ResScalarValue.java b/apktool-lib/src/main/java/brut/androlib/res/data/value/ResScalarValue.java index c0a3fe52..6d80e1b8 100644 --- a/apktool-lib/src/main/java/brut/androlib/res/data/value/ResScalarValue.java +++ b/apktool-lib/src/main/java/brut/androlib/res/data/value/ResScalarValue.java @@ -52,7 +52,7 @@ public abstract class ResScalarValue extends ResValue if (mRawValue != null) { return mRawValue; } - return encodeAsResXmlValueExt(); + return encodeAsResXml(); } public String encodeAsResXmlValueExt() throws AndrolibException { diff --git a/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlEncoders.java b/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlEncoders.java index 7124f885..46226e39 100644 --- a/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlEncoders.java +++ b/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlEncoders.java @@ -156,24 +156,37 @@ public final class ResXmlEncoders { return out.toString(); } -private static List findNonPositionalSubstitutions(String str, + /** + * It searches for "%", but not "%%" nor "%(\d)+\$" + */ + private static List findNonPositionalSubstitutions(String str, int max) { int pos = 0; + int pos2 = 0; int count = 0; int length = str.length(); List ret = new ArrayList(); - while((pos = str.indexOf('%', pos)) != -1) { - if (pos + 1 == length) { + while((pos2 = (pos = str.indexOf('%', pos2)) + 1) != 0) { + if (pos2 == length) { break; } - char c = str.charAt(pos + 1); - if (c >= 'a' && c <= 'z') { - ret.add(pos); - if (max != -1 && ++count >= max) { - break; + char c = str.charAt(pos2++); + if (c == '%') { + continue; + } + if (c >= '0' && c <= '9' && pos2 < length) { + do { + c = str.charAt(pos2++); + } while (c >= '0' && c <= '9' && pos2 < length); + if (c == '$') { + continue; } } - pos += 2; + + ret.add(pos); + if (max != -1 && ++count >= max) { + break; + } } return ret;