Bug 203127 - ctx.font = "" asserts in CSS parser
Summary: ctx.font = "" asserts in CSS parser
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-10-17 16:54 PDT by Dean Jackson
Modified: 2019-10-17 17:44 PDT (History)
7 users (show)

See Also:


Attachments
Patch (13.89 KB, patch)
2019-10-17 16:59 PDT, Dean Jackson
hi: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2019-10-17 16:54:50 PDT
ctx.font = "" asserts in CSS parser
Comment 1 Radar WebKit Bug Importer 2019-10-17 16:55:29 PDT
<rdar://problem/56391016>
Comment 2 Dean Jackson 2019-10-17 16:59:48 PDT
Created attachment 381252 [details]
Patch
Comment 3 Devin Rousso 2019-10-17 17:14:42 PDT
Comment on attachment 381252 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=381252&action=review

r=me

> Source/WebCore/ChangeLog:13
> +        will assert. This was the only case I could find where we sidestepped
> +        most of the parsing infrastructure and injected a raw string.

For the record (which I think is what you were referring to), there are a number of other places where we call `CSSParser::parseValue`, and most of them already do a check for an empty string before calling it, but not all of them.

The only other one I could is `CSSFontFaceSet::matchingFacesExcludingPreinstalledFonts` (which looks to be reachable from JavaScript via `FontFaceSet.prototype.check`), so perhaps we should add a similar check there as well.

> LayoutTests/http/wpt/2dcontext/text-styles/2d.text.font.parse.invalid.html:21
> +ctx.font = '20px serif';

I realize this is a WPT, but should we have a test to check that setting a valid value after an invalid one does in fact change the `font`, just to make sure that an invalid value doesn't "permanently" mess everything up?
```
    ctx.font = '20px serif';
    ctx.font = 'invalid';
    ctx.font = '10px sans-serif';
    _assertSame(ctx.font, '10px sans-serif', "ctx.font", "'10px sans-serif'");
```
Comment 4 Dean Jackson 2019-10-17 17:25:56 PDT
Comment on attachment 381252 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=381252&action=review

>> LayoutTests/http/wpt/2dcontext/text-styles/2d.text.font.parse.invalid.html:21
>> +ctx.font = '20px serif';
> 
> I realize this is a WPT, but should we have a test to check that setting a valid value after an invalid one does in fact change the `font`, just to make sure that an invalid value doesn't "permanently" mess everything up?
> ```
>     ctx.font = '20px serif';
>     ctx.font = 'invalid';
>     ctx.font = '10px sans-serif';
>     _assertSame(ctx.font, '10px sans-serif', "ctx.font", "'10px sans-serif'");
> ```

We probably should. Feel free to make a WPT request :)
Comment 5 Dean Jackson 2019-10-17 17:26:12 PDT
Will do FontFaceSet separately.
Comment 6 Dean Jackson 2019-10-17 17:44:14 PDT
Committed r251270: <https://trac.webkit.org/changeset/251270>