Bug 236784

Summary: Use more StringView during CSP parsing
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebCore Misc.Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, darin, ews-watchlist, ggaren, mkwst, sam, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2022-02-17 08:16:46 PST
Use more StringView during CSP parsing.
Comment 1 Chris Dumez 2022-02-17 08:18:30 PST
Created attachment 452372 [details]
Patch
Comment 2 Darin Adler 2022-02-17 16:20:24 PST
Comment on attachment 452372 [details]
Patch

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

As long as we don’t need these things to outlive the buffer we are parsing, this is a great thing to do.

> Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp:386
> -template<typename CharacterType> std::optional<String> ContentSecurityPolicySourceList::parseScheme(StringParsingBuffer<CharacterType> buffer)
> +template<typename CharacterType> std::optional<StringView> ContentSecurityPolicySourceList::parseScheme(StringParsingBuffer<CharacterType> buffer)

Given that both String and StringView have a null value, I am surprised that we feel the need to use std::optional.
Comment 3 Chris Dumez 2022-02-17 16:22:08 PST
(In reply to Darin Adler from comment #2)
> Comment on attachment 452372 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=452372&action=review
> 
> As long as we don’t need these things to outlive the buffer we are parsing,
> this is a great thing to do.
> 
> > Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp:386
> > -template<typename CharacterType> std::optional<String> ContentSecurityPolicySourceList::parseScheme(StringParsingBuffer<CharacterType> buffer)
> > +template<typename CharacterType> std::optional<StringView> ContentSecurityPolicySourceList::parseScheme(StringParsingBuffer<CharacterType> buffer)
> 
> Given that both String and StringView have a null value, I am surprised that
> we feel the need to use std::optional.

That is true. I'll see if I can fix this up too.
Comment 4 Chris Dumez 2022-02-17 19:51:28 PST
Created attachment 452473 [details]
Patch
Comment 5 EWS 2022-02-18 09:26:52 PST
Committed r290131 (247475@main): <https://commits.webkit.org/247475@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 452473 [details].
Comment 6 Radar WebKit Bug Importer 2022-02-18 09:27:22 PST
<rdar://problem/89149597>