From 0f251a0fd9bface117ca0e800d2bdacfe8f49da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryszard=20Wi=C5=9Bniewski?= Date: Tue, 10 May 2011 16:58:32 +0200 Subject: [PATCH] ResXmlEncoders::encodeAsXmlValue() : properly encode strings with styles and new lines. --- .../main/java/brut/androlib/res/xml/ResXmlEncoders.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 63fa3976..81e2aa06 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 @@ -81,12 +81,16 @@ public final class ResXmlEncoders { } boolean isInStyleTag = false; + int startPos = 0; boolean enclose = false; boolean wasSpace = true; for (char c : chars) { if (isInStyleTag) { if (c == '>') { isInStyleTag = false; + startPos = out.length() + 1; + enclose = false; + wasSpace = true; } } else if (c == ' ') { if (wasSpace) { @@ -108,6 +112,9 @@ public final class ResXmlEncoders { break; case '<': isInStyleTag = true; + if (enclose || wasSpace) { + out.insert(startPos, '"').append('"'); + } break; default: if (!isPrintableChar(c)) {