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

Minify breaks on JSON since parse v2.3.6? #53

Closed
anthonyfok opened this issue Nov 8, 2019 · 1 comment
Closed

Minify breaks on JSON since parse v2.3.6? #53

anthonyfok opened this issue Nov 8, 2019 · 1 comment

Comments

@anthonyfok
Copy link

@regisphilibert reports at gohugoio/hugo#6472 that hugo --minify breaks on JSON since 59.0, which was right after Hugo updated the versioned dependency on tdewolff/parse and tdewolff/minify. The error message is:

Building sites … ERROR 2019/11/01 16:57:44 parse error:1:1: unexpected character
    1: {"output":{"data":{"created":"2010-02-11T12:46:02Z","draf...
       ^
ERROR 2019/11/01 16:57:44 parse error:1:1: unexpected character
    1: {"output":{"data":{"created":"2010-03-08T16:25:25Z","draf...
       ^

which seems to point to a bug in parse's JSON parser calling valid JSON an error.

@regisphilibert later on produced a MWE for us to test on, but with a different error message:

Error: Error building site: failed to render pages: parse error:1:1: unexpected character '<'
    1: <!DOCTYPE html><html><head><title>http://example.org/article/</title><link rel="canonical" href="http://example.org/article/"/><meta name="robots" content="noindex"><meta charset="utf-8" /><meta http-equiv="refresh" content="0; url=http://example.org/article/" /></head></html>

which in turns seem to indicate a bug in Hugo passing HTML code as if it were JSON to Minify (and to parse)

Further tests revealed that commit 7763141 in tdewolff/parse
7763141 as the oldest version of parse in which I could trigger the error.

When you have time, please read gohugoio/hugo#6472 for more details. Unfortunately, I am still struggling to understand the code, and I have exceeded my quota for today for further investigation. So, I'd better turn to expert like you to determine whether there is any bug in parse or minify at all regarding this issue.

Many thanks for your help!

tdewolff added a commit that referenced this issue Nov 27, 2019
…ror if the underlying byte slice is modified, partially fixes gohugoio/hugo#6427 and #53
@tdewolff
Copy link
Owner

Looks like this is fixed for parse. Error messages now show correct location and context, and the error messages have been improved. The remaining problem is that in Hugo HTML is being parsed by a JSON parser.

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