"lang" attribute should be ascii-case-insensitive
Categories
(Core :: CSS Parsing and Computation, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox147 | --- | fixed |
People
(Reporter: e-school, Assigned: jfkthame)
Details
Attachments
(6 files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0
Steps to reproduce:
I had a lang attribute <html lang="DE-DE">.
Actual results:
This should actually be recognised, but the CSS setting ‘hyphen: auto’ does not work in this case. It does work with ‘de-DE’.
Expected results:
Although a notation such as "de-DE" is quite common, lang attributes should be case-insensitive according to RFC5646 and RFC5234.
Comment 1•1 month ago
|
||
| Assignee | ||
Comment 2•1 month ago
|
||
Indeed, for hyphens: auto we only seem to recognize the lang in its "canonical" case.
This also affects the language-dependent behavior of text-transform:
data:text/html,<div lang="NL-NL" style="text-transform:capitalize">how to capitalize ijsselmeer?
should result in the digraph "IJ" being capitalized as a unit, but it doesn't.
For some other purposes, however, it is correctly treated as case-insensitive; e.g.
data:text/html,<div lang="DE-DE">Does this use <q>German</q> quotes?
For quotes, this is handled in intl::QuotesForLang by parsing the lang as a locale code and canonicalizing the subtags if we don't find an entry for the original lang as provided. But I wonder if we should do the canonicalization earlier (before storing in the mLanguage field of the StyleFont struct)?
Comment 3•1 month ago
|
||
Yes, this code could lowercase the atom if needed or so. There are a few places that use the HTML language directly via nsIContent::GetLang tho...
| Assignee | ||
Comment 4•1 month ago
|
||
Yeah, that should work. My first thought was to do it in the GeckoBindings code (in Gecko_nsStyleFont_SetLang), but MapLangAttributeInto is better, as the potential effect on text-emphasis-position there should also be fixed.
In principle I think it seems preferable to use the LocaleService to canonicalize the tag, rather than simply lowercasing the string, so that we can keep using canonical form for things like hyphenation locales (e.g. Swiss German is de-CH, not de-ch) and rely on exact comparisons.
This does have a couple of side-effects, though: we currently have (Northern) Kurdish hyphenation patterns labelled using their ISO 639-3 code of kmr, but Locale::Canonicalize maps this to ISO 639-1 ku. So we'll need to re-label the patterns (which in the TeX world are tagged as kmr) to ku in order to use them.
The other thing I notice is that we have a couple of tests that explicitly assert that ISO 639-3 codes for Sindhi and Urdu are not recognized as triggering language-dependent behavior, as they are not the canonical tags for these languages. If we start canonicalizing the tag, these examples will change behavior. I think that's an acceptable -- perhaps even desirable -- change, though.
| Assignee | ||
Comment 5•1 month ago
|
||
Let's see how this goes: https://treeherder.mozilla.org/jobs?repo=try&landoCommitID=167289
| Assignee | ||
Comment 6•1 month ago
|
||
Updated•1 month ago
|
| Assignee | ||
Comment 7•1 month ago
|
||
| Assignee | ||
Comment 8•1 month ago
|
||
| Assignee | ||
Comment 9•1 month ago
|
||
| Assignee | ||
Comment 10•1 month ago
|
||
| Assignee | ||
Comment 11•1 month ago
|
||
This doesn't change behavior, just cleans up the code a bit by using the
nsStyleUtil helper.
Comment 12•1 month ago
|
||
Comment 13•1 month ago
|
||
Comment 15•1 month ago
|
||
| Assignee | ||
Updated•1 month ago
|
Comment 16•1 month ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/049c59a915d2
https://hg.mozilla.org/mozilla-central/rev/56273d257339
https://hg.mozilla.org/mozilla-central/rev/574cf09cc0e7
https://hg.mozilla.org/mozilla-central/rev/e957834932b9
https://hg.mozilla.org/mozilla-central/rev/ef4730680824
https://hg.mozilla.org/mozilla-central/rev/f3671a301bd5
Updated•1 month ago
|
Description
•