From 8a3bffea4926aa691ea1fbc0e7b67ed954e83d2c Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Tue, 27 Jun 2017 12:27:43 -0700 Subject: 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 --- tools/aapt2/ResourceUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/aapt2/ResourceUtils.cpp') 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 MakeBool(bool val) { } std::unique_ptr 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 TryParseInt(const StringPiece& str) { } std::unique_ptr 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 {}; -- cgit v1.2.3-59-g8ed1b