Bug 228170

Summary: XHR.send(Document) should replace mismatched surrogates with replacement character before sending
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, macpherson, menard, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Alex Christensen 2021-07-21 16:44:53 PDT
XHR.send(Document) should replace mismatched surrogates with replacement character before sending
Comment 1 Alex Christensen 2021-07-21 16:45:28 PDT
Created attachment 433971 [details]
Patch
Comment 2 Chris Dumez 2021-07-21 17:03:52 PDT
Comment on attachment 433971 [details]
Patch

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

> Source/WebCore/xml/XMLHttpRequest.cpp:467
> +static String convertIfNecessary(const String& input)

Isn't this the same as stringToUSVString()? If so, can we reuse it (maybe renaming stringToUSVString to replaceUnpairedSurrogatesWithReplacementCharacter, as its associated FIXME comment says)?
Comment 3 Alex Christensen 2021-07-21 18:44:38 PDT
Aha!  I knew it must exist already
Comment 4 Alex Christensen 2021-07-21 20:07:28 PDT
Created attachment 433983 [details]
Patch
Comment 5 Alex Christensen 2021-07-21 21:20:16 PDT
Created attachment 433987 [details]
Patch
Comment 6 Chris Dumez 2021-07-22 08:19:18 PDT
Comment on attachment 433987 [details]
Patch

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

> Source/WebCore/xml/XMLHttpRequest.cpp:487
> +        auto converted = stringToUSVString(WTFMove(serialized));

Would have been nice to rename stringToUSVString() to replaceUnpairedSurrogatesWithReplacementCharacter() since you are reusing it here for something that is not strictly a USVString conversion.
Comment 7 Alex Christensen 2021-07-22 09:45:33 PDT
Created attachment 434016 [details]
Patch
Comment 8 EWS 2021-07-22 10:44:41 PDT
Committed r280181 (239875@main): <https://commits.webkit.org/239875@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 434016 [details].
Comment 9 Radar WebKit Bug Importer 2021-07-22 10:45:15 PDT
<rdar://problem/80970543>