diff options
author | fokinv <fokinv@inf.u-szeged.hu> | 2016-05-20 13:19:58 +0200 |
---|---|---|
committer | Attila Dusnoki <dati91@gmail.com> | 2016-05-31 17:05:45 +0200 |
commit | a920e6d54e4e75e06ac8ac5029f9aa69fdf31ae8 (patch) | |
tree | 473b5d5892ace996d2afccdcbc7fbfe61f7ef13a /components/script/dom/bluetooth.rs | |
parent | b11648903bb07a31ec93f3030058ed41b3472b17 (diff) | |
download | servo-a920e6d54e4e75e06ac8ac5029f9aa69fdf31ae8.tar.gz servo-a920e6d54e4e75e06ac8ac5029f9aa69fdf31ae8.zip |
Add WebBluetooth Blacklist support
Diffstat (limited to 'components/script/dom/bluetooth.rs')
-rw-r--r-- | components/script/dom/bluetooth.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index 9617dad4485..e00fb33cf59 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -2,11 +2,12 @@ * 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 bluetooth_blacklist::{Blacklist, uuid_is_blacklisted}; use core::clone::Clone; use dom::bindings::codegen::Bindings::BluetoothBinding; use dom::bindings::codegen::Bindings::BluetoothBinding::RequestDeviceOptions; use dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothScanFilter, BluetoothMethods}; -use dom::bindings::error::Error::Type; +use dom::bindings::error::Error::{Security, Type}; use dom::bindings::error::Fallible; use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; @@ -71,7 +72,11 @@ fn canonicalize_filter(filter: &BluetoothScanFilter, global: GlobalRef) -> Falli return Err(Type(SERVICE_ERROR.to_owned())); } for service in services { - services_vec.push(try!(BluetoothUUID::GetService(global, service.clone())).to_string()); + let uuid = try!(BluetoothUUID::GetService(global, service.clone())).to_string(); + if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { + return Err(Security) + } + services_vec.push(uuid); } } @@ -119,7 +124,11 @@ fn convert_request_device_options(options: &RequestDeviceOptions, let mut optional_services = vec!(); if let Some(ref opt_services) = options.optionalServices { for opt_service in opt_services { - optional_services.push(try!(BluetoothUUID::GetService(global, opt_service.clone())).to_string()); + let uuid = try!(BluetoothUUID::GetService(global, opt_service.clone())).to_string(); + if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { + return Err(Security) + } + optional_services.push(uuid); } } |