AI 146842: am: CL 146808 am: CL 146806 Make sure we check buffer length when removing escaped chars (like unicode) when parsing Value XML files.

Original author: xav
  Merged from: //branches/cupcake/...
  Original author: android-build

Automated import of CL 146842
This commit is contained in:
Xavier Ducrohet
2009-04-18 23:23:41 -07:00
committed by The Android Open Source Project
parent f065b3f626
commit 03a7e70160

View File

@@ -194,9 +194,10 @@ public final class ValueResourceParser extends DefaultHandler {
char[] buffer = value.toCharArray(); char[] buffer = value.toCharArray();
for (int i = 0 ; i < length ; i++) { for (int i = 0 ; i < length ; i++) {
if (buffer[i] == '\\') { if (buffer[i] == '\\' && i + 1 < length) {
if (buffer[i+1] == 'u') { if (buffer[i+1] == 'u') {
// this is unicode char. if (i + 5 < length) {
// this is unicode char \u1234
int unicodeChar = Integer.parseInt(new String(buffer, i+2, 4), 16); int unicodeChar = Integer.parseInt(new String(buffer, i+2, 4), 16);
// put the unicode char at the location of the \ // put the unicode char at the location of the \
@@ -207,6 +208,7 @@ public final class ValueResourceParser extends DefaultHandler {
System.arraycopy(buffer, i+6, buffer, i+1, length - i - 6); System.arraycopy(buffer, i+6, buffer, i+1, length - i - 6);
} }
length -= 5; length -= 5;
}
} else { } else {
if (buffer[i+1] == 'n') { if (buffer[i+1] == 'n') {
// replace the 'n' char with \n // replace the 'n' char with \n