Summary: | FontFace constructor throws an exception when there is a name which starts with a number | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Ryosuke Niwa <rniwa> | ||||||
Component: | CSS | Assignee: | Myles C. Maxfield <mmaxfield> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | bfulgham, commit-queue, dino, koivisto, mmaxfield, webkit-bug-importer | ||||||
Priority: | P2 | Keywords: | InRadar | ||||||
Version: | WebKit Nightly Build | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=196381 | ||||||||
Attachments: |
|
Description
Ryosuke Niwa
2019-03-25 17:16:31 PDT
Huh, Blink doesn't seem to do any validation for the font name at all :( https://github.com/chromium/chromium/blob/master/third_party/blink/renderer/core/css/font_face.cc#L200 Oh, it's because there's a space in there. This is because of the historical difference between font-family:foo; and font-family:”foo”; FontFace::parseString() is passing its argument directly to consumeFontFamilyDescriptor() in CSSPropertyParser.cpp, which parses the string according to the first form. The first form doesn’t allow spaces. We should adopt the Chrome/Firefox behavior, and the spec should be clarified here. Created attachment 366004 [details]
Reduction
In Chrome & Firefox, this file would say "OK". In WebKit, it does not.
Relevant spec text: https://drafts.csswg.org/css-font-loading/#font-face-constructor > 1. ... > Parse the family argument, and the members of the descriptors argument, according to > the grammars of the corresponding descriptors of the CSS @font-face rule > ... https://drafts.csswg.org/css-fonts-4/#font-face-rule https://drafts.csswg.org/css-fonts-4/#font-family-desc https://drafts.csswg.org/css-fonts-4/#family-name-value Then finally, https://drafts.csswg.org/css-fonts-4/#family-name-syntax > Font family names other than generic families must either be given quoted as <string>s, or unquoted as a sequence of one or more identifiers. > ... > If a sequence of identifiers is given as a <family-name>, the computed value is the name converted to a string by joining all the identifiers in the sequence by single spaces. We probably need to amend the following text for FontFace constructor: https://drafts.csswg.org/css-font-loading/#font-face-constructor > If any of them fail to parse correctly, reject font face’s [[FontStatusPromise]] with a DOMException named "SyntaxError", set font face’s corresponding attributes to the empty string, and set font face’s status attribute to "error". Otherwise, set font face’s corresponding attributes to the serialization of the parsed values. Created attachment 366226 [details]
Patch
Comment on attachment 366226 [details] Patch Clearing flags on attachment: 366226 Committed r243637: <https://trac.webkit.org/changeset/243637> All reviewed patches have been landed. Closing bug. |