Parse attributes according to the specification in AttrValue::from_u32.

This exposes another bug: "-0" failed to parse with str.parse(), and is now
successfully parsed into 0. However, input.size and textarea.{rows, cols} are
supposed to be "limited to only non-negative numbers greater than zero", so 0
is not actually supposed to be accepted.
This commit is contained in:
Ms2ger 2015-04-20 10:50:47 +02:00
parent 8b8daa24b8
commit dd9351d722
3 changed files with 11 additions and 93 deletions

View file

@ -16,7 +16,7 @@ use dom::window::Window;
use dom::virtualmethods::vtable_for;
use devtools_traits::AttrInfo;
use util::str::{DOMString, split_html_space_chars};
use util::str::{DOMString, parse_unsigned_integer, split_html_space_chars};
use string_cache::{Atom, Namespace};
@ -55,8 +55,7 @@ impl AttrValue {
}
pub fn from_u32(string: DOMString, default: u32) -> AttrValue {
// XXX Is parse() correct?
let result: u32 = string.parse().unwrap_or(default);
let result = parse_unsigned_integer(string.chars()).unwrap_or(default);
AttrValue::UInt(string, result)
}