Skip to content

Problem with multi-line template literals #181

Closed

Description

@rustyblack

Hi, great project. Noticed an obscure bug, though:

Template literals starting with whitespace and containing a newline will sometimes confuse the obfuscator. For example:

function hi() {
    return ` Hello
        There`;
}

This gets obfuscated into:

function hi() {
    return;
    '\x20Hello\x0a\x09There';
}

Note that the return got separated from the literal, so the obfuscated function returns nothing.

The same thing happens if the backtick is immediately followed by a newline, e.g.:

function hi() {
    return `
        Hello There
    `;
}

Activity

  1. added this to the 0.14.0 milestone on Jan 24, 2018
  2. sanex3339 commented on Jan 24, 2018

    @sanex3339
    Member

    Same problem as here:
    jquery/esprima#1897

    Fixed here:
    jquery/esprima@9973bab

    But no release with fix yet.

  3. sanex3339 commented on Jan 24, 2018

    @sanex3339
    Member

    You can request faster release here:
    jquery/esprima#1882

  4. modified the milestones: 0.14.0, 0.15.0 on Jan 24, 2018
  5. sanex3339 commented on Feb 13, 2018

    @sanex3339
    Member

    So, i think i will temporary fix it from my side by correcting wrong AST tree

  6. modified the milestones: 0.15.0, 0.14.1 on Feb 13, 2018
  7. sido420 commented on Feb 13, 2018

    @sido420

    any ETA on our side? I've pinged on esprima already.

  8. 11 remaining items

  9. sanex3339 commented on Feb 15, 2018

    @sanex3339
    Member

    0.14.1 fixed template literals without additional expressions, like example in the first message.
    For more complicated expressions is slightly more difficult to find correct solution that won't break anything else.

  10. sanex3339 commented on Feb 15, 2018

    @sanex3339
    Member

    Fixed. Expect release in a hour or so.

  11. added a commit that references this issue on Feb 15, 2018
  12. sanex3339 commented on Feb 15, 2018

    @sanex3339
    Member

    Should be fixed in [email protected]

  13. bipinpatel-tech commented on Jul 9, 2018

    @bipinpatel-tech

    it's not working with following syntax
    sql_query = select * from blahblah where myids in (${ids.map(d=>'${d}').join(',')}) ${projectWhere} ;

  14. sanex3339 commented on Jul 9, 2018

    @sanex3339
    Member

    Hi, please format your code, looks like formatting is wrong.

  15. bipinpatel-tech commented on Jul 10, 2018

    @bipinpatel-tech

    Actual code

    sql_query = `select * from sub JOIN ps   ON 
    sub.subsystem_id=ps.subsystem_id
                                    JOIN project ON project.id = ps.project_id
                                    where sub.subsystem_uid in (${ids.map(d=>`'${d}'`).join(',')})
                                    ${otherWhere}
                                    `;
    
  16. sanex3339 commented on Jul 10, 2018

    @sanex3339
    Member

    Created issue: #288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions