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

"Remove space between attributes when after a quoted value" results in invalid HTML #342

Closed
ghost opened this issue Oct 16, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 16, 2020

After updating from 2.9.4 to a newer version, we observed that we get invalid HTML. This is likely related to the change "HTML: remove space between attributes when after a quoted value" in 2.9.5.

Raw HTML

    <meta property="og:locale" content="en_US" />
    <meta property="og:site_name" content="InfoSec Handbook – information security blog" />
    <meta property="og:type" content="website" />
    <meta property="og:title" content="InfoSec Handbook – information security blog" />
    <meta property="og:description" content="A non-profit information security blog, operated by a community of InfoSec professionals – no ads, no tracking, free and secure." />
    <meta property="og:url" content="https://infosec-handbook.eu/" />
    <meta property="og:image" content="https://infosec-handbook.eu/img/l128.pn" />

Expected result (prior to 2.9.5)

<meta property="og:locale" content="en_US"><meta property="og:site_name" content="InfoSec Handbook – information security blog"><meta property="og:type" content="website"><meta property="og:title" content="InfoSec Handbook – information security blog"><meta property="og:description" content="A non-profit information security blog, operated by a community of InfoSec professionals – no ads, no tracking, free and secure."><meta property="og:url" content="https://infosec-handbook.eu/"><meta property="og:image" content="https://infosec-handbook.eu/img/l128.png">

Actual result (2.9.5 and newer)

<meta property="og:locale"content="en_US"><meta property="og:site_name"content="InfoSec Handbook – information security blog"><meta property="og:type"content="website"><meta property="og:title"content="InfoSec Handbook – information security blog"><meta property="og:description"content="A non-profit information security blog, operated by a community of InfoSec professionals – no ads, no tracking, free and secure."><meta property="og:url"content="https://infosec-handbook.eu/"><meta property="og:image"content="https://infosec-handbook.eu/img/l128.png">

In this example, minify removes whitespaces between …" content…, resulting in …"content….

Problem

The nu HTML checker and the developer mode of web browsers (e.g., Firefox) detect this as invalid HTML:

Error: No space between attributes.
At line 1, column 846
rty="og:locale"content="en_US"

There is no minify option to disable this new behavior, introduced in 2.9.5. --html-keep-whitespace doesn't disable the behavior.

Workaround

Downgrade to minify 2.9.4.

@ghost ghost changed the title Remove space between attributes when after a quoted value results in invalid HTML "Remove space between attributes when after a quoted value" results in invalid HTML Oct 16, 2020
@tdewolff
Copy link
Owner

Thank you for the notice! This was an optimization taken from another minifier, and I was sure the spec allowed this. However, upon second inspection of the HTML spec at https://html.spec.whatwg.org/multipage/syntax.html#start-tags it becomes clear that "Attributes must be separated from each other by one or more ASCII whitespace".

@ghost
Copy link
Author

ghost commented Oct 16, 2020

c2f5ff6 fixed the problem. We just rechecked on Arch Linux with 2.9.9.

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

1 participant