Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScriptParser.ParseProgram throws ArgumentOutOfRangeException #70

Closed
Metalnem opened this issue Jan 10, 2019 · 1 comment · Fixed by #379
Closed

JavaScriptParser.ParseProgram throws ArgumentOutOfRangeException #70

Metalnem opened this issue Jan 10, 2019 · 1 comment · Fixed by #379
Labels

Comments

@Metalnem
Copy link

JavaScriptParser.ParseProgram sometimes throws ArgumentOutOfRangeException (this is different from the ArgumentOutOfRangeException found in sebastienros/jint#571). Here is the complete C# program for reproducing the issue:

using Esprima;

namespace esprima.Run
{
  public class Program
  {
    public static void Main(string[] args)
    {
      var parser = new JavaScriptParser("Fu>\\u{ddee}\\u{dn");
      parser.ParseProgram();
    }
  }
}

The stack trace:

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Private.CoreLib.dll: 'A valid UTF32 value is between 0x000000 and 0x10ffff, inclusive, and should not include surrogate codepoint values (0x00d800 ~ 0x00dfff).'
   at System.Char.ConvertFromUtf32(Int32 utf32)
   at Esprima.Scanner.GetComplexIdentifier()
   at Esprima.Scanner.ScanIdentifier()
   at Esprima.JavaScriptParser.NextToken()
   at Esprima.JavaScriptParser.ParseBinaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseConditionalExpression()
   at Esprima.JavaScriptParser.ParseAssignmentExpression()
   at Esprima.JavaScriptParser.IsolateCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseExpression()
   at Esprima.JavaScriptParser.ParseLabelledStatement()
   at Esprima.JavaScriptParser.ParseStatement()
   at Esprima.JavaScriptParser.ParseStatementListItem()
   at Esprima.JavaScriptParser.ParseProgram(Boolean strict)

Found via SharpFuzz.

@ahmetkakici
Copy link

I was using JavascriptPaser to validate user provided scripts while using jint v2.
It was throwing ParserException with the line number, column and description information.
But now with v3, JavascriptParser's ParseProgram throws ArgumentOutOfRangeException without any information.

Btw, if i use Escape's JavascriptParser, ParseProgram still throws ParserException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants