Bug 88157

Summary: <link> with non-CSS type should not be retrieved
Product: WebKit Reporter: Boris Zbarsky <bzbarsky>
Component: CSSAssignee: Rob Buis <rbuis>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, cdumez, commit-queue, darin, esprehn+autocc, ews-watchlist, gyuyoung.kim, rbuis, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Testcase
none
Patch to check if a link-elements type is text/css or not set before fetching
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Boris Zbarsky
Reported 2012-06-01 18:01:57 PDT
Created attachment 145414 [details] Testcase The attached testcase should render green text. In WebKit it renders red. Relevant spec is at http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element and says: For external resource links, the type attribute is used as a hint to user agents so that they can avoid fetching resources they do not support. ... If the UA does not support the given MIME type for the given link relationship, then the UA should not obtain the resource; WebKit's behavior here is not a spec violation per se, since this is a SHOULD level requirement, not a MUST. But unless there's a really good reason to violate the SHOULD it's probably better to follow it. Other UAs do.
Attachments
Testcase (189 bytes, text/html)
2012-06-01 18:01 PDT, Boris Zbarsky
no flags
Patch to check if a link-elements type is text/css or not set before fetching (919 bytes, patch)
2012-06-06 07:46 PDT, Sumedha Widyadharma
no flags
Patch (1.45 KB, patch)
2019-12-18 10:05 PST, Rob Buis
no flags
Patch (1.45 KB, patch)
2019-12-18 11:04 PST, Rob Buis
no flags
Patch (3.71 KB, patch)
2019-12-18 11:45 PST, Rob Buis
no flags
Patch (4.96 KB, patch)
2019-12-28 04:19 PST, Rob Buis
no flags
Patch (5.73 KB, patch)
2019-12-28 09:05 PST, Rob Buis
no flags
Patch (6.94 KB, patch)
2020-01-02 05:16 PST, Rob Buis
no flags
Patch (6.94 KB, patch)
2020-01-02 05:38 PST, Rob Buis
no flags
Sumedha Widyadharma
Comment 1 2012-06-06 07:46:00 PDT
Created attachment 146026 [details] Patch to check if a link-elements type is text/css or not set before fetching
Rob Buis
Comment 2 2019-12-18 10:05:50 PST
Rob Buis
Comment 3 2019-12-18 11:04:32 PST
Rob Buis
Comment 4 2019-12-18 11:45:45 PST
youenn fablet
Comment 5 2019-12-24 02:00:18 PST
Comment on attachment 385990 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=385990&action=review > Source/WebCore/html/HTMLLinkElement.cpp:278 > + bool treatAsStyleSheet = (m_relAttribute.isStyleSheet && (m_type.isNull() || m_type.containsIgnoringASCIICase("text/css"))) What happens for "ABCtext/css", "text/cssDEF"? Should we have more edge case tests. Might be nice to have these as WPT tests as well and verify we match other browser behaviours.
Rob Buis
Comment 6 2019-12-28 04:19:47 PST
Rob Buis
Comment 7 2019-12-28 09:05:38 PST
Rob Buis
Comment 8 2020-01-02 05:16:25 PST
Rob Buis
Comment 9 2020-01-02 05:38:58 PST
Rob Buis
Comment 10 2020-01-02 05:59:55 PST
(In reply to youenn fablet from comment #5) > Comment on attachment 385990 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=385990&action=review > > > Source/WebCore/html/HTMLLinkElement.cpp:278 > > + bool treatAsStyleSheet = (m_relAttribute.isStyleSheet && (m_type.isNull() || m_type.containsIgnoringASCIICase("text/css"))) > > What happens for "ABCtext/css", "text/cssDEF"? > Should we have more edge case tests. > Might be nice to have these as WPT tests as well and verify we match other > browser behaviours. The tests are now added to the WPT repo: https://github.com/web-platform-tests/wpt/pull/20930 I imported them into this patch.
WebKit Commit Bot
Comment 11 2020-01-03 01:41:45 PST
Comment on attachment 386602 [details] Patch Clearing flags on attachment: 386602 Committed r253992: <https://trac.webkit.org/changeset/253992>
WebKit Commit Bot
Comment 12 2020-01-03 01:41:47 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 13 2020-01-03 01:42:18 PST
Darin Adler
Comment 14 2020-01-03 19:11:57 PST
Comment on attachment 386602 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=386602&action=review > Source/WebCore/html/HTMLLinkElement.cpp:287 > + treatAsStyleSheet = document().settings().treatsAnyTextCSSLinkAsStylesheet() && m_type.containsIgnoringASCIICase("text/css"); Calling "contains" here can’t possibly be exactly right, since it’s just a substring check, not checking for delimiters or anything. Not new, but not correct.
Rob Buis
Comment 15 2020-01-03 23:05:44 PST
(In reply to Darin Adler from comment #14) > Comment on attachment 386602 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=386602&action=review > > > Source/WebCore/html/HTMLLinkElement.cpp:287 > > + treatAsStyleSheet = document().settings().treatsAnyTextCSSLinkAsStylesheet() && m_type.containsIgnoringASCIICase("text/css"); > > Calling "contains" here can’t possibly be exactly right, since it’s just a > substring check, not checking for delimiters or anything. Not new, but not > correct. But does the check not make sense together with treatsAnyTextCSSLinkAsStylesheet setting? What is the history behind the setting and is it not needed anymore? Anyway, will investigate.
Note You need to log in before you can comment on or make changes to this bug.