mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Handle unpaired surrogates in USVStrings
This should fix (at least) the last two remaining WPT test failures in FileAPI/unicode.html.
This commit is contained in:
parent
5559a3dc6e
commit
55f0dc823f
Notes:
github-actions[bot]
2024-10-13 21:25:25 +00:00
Author: https://github.com/justus2510
Commit: 55f0dc823f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1761
Reviewed-by: https://github.com/shannonbooth ✅
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 26 additions and 4 deletions
|
@ -1414,19 +1414,23 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
||||||
)~~~");
|
)~~~");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool includes_string = false;
|
RefPtr<IDL::Type const> string_type;
|
||||||
for (auto& type : types) {
|
for (auto& type : types) {
|
||||||
if (type->is_string()) {
|
if (type->is_string()) {
|
||||||
includes_string = true;
|
string_type = type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includes_string) {
|
if (string_type) {
|
||||||
// 14. If types includes a string type, then return the result of converting V to that type.
|
// 14. If types includes a string type, then return the result of converting V to that type.
|
||||||
// NOTE: Currently all string types are converted to String.
|
// NOTE: Currently all string types are converted to String.
|
||||||
|
|
||||||
|
IDL::Parameter parameter { .type = *string_type, .name = ByteString::empty(), .optional_default_value = {}, .extended_attributes = {} };
|
||||||
|
generate_to_cpp(union_generator, parameter, js_name, js_suffix, ByteString::formatted("{}{}_string", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1);
|
||||||
|
|
||||||
union_generator.append(R"~~~(
|
union_generator.append(R"~~~(
|
||||||
return TRY(@js_name@@js_suffix@.to_string(vm));
|
return { @js_name@@js_suffix@_string };
|
||||||
)~~~");
|
)~~~");
|
||||||
} else if (numeric_type && includes_bigint) {
|
} else if (numeric_type && includes_bigint) {
|
||||||
// 15. If types includes a numeric type and bigint, then return the result of converting V to either that numeric type or bigint.
|
// 15. If types includes a numeric type and bigint, then return the result of converting V to either that numeric type or bigint.
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
PASS
|
||||||
|
PASS
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
asyncTest(async (done) => {
|
||||||
|
const unpairedSurrogates = "hello\uDC00friends\uD800:)";
|
||||||
|
const replacedSurrogates = "hello\uFFFDfriends\uFFFD:)";
|
||||||
|
|
||||||
|
const blob = new Blob([unpairedSurrogates]);
|
||||||
|
println(await blob.text() === replacedSurrogates ? "PASS" : "FAIL")
|
||||||
|
|
||||||
|
const file = new File([unpairedSurrogates], "someFileName");
|
||||||
|
println(await file.text() === replacedSurrogates ? "PASS" : "FAIL")
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue