Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use [*=" "] to check for forbidden whitespaces #397

Closed
3 tasks done
ffoodd opened this issue Oct 27, 2020 · 7 comments · Fixed by #412
Closed
3 tasks done

Use [*=" "] to check for forbidden whitespaces #397

ffoodd opened this issue Oct 27, 2020 · 7 comments · Fixed by #412

Comments

@ffoodd
Copy link
Owner

ffoodd commented Oct 27, 2020

A few attributes shouldn't contain any whitespace, such as id or lang (see #396).

@matuzo's clever selector using the contains flag for attribute selector would help a lot. Things to consider:

  • Which HTML attributes shouldn't contain whitespace?
  • Which current tests could be improved this way?
  • Which of whitespaces should be tested? Tricky trick gone too far, maybe?

Quite a big one :)

@ffoodd
Copy link
Owner Author

ffoodd commented Oct 27, 2020

Other way around: should it have its own test, just as invalid nesting? This is syntax, after all.
Or improving current attributes selectors would cover the same?

@matuzo
Copy link

matuzo commented Oct 28, 2020

For the sake of completeness, it was @Schepp's idea. I just made the demos and tested it. :)

@ffoodd
Copy link
Owner Author

ffoodd commented Oct 28, 2020

Thanks for pointing him out 👍
Everyone will go to the credits page, wouldn't have discover it without your sharing :D

@Dionakra
Copy link
Contributor

Dionakra commented Jan 8, 2021

Reading the HTML standard, I only found two attributes that may not include whitespaces:

  • [id]: The id attribute value must be unique amongst all the IDs in the element's tree and must contain at least one character. The value must not contain any ASCII whitespace.
  • map[name]: The name attribute gives the map a name so that it can be referenced. The attribute must be present and must have a non-empty value with no ASCII whitespace

Regarding the lang tag, there is not anything specific about whitespaces. I will write what I found in #396.

@ffoodd
Copy link
Owner Author

ffoodd commented Jan 8, 2021

Well, in fact the RFC mentions that no whitespace should be present in a language tag (2 paragraphs above this anchor) and the spec says "Its value must be a valid BCP 47 language tag" — using "a", so I interpret this as "a single".

As far as I understand, that means lang attribute should not contain whitespace either—am I missing something?

@Dionakra
Copy link
Contributor

Dionakra commented Jan 8, 2021

You are correct, I didn't read that RFC in detail, this I missed that part. Sorry about that! Will include that check in the #396 as well.

@ffoodd
Copy link
Owner Author

ffoodd commented Jan 8, 2021

No worry, reading specs and RFCs is not a that easy (and probably not everyone's hobby neither!). Your insights and researches are greatly appreciated, thanks a lot ❤️

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants