--minify breaks on JSON since 59.0 #6472
Since 59.0 hugo throws errors when trying to minify JSON files.
It appears the minify lib has been updated to
I'll try and share a repo later.
The text was updated successfully, but these errors were encountered:
Hi Regis and Bjørn Erik,
Thank you for bringing this to my attention. Unfortunately, partly due to my unfamiliarity with the JSON output feature, or perhaps the JSON test cases that I have on hand are too simplistic, that I am unable to reproduce the error that you are seeing, so please do share a test repo when you have time. Many thanks!
The error is reported from parse in commit tdewolff/parse@7763141 (between v2.3.5 and v2.3.6): "Improve error messages for NULL and unknown values"
or fuller report after I tweaked tdewolff/parse code:
It would appear that somehow Hugo is trying to ask Minify to process HTML as if it were JSON, and before commit tdewolff/parse@7763141, such error was silently ignored by tdewolff/parse. So...
But then, it does not seem to explain the error message that @regisphilibert's originally encountered:
@regisphilibert, I know you are very busy, but, if possible, could you please also try to produce a MWE in order to get the error you see initially, i.e. "unexpected character" on seemingly valid JSON code?
@tdewolff, please help take a look and see if you can shed some light on this. Thank you!
(Sorry, I am really slow at trying to understand the code, and I have exceeded my quota for today, hence this "progress report" and plea for help.)
Note to self: In the example that @regisphilibert provided, Hugo apparently calls Minify() from func Transformer() in minifier/minifier.go:
return min.Minify(m.m, ft.To(), ft.From(), params)
I was going to try to decipher what
Wow, that was really quick! Thank you so much @regisphilibert!
Hmm... strange, the
p.err = parse.NewErrorLexer("unexpected character", p.r)
p.err = parse.NewErrorLexer("unexpected character"+string(c), p.r)
What I think is happening is that passing HTML is causing the error (ie. the
When the parser finds an error, it registers the
I have fixed this problem partially in email@example.com (with firstname.lastname@example.org). What remains is that Hugo parses a generated HTML document by a JSON parser.
This can be confirmed by adding:
before line 54 in