diff options
author | 2016-06-23 13:03:15 -0700 | |
---|---|---|
committer | 2016-06-23 13:03:15 -0700 | |
commit | b2106687e1fa781d6470ae6374122cf34468846f (patch) | |
tree | e8081d0b1ff9e83967c5ad362ad4ec668b4e3294 | |
parent | 92baab4f2a834ebaa29f4060326ecb4c9ff18232 (diff) |
Fix pseudolocalizer at end of string
The accent pseudolocalizer would incorrectly process
the byte after the end of the string, which would end
up inserting null characters into the resulting
output.
Change-Id: I5cdabd6b0272d94073f06e180b8cbe7abafa3888
-rw-r--r-- | tools/aapt2/compile/Pseudolocalizer.cpp | 4 | ||||
-rw-r--r-- | tools/aapt2/compile/Pseudolocalizer_test.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/tools/aapt2/compile/Pseudolocalizer.cpp b/tools/aapt2/compile/Pseudolocalizer.cpp index eae52d778744..767d746b81b6 100644 --- a/tools/aapt2/compile/Pseudolocalizer.cpp +++ b/tools/aapt2/compile/Pseudolocalizer.cpp @@ -280,13 +280,13 @@ std::u16string PseudoMethodAccent::text(const StringPiece16& source) std::u16string chunk; bool end = false; chunk.append(&c, 1); - while (!end && i < I) { + while (!end && i + 1 < I) { ++i; c = s[i]; chunk.append(&c, 1); if (isPossibleNormalPlaceholderEnd(c)) { end = true; - } else if (c == 't') { + } else if (i + 1 < I && c == 't') { ++i; c = s[i]; chunk.append(&c, 1); diff --git a/tools/aapt2/compile/Pseudolocalizer_test.cpp b/tools/aapt2/compile/Pseudolocalizer_test.cpp index b0bc2c10fbe0..36c88969a6bf 100644 --- a/tools/aapt2/compile/Pseudolocalizer_test.cpp +++ b/tools/aapt2/compile/Pseudolocalizer_test.cpp @@ -69,7 +69,7 @@ TEST(PseudolocalizerTest, PlaintextAccent) { EXPECT_TRUE(simpleHelper("Battery %1d%%", "[βåţţéŕý »%1d«%% one two]", Pseudolocalizer::Method::kAccent)); - + EXPECT_TRUE(simpleHelper("^1 %", "[^1 % one]", Pseudolocalizer::Method::kAccent)); EXPECT_TRUE(compoundHelper("", "", "", "[]", Pseudolocalizer::Method::kAccent)); EXPECT_TRUE(compoundHelper("Hello,", " world", "", "[Ĥéļļö, ŵöŕļð one two]", Pseudolocalizer::Method::kAccent)); |