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

Regular expression parsing error #160

Closed
Taritsyn opened this issue Feb 11, 2019 · 2 comments
Closed

Regular expression parsing error #160

Taritsyn opened this issue Feb 11, 2019 · 2 comments

Comments

@Taritsyn
Copy link
Contributor

Hello, Dmitry!

When parsing a [^]*?(:[rp][el]a[\w-]+)[^]* regular expression, the following error occurs:

NiL.JS.Core.JSException: SyntaxError: parsing '[^]*?(:[rp][el]a[\w-]+)[^]*' - Unterminated [] set.
   at NiL.JS.ExceptionHelper.Throw(Error error)
   at NiL.JS.BaseLibrary.RegExp.makeRegex(String pattern, String flags)
   at NiL.JS.Expressions.RegExpExpression.Evaluate(Context context)
   at NiL.JS.Expressions.Assignment.Evaluate(Context context)
   at NiL.JS.Statements.VariableDefinition.Evaluate(Context context)
   at NiL.JS.Statements.CodeBlock.evaluateLines(Context context, Int32 i, Boolean clearSuspendData)
   at NiL.JS.Statements.CodeBlock.Evaluate(Context context)
   at NiL.JS.Core.Context.Eval(String code, JSValue thisBind, Boolean suppressScopeCreation)
   at TestNilJs.Program.Main(String[] args) in C:\Projects\!EXPERIMENTAL\NiL.JS\TestNilJs\TestNilJs\Program.cs:line 12

This error does not occur in the latest versions of V8 and ChakraCore, but is also typical for Jurassic and Jint.

You can use the following C#-code to reproduce the error:

using System;

using NiL.JS.Core;

namespace TestNilJs
{
    class Program
    {
        static void Main(string[] args)
        {
            const string code = @"var na = /[^]*?(:[rp][el]a[\w-]+)[^]*/;";
            var context = new Context(true);

            try
            {
                context.Eval(code);
            }
            catch (JSException e)
            {
                Console.Write(e.ToString());
            }
        }
    }
}
@nilproject
Copy link
Owner

nilproject commented Feb 15, 2019

Hello, Andrey!
Yes, it's known bug. It's because I used System.Text.RegularExpressions, which is not fully compatible with JavaScript RegExp.

@Taritsyn
Copy link
Contributor Author

OK. Looks like that this issue needs to be sent to Microsoft.

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

No branches or pull requests

2 participants