aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/str.rs
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2014-06-08 12:22:31 -0400
committerbors-servo <release+servo@mozilla.com>2014-06-08 12:22:31 -0400
commit1f41eda3215cbb97499855ffb7a5170b488ba00a (patch)
treef16656fede30585d220fb7e156ab997079318c63 /src/components/script/dom/bindings/str.rs
parent743dcee0f59d63bfbb820df2412c8e2267b38f66 (diff)
parent86594a752c1f857df62b058b5d0e4a39fa05e6f3 (diff)
downloadservo-1f41eda3215cbb97499855ffb7a5170b488ba00a.tar.gz
servo-1f41eda3215cbb97499855ffb7a5170b488ba00a.zip
auto merge of #2613 : Manishearth/servo/xhr-wpt-methods, r=Ms2ger
For [XMLHttpRequest/open-method-case-sensitive.htm](https://github.com/w3c/web-platform-tests/blob/master/XMLHttpRequest/open-method-case-sensitive.htm), [XMLHttpRequest/XMLHttpRequest/open-method-insecure.htm](https://github.com/w3c/web-platform-tests/blob/master/XMLHttpRequest/open-method-insecure.htm), [XMLHttpRequest/XMLHttpRequest/open-method-responsetype-set-sync.htm ](https://github.com/w3c/web-platform-tests/blob/master/XMLHttpRequest/open-method-responsetype-set-sync.htm) in particular. `getResponseHeader()` is used by a lot of other tests (the harness echoes most of the metadata in the response headers, which is tested on this side) The sync changes fixes half of the timeouts to give meaningful results. Blocks #2525
Diffstat (limited to 'src/components/script/dom/bindings/str.rs')
-rw-r--r--src/components/script/dom/bindings/str.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/components/script/dom/bindings/str.rs b/src/components/script/dom/bindings/str.rs
index e7d84d21c07..ae6c721abea 100644
--- a/src/components/script/dom/bindings/str.rs
+++ b/src/components/script/dom/bindings/str.rs
@@ -2,7 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use std::from_str::FromStr;
use std::hash::{Hash, sip};
+use std::path::BytesContainer;
use std::str;
#[deriving(Encodable,Clone,TotalEq,Eq)]
@@ -45,6 +47,9 @@ impl ByteString {
pub fn is_token(&self) -> bool {
let ByteString(ref vec) = *self;
+ if vec.len() == 0 {
+ return false; // A token must be at least a single character
+ }
vec.iter().all(|&x| {
// http://tools.ietf.org/html/rfc2616#section-2.2
match x {
@@ -53,6 +58,7 @@ impl ByteString {
44 | 59 | 58 | 92 | 34 |
47 | 91 | 93 | 63 | 61 |
123 | 125 | 32 => false, // separators
+ x if x > 127 => false, // non-CHARs
_ => true
}
})
@@ -113,4 +119,10 @@ impl Hash for ByteString {
let ByteString(ref vec) = *self;
vec.hash(state);
}
+}
+
+impl FromStr for ByteString {
+ fn from_str(s: &str) -> Option<ByteString> {
+ Some(ByteString::new(s.container_into_owned_bytes()))
+ }
} \ No newline at end of file