mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-03 08:52:54 +00:00
LibWeb: Parse mimetype when creating Blob and File
This commit is contained in:
parent
0739f1b1e6
commit
193c0dcafc
Notes:
github-actions[bot]
2024-10-04 18:57:01 +00:00
Author: https://github.com/stelar7
Commit: 193c0dcafc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1619
2 changed files with 19 additions and 19 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/StructuredSerialize.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/MimeSniff/MimeType.h>
|
||||
#include <LibWeb/Streams/AbstractOperations.h>
|
||||
#include <LibWeb/Streams/ReadableStreamDefaultReader.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
@ -197,17 +198,17 @@ JS::NonnullGCPtr<Blob> Blob::create(JS::Realm& realm, Optional<Vector<BlobPart>>
|
|||
auto type = String {};
|
||||
// 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()) {
|
||||
// 1. If the type member is provided and is not the empty string, let t be set to the type dictionary member.
|
||||
// FIXME: 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;
|
||||
}
|
||||
// FIXME: 2. Convert every character in t to ASCII lowercase.
|
||||
|
||||
// 2. Convert every character in t to ASCII lowercase.
|
||||
if (!type.is_empty())
|
||||
type = MUST(Infra::to_ascii_lowercase(type));
|
||||
// NOTE: The spec is out of date, and we are supposed to call into the MimeType parser here.
|
||||
if (!options->type.is_empty()) {
|
||||
auto maybe_parsed_type = MUST(Web::MimeSniff::MimeType::parse(options->type));
|
||||
|
||||
if (maybe_parsed_type.has_value())
|
||||
type = MUST(maybe_parsed_type->serialized());
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue