Menu

#1907 Failed to parse javascript

2.27
pending
nobody
None
1
2018-03-07
2017-08-02
ChristopheD
No

Hello,

HtmlUnit failed to parse a Javascript (maybe the javascript is malformed) with the error :

ERROR [main] (com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter) - error: message=[missing ; before statement] sourceName=...

Browsers are able to manage that missing ; so is there any parameter at the htmlUnit that would allow me set the parsing to a less strict mode ?

Regards,
Christophe

Discussion

  • Ahmed Ashour

    Ahmed Ashour - 2017-08-02

    Please provide test case.

     
  • ChristopheD

    ChristopheD - 2017-08-02

    Hi,

    Here is the javascript file that failed to be parsed : https://goo.gl/iQCpw3

    Regards,
    Christophe

     
  • RBRi

    RBRi - 2017-08-02

    Ok, can reproduce your problem, but the js file hast 17000 lines, and contains also minified js code. If you like to have this fixed it will be a great help if you can strip down this to a simple sample.

     
  • RBRi

    RBRi - 2017-08-02
    • status: open --> pending
     
  • RBRi

    RBRi - 2017-08-02

    From a first look i guess class definitions like

    class GeoRedirect {
    }
    

    are not supported by Rhino/Core-JS so far

     
  • ChristopheD

    ChristopheD - 2017-08-02

    Hi,

    Thank you for your help. Unfortunately this is a JS from one of our customer and we have no option to alter it.

    Is there any option to skip the unsupported code ?

    Regards,
    Christophe

     
    • RBRi

      RBRi - 2017-08-04

      Maybe you can try to 'fix' the code by makeing some changes before HtmlUnit tries to parse the code.
      Have a look at the FAQ. There is a sample
      How to modify the outgoing request or incomming response.

      RBRi
      
       

      Last edit: RBRi 2017-08-30
  • ChristopheD

    ChristopheD - 2017-08-04

    Hi,

    I did it and it works now. Any idea when HtmlUnit will be able to manage classes in Javascript ?

    Regards,
    Christophe

     
  • RBRi

    RBRi - 2018-03-07

    This depends on Rhino, maybe you can ask there or vote...

     

Log in to post a comment.