Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

dechaos
Copy link

@dechaos dechaos commented Feb 12, 2018

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

…late(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
@weex-bot
Copy link

weex-bot commented Feb 12, 2018

Warnings
⚠️ No Changelog changes!
Messages
📖 danger test finished.

Generated by 🚫 dangerJS

@acton393
Copy link
Member

@dechaos thank you for you contribution, and the file change looks good to me, a very specific explanation at the same time for CSS of W3C rules, let's make it more standard.

@asfgit asfgit closed this in 95e16d8 Feb 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants