Uploaded image for project: 'Weex (Retired)'
  1. Weex (Retired)
  2. WEEX-217

WXTransform should not crash while parsing 'translate(0)' on iOS

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • iOS

    Description

      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:]

      - (void)parseTranslate:(NSArray *)value
      {
          [self parseTranslatex:@[value[0]]];
          [self parseTranslatey:@[value[1]]];
      }

      so 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.

      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.

      Attachments

        Issue Links

          Activity

            People

              cxfeng Adam Feng
              dechaos Gabriel Li
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified