MyFaces Trinidad
  1. MyFaces Trinidad
  2. TRINIDAD-197

Obfuscation of addition statement where one of the items being added is an increment statement

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.0-incubating-plugins
    • Fix Version/s: 1.0.0-incubating-plugins
    • Component/s: Build
    • Labels:
      None
    • Environment:
      maven-javascript-plugin

      Description

      If you have JavaScript code like the following:

      var x = 1;
      var y = "" + ++x;

      It is a legal operation. However, if this code is run through the maven-javascript-plugin, the second line becomes something like this:

      var y=""+++x;

      This yields an invalid increment operand. Instead, the space between the "" and the "+" must be preserved. I also suspect (but have not tested) this may be a problem with this code too:

      var a = 1;
      var b = a++ + "";

      I suspect the increment and the decrement tokens in the obfuscater just need to be tagged as space sensitive (both before and after)--so we don't remove the spaces when compacting the code.

      1. obfuscator.plugin2.patch
        9 kB
        Kamran Kashanian
      2. obfuscator.plugin.patch
        9 kB
        Kamran Kashanian

        Activity

        Hide
        Adam Winer added a comment -

        Checked in second patch.

        Show
        Adam Winer added a comment - Checked in second patch.
        Hide
        Kamran Kashanian added a comment -

        This patch implements a less conservative approach to stripping whitespaces than the previous patch. While the previous patch left a single whitespace character around every JS token in the file, this patch restricts this to "unary" operators. In the grammar file unary operators include the following: delete, void, typeof, ++, --, +, -, ~, and !.

        Show
        Kamran Kashanian added a comment - This patch implements a less conservative approach to stripping whitespaces than the previous patch. While the previous patch left a single whitespace character around every JS token in the file, this patch restricts this to "unary" operators. In the grammar file unary operators include the following: delete, void, typeof, ++, --, +, -, ~, and !.
        Hide
        Kamran Kashanian added a comment -

        This patch fixes the stripping of white space characters around the pre/post increment operator. Note that the fix makes the logic for white space stripping extremely conservative. We now leave a single white space character around each token (for tokens that were surrounded by one or more white space characters). The advantage of this is that it prevents errors caused by aggressively stripping white space characters. The disadvantage is that it increases the size of the obfuscated javascript code. In the long run, we need to make this configurable, and I think there is a plan for me to revisit this in the near future.

        Show
        Kamran Kashanian added a comment - This patch fixes the stripping of white space characters around the pre/post increment operator. Note that the fix makes the logic for white space stripping extremely conservative. We now leave a single white space character around each token (for tokens that were surrounded by one or more white space characters). The advantage of this is that it prevents errors caused by aggressively stripping white space characters. The disadvantage is that it increases the size of the obfuscated javascript code. In the long run, we need to make this configurable, and I think there is a plan for me to revisit this in the near future.

          People

          • Assignee:
            Adam Winer
            Reporter:
            Matt Cooper
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development