mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Stop messing with the case of the attribute name in AttributeHandlers::get_attribute.
This fixes a bug where GetAttributeNS would incorrectly match lower-case attributes when called with an upper-case argument.
This commit is contained in:
parent
25f263b751
commit
d0e095a3e5
3 changed files with 9 additions and 116 deletions
|
@ -252,7 +252,10 @@ impl<'a> ElementHelpers for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AttributeHandlers {
|
pub trait AttributeHandlers {
|
||||||
fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>>;
|
/// Returns the attribute with given namespace and case-sensitive local
|
||||||
|
/// name, if any.
|
||||||
|
fn get_attribute(&self, namespace: Namespace, local_name: &str)
|
||||||
|
-> Option<Temporary<Attr>>;
|
||||||
fn set_attribute_from_parser(&self, local_name: Atom,
|
fn set_attribute_from_parser(&self, local_name: Atom,
|
||||||
value: DOMString, namespace: Namespace,
|
value: DOMString, namespace: Namespace,
|
||||||
prefix: Option<DOMString>);
|
prefix: Option<DOMString>);
|
||||||
|
@ -282,13 +285,9 @@ pub trait AttributeHandlers {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>> {
|
fn get_attribute(&self, namespace: Namespace, local_name: &str) -> Option<Temporary<Attr>> {
|
||||||
let element: &Element = self.deref();
|
let local_name = Atom::from_slice(local_name);
|
||||||
let local_name = match self.html_element_in_html_document() {
|
self.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| {
|
||||||
true => Atom::from_slice(name.to_ascii_lower().as_slice()),
|
|
||||||
false => Atom::from_slice(name)
|
|
||||||
};
|
|
||||||
element.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| {
|
|
||||||
*attr.local_name() == local_name && attr.namespace == namespace
|
*attr.local_name() == local_name && attr.namespace == namespace
|
||||||
}).map(|x| Temporary::from_rooted(&*x))
|
}).map(|x| Temporary::from_rooted(&*x))
|
||||||
}
|
}
|
||||||
|
@ -423,6 +422,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_url_attribute(&self, name: &str) -> DOMString {
|
fn get_url_attribute(&self, name: &str) -> DOMString {
|
||||||
|
assert!(name == name.to_ascii_lower().as_slice());
|
||||||
// XXX Resolve URL.
|
// XXX Resolve URL.
|
||||||
self.get_string_attribute(name)
|
self.get_string_attribute(name)
|
||||||
}
|
}
|
||||||
|
@ -431,6 +431,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_string_attribute(&self, name: &str) -> DOMString {
|
fn get_string_attribute(&self, name: &str) -> DOMString {
|
||||||
|
assert!(name == name.to_ascii_lower().as_slice());
|
||||||
match self.get_attribute(Null, name) {
|
match self.get_attribute(Null, name) {
|
||||||
Some(x) => {
|
Some(x) => {
|
||||||
let x = x.root();
|
let x = x.root();
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
[attributes.html]
|
[attributes.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[setAttribute should lowercase its name argument (upper case attribute)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setAttribute should lowercase its name argument (mixed case attribute)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setAttribute should set the attribute with the given qualified name]
|
[setAttribute should set the attribute with the given qualified name]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -15,12 +9,6 @@
|
||||||
[First set attribute is returned by getAttribute]
|
[First set attribute is returned by getAttribute]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Only lowercase attributes are returned on HTML elements (upper case attribute)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Only lowercase attributes are returned on HTML elements (mixed case attribute)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[First set attribute is returned with mapped attribute set later]
|
[First set attribute is returned with mapped attribute set later]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,9 @@
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,abc,Abc]
|
[createElementNS http://www.w3.org/1999/xhtml,abc,Abc]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,abc,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,abc,ABC]
|
[createElementNS http://www.w3.org/1999/xhtml,abc,ABC]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,abc,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,abc,\xc3\xa4]
|
[createElementNS http://www.w3.org/1999/xhtml,abc,\xc3\xa4]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -27,15 +21,9 @@
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,Abc,Abc]
|
[createElementNS http://www.w3.org/1999/xhtml,Abc,Abc]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,Abc,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,Abc,ABC]
|
[createElementNS http://www.w3.org/1999/xhtml,Abc,ABC]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,Abc,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,Abc,\xc3\xa4]
|
[createElementNS http://www.w3.org/1999/xhtml,Abc,\xc3\xa4]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -48,15 +36,9 @@
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,ABC,Abc]
|
[createElementNS http://www.w3.org/1999/xhtml,ABC,Abc]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,ABC,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,ABC,ABC]
|
[createElementNS http://www.w3.org/1999/xhtml,ABC,ABC]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,ABC,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,ABC,\xc3\xa4]
|
[createElementNS http://www.w3.org/1999/xhtml,ABC,\xc3\xa4]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -69,15 +51,9 @@
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,\xc3\xa4,Abc]
|
[createElementNS http://www.w3.org/1999/xhtml,\xc3\xa4,Abc]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,\xc3\xa4,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,\xc3\xa4,ABC]
|
[createElementNS http://www.w3.org/1999/xhtml,\xc3\xa4,ABC]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,\xc3\xa4,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,\xc3\xa4,\xc3\xa4]
|
[createElementNS http://www.w3.org/1999/xhtml,\xc3\xa4,\xc3\xa4]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -90,84 +66,12 @@
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,Abc]
|
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,Abc]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,\xc3\x84,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,ABC]
|
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,ABC]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/1999/xhtml,\xc3\x84,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,\xc3\xa4]
|
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,\xc3\xa4]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,\xc3\x84]
|
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,\xc3\x84]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,abc,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,abc,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,Abc,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,Abc,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,ABC,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,ABC,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,\xc3\xa4,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,\xc3\xa4,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,\xc3\x84,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://www.w3.org/2000/svg,\xc3\x84,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,abc,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,abc,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,Abc,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,Abc,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,ABC,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,ABC,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,\xc3\xa4,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,\xc3\xa4,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,\xc3\x84,Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS http://FOO,\xc3\x84,ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS Abc]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getAttributeNS ABC]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue