aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorfokinv <fokin.valentin@stud.u-szeged.hu>2016-10-07 10:42:23 +0200
committerzakorgyula <gyula.zakor@gmail.com>2016-11-04 15:36:47 +0100
commitbaa024e3621fc2e8767d594836fa46987779ccfc (patch)
tree93b1c8cfc48cdb878cb32a995741bc718b7b9bbf /components/script/dom
parent98f2233f2d232775150bdf0d5348efa167b10018 (diff)
downloadservo-baa024e3621fc2e8767d594836fa46987779ccfc.tar.gz
servo-baa024e3621fc2e8767d594836fa46987779ccfc.zip
Return with NotFoundError when the requested deviceName/deviceNamePrefix is longer than 29 bytes.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bluetooth.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs
index 144cf03a4be..e6eeb35cd2c 100644
--- a/components/script/dom/bluetooth.rs
+++ b/components/script/dom/bluetooth.rs
@@ -9,7 +9,7 @@ use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence};
use core::clone::Clone;
use dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothMethods, BluetoothRequestDeviceFilter};
use dom::bindings::codegen::Bindings::BluetoothBinding::RequestDeviceOptions;
-use dom::bindings::error::Error::{self, Security, Type};
+use dom::bindings::error::Error::{self, NotFound, Security, Type};
use dom::bindings::error::Fallible;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
@@ -25,7 +25,6 @@ use std::rc::Rc;
const FILTER_EMPTY_ERROR: &'static str = "'filters' member, if present, must be nonempty to find any devices.";
const FILTER_ERROR: &'static str = "A filter must restrict the devices in some way.";
-const FILTER_NAME_TOO_LONG_ERROR: &'static str = "A 'name' or 'namePrefix' can't be longer then 29 bytes.";
// 248 is the maximum number of UTF-8 code units in a Bluetooth Device Name.
const MAX_DEVICE_NAME_LENGTH: usize = 248;
// A device name can never be longer than 29 bytes.
@@ -213,7 +212,7 @@ fn canonicalize_filter(filter: &BluetoothRequestDeviceFilter) -> Fallible<Blueto
return Err(Type(NAME_TOO_LONG_ERROR.to_owned()));
}
if name.len() > MAX_FILTER_NAME_LENGTH {
- return Err(Type(FILTER_NAME_TOO_LONG_ERROR.to_owned()));
+ return Err(NotFound);
}
// Step 2.4.4.2.
@@ -233,7 +232,7 @@ fn canonicalize_filter(filter: &BluetoothRequestDeviceFilter) -> Fallible<Blueto
return Err(Type(NAME_TOO_LONG_ERROR.to_owned()));
}
if name_prefix.len() > MAX_FILTER_NAME_LENGTH {
- return Err(Type(FILTER_NAME_TOO_LONG_ERROR.to_owned()));
+ return Err(NotFound);
}
// Step 2.4.5.2.