diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2022-08-01 20:41:53 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-08-02 08:20:40 +0100 |
commit | c8c5f05de537c7934d659fe175035f097896d85d (patch) | |
tree | 8af0deb57302d4504e58bef81fe7ca5180e4ecd9 | |
parent | 73aec263b16994df4d2dc49ec41392629d519625 (diff) | |
download | serenity-c8c5f05de537c7934d659fe175035f097896d85d.zip |
LibWeb: Make sure Blob type is not outside range 0x0020-0x007E
This makes sure that type is set to an empty string if
BlobPropertyBag::type is outside the range 0x0020 to 0x007E.
-rw-r--r-- | Userland/Libraries/LibWeb/FileAPI/Blob.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index c6887f89bd..f280427fbf 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -132,10 +132,17 @@ DOM::ExceptionOr<NonnullRefPtr<Blob>> Blob::create(Optional<Vector<BlobPart>> co String type = String::empty(); // 3. If the type member of the options argument is not the empty string, run the following sub-steps: if (options.has_value() && !options->type.is_empty()) { - // FIXME: 1. Let t be the type dictionary member. If t contains any characters outside the range U+0020 to U+007E, then set t to the empty string and return from these substeps. + // 1. If the type member is provided and is not the empty string, let t be set to the type dictionary member. + // If t contains any characters outside the range U+0020 to U+007E, then set t to the empty string and return from these substeps. + // NOTE: t is set to empty string at declaration. + if (!options->type.is_empty()) { + if (is_basic_latin(options->type)) + type = options->type; + } // 2. Convert every character in t to ASCII lowercase. - type = options->type.to_lowercase(); + if (!type.is_empty()) + type = options->type.to_lowercase(); } // 4. Return a Blob object referring to bytes as its associated byte sequence, with its size set to the length of bytes, and its type set to the value of t from the substeps above. |