This repository has been archived by the owner on Jun 3, 2021. It is now read-only.
[WEEX-217][iOS] fix:WXTransform should not crash while parsing 'translate(0)' on iOS #1028
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to the latest published W3C specification about CSS Transforms:
translate() = translate( [, ]? )
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 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