summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceUtils.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-06-27 12:27:43 -0700
committerAdam Lesinski <adamlesinski@google.com>2017-06-27 12:45:00 -0700
commit8a3bffea4926aa691ea1fbc0e7b67ed954e83d2c (patch)
treefe30071c024754dba8b062afed96a21c68558c28 /tools/aapt2/ResourceUtils.cpp
parent79385ec3b0b1a8753aefd2973273560f0461ff80 (diff)
AAPT2: Fix issues with parsing integers + floats
If whitespace was present at the end of an integer or float, parsing would fail. Bug: 62902869 Test: make aapt2_tests Change-Id: I6c54f25ad73913d8ea90969fca9de24f726deb96
Diffstat (limited to 'tools/aapt2/ResourceUtils.cpp')
-rw-r--r--tools/aapt2/ResourceUtils.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp
index deeef6ebbcb7..6e6a2ba6fc50 100644
--- a/tools/aapt2/ResourceUtils.cpp
+++ b/tools/aapt2/ResourceUtils.cpp
@@ -512,7 +512,7 @@ std::unique_ptr<BinaryPrimitive> MakeBool(bool val) {
}
std::unique_ptr<BinaryPrimitive> TryParseInt(const StringPiece& str) {
- std::u16string str16 = util::Utf8ToUtf16(str);
+ std::u16string str16 = util::Utf8ToUtf16(util::TrimWhitespace(str));
android::Res_value value;
if (!android::ResTable::stringToInt(str16.data(), str16.size(), &value)) {
return {};
@@ -521,7 +521,7 @@ std::unique_ptr<BinaryPrimitive> TryParseInt(const StringPiece& str) {
}
std::unique_ptr<BinaryPrimitive> TryParseFloat(const StringPiece& str) {
- std::u16string str16 = util::Utf8ToUtf16(str);
+ std::u16string str16 = util::Utf8ToUtf16(util::TrimWhitespace(str));
android::Res_value value;
if (!android::ResTable::stringToFloat(str16.data(), str16.size(), &value)) {
return {};