Bug 59322

Summary: Web Inspector: CSS is parsed improperly when saved in UTF-8 with a BOM
Product: WebKit Reporter: Alexander Pavlov (apavlov) <apavlov>
Component: Web Inspector (Deprecated)Assignee: Alexander Pavlov (apavlov) <apavlov>
Status: RESOLVED FIXED    
Severity: Normal CC: apavlov, bweinstein, joepeck, keishi, loislo, pfeldman, pmuellr, rik, timothy, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Suggested fix pfeldman: review-

Description Alexander Pavlov (apavlov) 2011-04-25 07:59:26 PDT
A UTF-8 BOM is not handled properly by the CSSParser (and it should never get through to it).

Upstreaming http://code.google.com/p/chromium/issues/detail?id=78703
Comment 1 Alexander Pavlov (apavlov) 2011-04-25 08:27:59 PDT
Created attachment 90917 [details]
[PATCH] Suggested fix
Comment 2 Yury Semikhatsky 2011-04-25 08:34:08 PDT
Comment on attachment 90917 [details]
[PATCH] Suggested fix

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

> LayoutTests/inspector/styles/parse-utf8-bom.html:15
> +        InspectorTest.dumpSelectedElementStyles(true, false, true);

Can we be sure that the styles content is already loaded at this point?
Comment 3 Alexander Pavlov (apavlov) 2011-04-25 08:41:00 PDT
(In reply to comment #2)
> (From update of attachment 90917 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=90917&action=review
> 
> > LayoutTests/inspector/styles/parse-utf8-bom.html:15
> > +        InspectorTest.dumpSelectedElementStyles(true, false, true);
> 
> Can we be sure that the styles content is already loaded at this point?

Yes, all external stylesheets will have been loaded by the time window.onload fires.
Comment 4 Alexander Pavlov (apavlov) 2011-04-25 08:54:42 PDT
Committed r84777: <http://trac.webkit.org/changeset/84777>
Comment 5 Pavel Feldman 2011-04-25 09:33:48 PDT
Comment on attachment 90917 [details]
[PATCH] Suggested fix

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

> Source/WebCore/inspector/InspectorStyleSheet.cpp:1061
> +        success = resourceStyleSheetText(&rawText);

You should instead fetch CachedResource, cast it to the Stylesheet and get decoded data.