Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use <base> in resolving url attributes (like "href"). #6303

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions components/script/dom/element.rs
Expand Up @@ -10,6 +10,7 @@ use dom::attr::AttrValue;
use dom::namednodemap::NamedNodeMap;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::ElementBinding;
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
Expand Down Expand Up @@ -1061,6 +1062,9 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
let url = self.get_string_attribute(local_name);
let doc = document_from_node(self).root();
let base = doc.r().url();
let base = doc.r().QuerySelector("base".to_owned()).unwrap().map_or(base, |base| {
UrlParser::new().parse(&base.root().r().get_string_attribute(&atom!("href"))).unwrap()
});
// https://html.spec.whatwg.org/multipage/#reflect
// XXXManishearth this doesn't handle `javascript:` urls properly
match UrlParser::new().base_url(&base).parse(&url) {
Expand Down