NUglify
NUglify copied to clipboard
NullReferenceException in "ParseUnaryExpression"
When running Uglify.Js
on this string:
<!--
var test = true;
var test1 = false;
var test 3 = "maybe";
-->
I am getting a NullReferenceException with this stack trace:
at NUglify.JavaScript.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus)
at NUglify.JavaScript.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus)
at NUglify.JavaScript.JSParser.ParseExpressionStatement(Boolean fSourceElement)
at NUglify.JavaScript.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment)
at NUglify.JavaScript.JSParser.ParseStatements(BlockStatement block)
at NUglify.JavaScript.JSParser.InternalParse()
at NUglify.JavaScript.JSParser.Parse(DocumentContext sourceContext)
at NUglify.JavaScript.JSParser.Parse(DocumentContext sourceContext, CodeSettings settings)
at NUglify.Uglify.Js(String source, String fileName, CodeSettings codeSettings)
at NUglify.Uglify.Js(String source, CodeSettings codeSettings)
Is it possible to fix this on your side?
Right now I'm catching all exceptions and returning the un-uglified string but having zero NullReferenceExceptions would really be awesome.
So it shouldn't throw an exception, so I'll look at that.
What syntax is that? Half HTML comment and half JS? What are you expecting this to be and how to behave?
Thank you.
This was given to me by one of my webdesign co-workers. I assume this to be an excerpt from a larger script that failed to minify. So this is just a proof-of-concept.
Actually I am unsure how this should behave beside not throwing an exception.
Actually I am unsure how this should behave beside not throwing an exception.
Quite.
The parser generally does handle syntax errors. It usually omits the offending code and reports something useful. I'll take a look but as this is "exceptional" I can't promise a change