diff options
| author | Xavier Ducrohet <> | 2009-04-18 12:15:12 -0700 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-18 12:15:12 -0700 |
| commit | 922b7f3289256e600200c4c84a6b01f63bd1d11b (patch) | |
| tree | 3d5e18ebbb9fdca045573b27ceb9e2a0cfa09ddc /tools/layoutlib_utils | |
| parent | 2013a91fad40a97e01071e51b3c4ddffbfb491b8 (diff) | |
| download | android_development-922b7f3289256e600200c4c84a6b01f63bd1d11b.tar.gz android_development-922b7f3289256e600200c4c84a6b01f63bd1d11b.tar.bz2 android_development-922b7f3289256e600200c4c84a6b01f63bd1d11b.zip | |
AI 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/...
Automated import of CL 146808
Diffstat (limited to 'tools/layoutlib_utils')
| -rw-r--r-- | tools/layoutlib_utils/src/com/android/layoutlib/utils/ValueResourceParser.java | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tools/layoutlib_utils/src/com/android/layoutlib/utils/ValueResourceParser.java b/tools/layoutlib_utils/src/com/android/layoutlib/utils/ValueResourceParser.java index 8b768ef97..4682d9086 100644 --- a/tools/layoutlib_utils/src/com/android/layoutlib/utils/ValueResourceParser.java +++ b/tools/layoutlib_utils/src/com/android/layoutlib/utils/ValueResourceParser.java @@ -194,19 +194,21 @@ public final class ValueResourceParser extends DefaultHandler { char[] buffer = value.toCharArray(); for (int i = 0 ; i < length ; i++) { - if (buffer[i] == '\\') { + if (buffer[i] == '\\' && i + 1 < length) { if (buffer[i+1] == 'u') { - // this is unicode char. - int unicodeChar = Integer.parseInt(new String(buffer, i+2, 4), 16); - - // put the unicode char at the location of the \ - buffer[i] = (char)unicodeChar; - - // offset the rest of the buffer since we go from 6 to 1 char - if (i + 6 < buffer.length) { - System.arraycopy(buffer, i+6, buffer, i+1, length - i - 6); + if (i + 5 < length) { + // this is unicode char \u1234 + int unicodeChar = Integer.parseInt(new String(buffer, i+2, 4), 16); + + // put the unicode char at the location of the \ + buffer[i] = (char)unicodeChar; + + // offset the rest of the buffer since we go from 6 to 1 char + if (i + 6 < buffer.length) { + System.arraycopy(buffer, i+6, buffer, i+1, length - i - 6); + } + length -= 5; } - length -= 5; } else { if (buffer[i+1] == 'n') { // replace the 'n' char with \n |
