mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Modify Headers API to correctly validate value.
This commit modifies the headers API script to correctly validate value. As a result of this change, more wpt tests pass. The commit also changes the expected test results.
This commit is contained in:
parent
fabe2b8f7e
commit
69f4cf6808
6 changed files with 14 additions and 42 deletions
|
@ -80,8 +80,11 @@ impl HeadersMethods for Headers {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
// Step 7
|
// Step 7
|
||||||
let mut combined_value = self.header_list.borrow_mut().get_raw(&valid_name).unwrap()[0].clone();
|
let mut combined_value: Vec<u8> = vec![];
|
||||||
combined_value.push(b","[0]);
|
if let Some(v) = self.header_list.borrow().get_raw(&valid_name) {
|
||||||
|
combined_value = v[0].clone();
|
||||||
|
combined_value.push(b","[0]);
|
||||||
|
}
|
||||||
combined_value.extend(valid_value.iter().cloned());
|
combined_value.extend(valid_value.iter().cloned());
|
||||||
self.header_list.borrow_mut().set_raw(valid_name, vec![combined_value]);
|
self.header_list.borrow_mut().set_raw(valid_name, vec![combined_value]);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -165,8 +168,6 @@ impl Headers {
|
||||||
match filler {
|
match filler {
|
||||||
// Step 1
|
// Step 1
|
||||||
Some(HeadersOrByteStringSequenceSequence::Headers(h)) => {
|
Some(HeadersOrByteStringSequenceSequence::Headers(h)) => {
|
||||||
// header_list_copy has type hyper::header::Headers
|
|
||||||
let header_list_copy = h.header_list.clone();
|
|
||||||
for header in h.header_list.borrow().iter() {
|
for header in h.header_list.borrow().iter() {
|
||||||
try!(self.Append(
|
try!(self.Append(
|
||||||
ByteString::new(Vec::from(header.name())),
|
ByteString::new(Vec::from(header.name())),
|
||||||
|
@ -346,20 +347,24 @@ fn is_field_name(name: &ByteString) -> bool {
|
||||||
// field-content = field-vchar [ 1*( SP / HTAB / field-vchar )
|
// field-content = field-vchar [ 1*( SP / HTAB / field-vchar )
|
||||||
// field-vchar ]
|
// field-vchar ]
|
||||||
fn is_field_content(value: &ByteString) -> bool {
|
fn is_field_content(value: &ByteString) -> bool {
|
||||||
if value.len() == 0 {
|
let value_len = value.len();
|
||||||
|
|
||||||
|
if value_len == 0 {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if !is_field_vchar(value[0]) {
|
if !is_field_vchar(value[0]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for &ch in &value[1..value.len() - 1] {
|
if value_len > 2 {
|
||||||
if !is_field_vchar(ch) || !is_space(ch) || !is_htab(ch) {
|
for &ch in &value[1..value_len - 1] {
|
||||||
return false;
|
if !is_field_vchar(ch) && !is_space(ch) && !is_htab(ch) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !is_field_vchar(value[value.len() - 1]) {
|
if !is_field_vchar(value[value_len - 1]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,21 +3,12 @@
|
||||||
[Create headers from empty object]
|
[Create headers from empty object]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Create headers with sequence]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Create headers with OpenEndedDictionary]
|
[Create headers with OpenEndedDictionary]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Create headers with existing headers]
|
[Create headers with existing headers]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Check append method]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Check set method]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Check has method]
|
[Check has method]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,3 @@
|
||||||
[Create headers, names use characters with different case]
|
[Create headers, names use characters with different case]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Check append method, names use characters with different case]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Check set method, names use characters with different case]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Check delete method, names use characters with different case]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,6 @@
|
||||||
[Create headers using same name for different values]
|
[Create headers using same name for different values]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Check delete and has methods when using same name for different values]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Check set methods when called with already used name]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Check append methods when called with already used name]
|
[Check append methods when called with already used name]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
[headers-errors.html]
|
[headers-errors.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[Headers forEach throws if argument is not callable]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Headers forEach loop should stop if callback is throwing exception]
|
[Headers forEach loop should stop if callback is throwing exception]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,3 @@
|
||||||
[Create headers with not normalized values]
|
[Create headers with not normalized values]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Check append method whith not normalized values]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Check set method whith not normalized values]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue