GitHub user dechaos opened a pull request:

    https://github.com/apache/incubator-weex/pull/1028

    [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
    
    First of all, thank you for your contribution! 
    
    Please makes sure that these checkboxes are checked before submitting your 
PR, thank you!
    
    <!-- 
    How to use github markdown?
    ### checkable example
    - [x] checked
    - [ ] not checked
    More github Markdown info to see 
https://guides.github.com/features/mastering-markdown/
    -->
    
    CheckList:
    
    **if** *isBugFix* **:**
    
      * [ ] Make sure that you add at least one unit test for the bug which you 
had fixed.
    
    **elif** *isNewFeature* **:**
    
      * [ ] Update API docs for the component.
      * [ ] Update/Add demo to demonstrate new feature.
      * [ ] Update test scripts for the feature.
      * [ ] Add unit tests for the feature.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dechaos/incubator-weex fix-translate-crash

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-weex/pull/1028.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1028
    
----
commit 12bff01244ef2bcf3796dc3645ec157de5db6e34
Author: 如展 <gabriel.ln@...>
Date:   2018-02-12T09:07:16Z

    [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

----


---

Reply via email to