Truly independent web browser
LibWeb: Keep native line-ending conversion alive in process_blob_parts
Shannon Boothebf45e3eebe7
diff --git a/Libraries/LibWeb/FileAPI/Blob.cpp b/Libraries/LibWeb/FileAPI/Blob.cppindex 8e536c8da8b..b5a3d204b46 100644--- a/Libraries/LibWeb/FileAPI/Blob.cpp+++ b/Libraries/LibWeb/FileAPI/Blob.cpp@@ -127,14 +127,14 @@ ErrorOr<ByteBuffer> process_blob_parts(BlobParts const& blob_parts, Optional<Blo// 1. If element is a USVString, run the following sub-steps:[&](Utf16String const& string) -> ErrorOr<void> {// 1. Let s be element.- auto s = string.utf16_view();+ auto s = string;// 2. If the endings member of options is "native", set s to the result of converting line endings to native of element.if (options.has_value() && options->endings == EndingType::Native)s = TRY(convert_line_endings_to_native(s));// 3. Append the result of UTF-8 encoding s to bytes.- auto encoded_string = TRY(s.to_utf8());+ auto encoded_string = s.to_utf8();return bytes.try_append(encoded_string.bytes());},// 2. If element is a BufferSource, get a copy of the bytes held by the buffer source, and append those bytes to bytes.diff --git a/Tests/LibWeb/Text/expected/FileAPI/Blob-native-endings.txt b/Tests/LibWeb/Text/expected/FileAPI/Blob-native-endings.txtnew file mode 100644index 00000000000..f7c9b1412c8--- /dev/null+++ b/Tests/LibWeb/Text/expected/FileAPI/Blob-native-endings.txt@@ -0,0 +1,2 @@+transparent: size=3072 PASS+native: size=2048 PASSdiff --git a/Tests/LibWeb/Text/input/FileAPI/Blob-native-endings.html b/Tests/LibWeb/Text/input/FileAPI/Blob-native-endings.htmlnew file mode 100644index 00000000000..ff8920f2a21--- /dev/null+++ b/Tests/LibWeb/Text/input/FileAPI/Blob-native-endings.html@@ -0,0 +1,13 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ const input = "a\r\n".repeat(1024);++ const transparent = new Blob([input], { endings: "transparent" });+ println(`transparent: size=${transparent.size} ${(await transparent.text()) === input ? "PASS" : "FAIL"}`);++ const native = new Blob([input], { endings: "native" });+ println(`native: size=${native.size} ${(await native.text()) === "a\n".repeat(1024) ? "PASS" : "FAIL"}`);+ });+</script>