Repository: incubator-weex Updated Branches: refs/heads/master ebd9aa5e5 -> 95e16d870
[WEEX-217][iOS] fix:WXTransform should not crash while parsing 'translate(0)' on iOS According to the latest published W3C specification about CSS Transforms: translate() = translate( <length-percentage> [, <length-percentage> ]? ) specifies a 2D translation by the vector [tx, ty], where tx is the first translation-value parameter and ty is the optional second translation-value parameter. If <ty> is not provided, ty has zero as a value. , translate(tx) is equal to translate(tx, 0). In the previous version of Weex, we removed the array length check in method [WXTransform parseTranslate:]. if the parser encounters a 'translate(0)', the array contains only one single value inside, parseTranslate will fetch the element at index 1 from the array, which causes a typical out-of-bounds exception, and lead to an app crash eventually. We should add the array length check back to the method to avoid the crash in the above case. As we known in many js packing procedures, 'translate(x, 0)' will be compressed/minified to the form 'translate(x)â, Weex should avoid such inconsistent implementations and conforms the W3C specifications. Bug: 217 close #1028 Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/95e16d87 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/95e16d87 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/95e16d87 Branch: refs/heads/master Commit: 95e16d870d96f926606b0f831aa1ce6a281cc7d0 Parents: ebd9aa5 Author: å¦å± <gabriel...@alibaba-inc.com> Authored: Mon Feb 12 17:07:16 2018 +0800 Committer: acton393 <zhangxing610...@gmail.com> Committed: Mon Feb 12 18:12:29 2018 +0800 ---------------------------------------------------------------------- ios/sdk/WeexSDK/Sources/Component/WXTransform.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/95e16d87/ios/sdk/WeexSDK/Sources/Component/WXTransform.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTransform.m b/ios/sdk/WeexSDK/Sources/Component/WXTransform.m index 6f3e153..0fbf8a8 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXTransform.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXTransform.m @@ -349,7 +349,9 @@ - (void)parseTranslate:(NSArray *)value { [self parseTranslatex:@[value[0]]]; - [self parseTranslatey:@[value[1]]]; + if (value.count > 1) { + [self parseTranslatey:@[value[1]]]; + } } - (void)parseTranslatex:(NSArray *)value