ResXmlEncoders::encodeAsXmlValue() : properly encode strings with styles and new lines.

This commit is contained in:
Ryszard Wiśniewski 2011-05-10 16:58:32 +02:00
parent 8dcbe6ead7
commit 0f251a0fd9

View File

@ -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)) {