mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 10:36:02 +00:00
LibWeb+LibURL: Get blob's environments origin from URL's blob entry
This closer matches specification - and removes any dependency on LibWeb in the implementation of DOMURL::url_origin. It is also one step closer to moving BlobURLRegistry to a singleton process to match LibWeb's multiprocess Worker architecture.
This commit is contained in:
parent
43973f2d0a
commit
12ea470417
Notes:
github-actions[bot]
2024-10-05 08:47:38 +00:00
Author: https://github.com/shannonbooth
Commit: 12ea470417
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1636
4 changed files with 7 additions and 2 deletions
|
@ -91,6 +91,7 @@ ErrorOr<URL::URL> decode(Decoder& decoder)
|
|||
url.set_blob_url_entry(URL::BlobURLEntry {
|
||||
.type = TRY(decoder.decode<String>()),
|
||||
.byte_buffer = TRY(decoder.decode<ByteBuffer>()),
|
||||
.environment_origin = TRY(decoder.decode<URL::Origin>()),
|
||||
});
|
||||
|
||||
return url;
|
||||
|
|
|
@ -111,6 +111,7 @@ ErrorOr<void> encode(Encoder& encoder, URL::URL const& value)
|
|||
|
||||
TRY(encoder.encode(blob.type));
|
||||
TRY(encoder.encode(blob.byte_buffer));
|
||||
TRY(encoder.encode(blob.environment_origin));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibURL/Host.h>
|
||||
#include <LibURL/Origin.h>
|
||||
|
||||
// On Linux distros that use mlibc `basename` is defined as a macro that expands to `__mlibc_gnu_basename` or `__mlibc_gnu_basename_c`, so we undefine it.
|
||||
#if defined(AK_OS_LINUX) && defined(basename)
|
||||
|
@ -44,6 +45,7 @@ enum class ExcludeFragment {
|
|||
struct BlobURLEntry {
|
||||
String type;
|
||||
ByteBuffer byte_buffer;
|
||||
Origin environment_origin;
|
||||
};
|
||||
|
||||
void append_percent_encoded_if_necessary(StringBuilder&, u32 code_point, PercentEncodeSet set = PercentEncodeSet::Userinfo);
|
||||
|
|
|
@ -489,8 +489,8 @@ URL::Origin url_origin(URL::URL const& url)
|
|||
auto url_string = url.to_string().release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 1. If url’s blob URL entry is non-null, then return url’s blob URL entry’s environment’s origin.
|
||||
if (auto blob_url_entry = FileAPI::blob_url_store().get(url_string); blob_url_entry.has_value())
|
||||
return blob_url_entry->environment->origin();
|
||||
if (url.blob_url_entry().has_value())
|
||||
return url.blob_url_entry()->environment_origin;
|
||||
|
||||
// 2. Let pathURL be the result of parsing the result of URL path serializing url.
|
||||
auto path_url = parse(url.serialize_path());
|
||||
|
@ -582,6 +582,7 @@ URL::URL parse(StringView input, Optional<URL::URL> const& base_url, Optional<St
|
|||
url.set_blob_url_entry(URL::BlobURLEntry {
|
||||
.type = blob_url_entry->object->type(),
|
||||
.byte_buffer = MUST(ByteBuffer::copy(blob_url_entry->object->raw_bytes())),
|
||||
.environment_origin = blob_url_entry->environment->origin(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue