Bug 228170 - XHR.send(Document) should replace mismatched surrogates with replacement character before sending
Summary: XHR.send(Document) should replace mismatched surrogates with replacement char...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-07-21 16:44 PDT by Alex Christensen
Modified: 2021-07-22 10:45 PDT (History)
10 users (show)

See Also:


Attachments
Patch (5.14 KB, patch)
2021-07-21 16:45 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (3.76 KB, patch)
2021-07-21 20:07 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (3.98 KB, patch)
2021-07-21 21:20 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (9.96 KB, patch)
2021-07-22 09:45 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>