LibWeb: Add support for the <base> element changing the base URL

Used by Google seemingly almost all around account sign in and
management. The modern sign in page has this near the beginning:
```html
<base href="https://accounts.google.com">
```
All of the XHRs performed by sign in are relative URLs to this
base URL. Previously we ignored this and did it relative to the
current URL, causing the XHRs to 404 and sign in to fall apart.

I presume they do this because you can access the sign in page
from multiple endpoints, such as `/ServiceLogin` and
`/o/oauth2/auth/identifier`
This commit is contained in:
Luke Wilde 2022-06-19 16:02:48 +01:00 committed by Linus Groh
parent b3d87f8e37
commit 1f820f8840
Notes: sideshowbarker 2024-07-17 10:04:37 +09:00
7 changed files with 111 additions and 8 deletions

View file

@ -62,9 +62,8 @@ String WindowEnvironmentSettingsObject::api_url_character_encoding()
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:api-base-url
AK::URL WindowEnvironmentSettingsObject::api_base_url()
{
// FIXME: Return the current base URL of window's associated Document.
// (This currently just returns the current document URL, not accounting for <base> elements and such)
return m_window->associated_document().url();
// Return the current base URL of window's associated Document.
return m_window->associated_document().base_url();
}
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:concept-settings-object-origin