Skip to content

Commit

Permalink
Remove the 29 byte length restriction, when requesting bluetooth devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakor Gyula authored and dati91 committed Feb 3, 2017
1 parent da89099 commit b52f9e4
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 98 deletions.
13 changes: 1 addition & 12 deletions components/script/dom/bluetooth.rs
Expand Up @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothDataFilt
use dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothMethods, RequestDeviceOptions};
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
use dom::bindings::error::Error::{self, Network, NotFound, Security, Type};
use dom::bindings::error::Error::{self, Network, Security, Type};
use dom::bindings::error::Fallible;
use dom::bindings::js::{JS, Root};
use dom::bindings::refcounted::{Trusted, TrustedPromise};
Expand All @@ -40,11 +40,6 @@ const MANUFACTURER_DATA_ERROR: &'static str = "'manufacturerData', if present, m
const MASK_LENGTH_ERROR: &'static str = "`mask`, if present, must have the same length as `dataPrefix`.";
// 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.
// An advertising packet is at most 31 bytes long.
// The length and identifier of the length field take 2 bytes.
// That leaves 29 bytes for the name.
const MAX_FILTER_NAME_LENGTH: usize = 29;
const NAME_PREFIX_ERROR: &'static str = "'namePrefix', if present, must be nonempty.";
const NAME_TOO_LONG_ERROR: &'static str = "A device name can't be longer than 248 bytes.";
const SERVICE_DATA_ERROR: &'static str = "'serviceData', if present, must be non-empty to filter devices.";
Expand Down Expand Up @@ -311,9 +306,6 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
if name.len() > MAX_DEVICE_NAME_LENGTH {
return Err(Type(NAME_TOO_LONG_ERROR.to_owned()));
}
if name.len() > MAX_FILTER_NAME_LENGTH {
return Err(NotFound);
}

// Step 4.2.
Some(name.to_string())
Expand All @@ -331,9 +323,6 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
if name_prefix.len() > MAX_DEVICE_NAME_LENGTH {
return Err(Type(NAME_TOO_LONG_ERROR.to_owned()));
}
if name_prefix.len() > MAX_FILTER_NAME_LENGTH {
return Err(NotFound);
}

// Step 5.2.
name_prefix.to_string()
Expand Down
24 changes: 0 additions & 24 deletions tests/wpt/mozilla/meta/MANIFEST.json
Expand Up @@ -7766,18 +7766,6 @@
"url": "/_mozilla/mozilla/bluetooth/requestDevice/canonicalizeFilter/max-length-for-device-name-namePrefix.html"
}
],
"mozilla/bluetooth/requestDevice/canonicalizeFilter/max-length-for-name-in-adv-name.html": [
{
"path": "mozilla/bluetooth/requestDevice/canonicalizeFilter/max-length-for-name-in-adv-name.html",
"url": "/_mozilla/mozilla/bluetooth/requestDevice/canonicalizeFilter/max-length-for-name-in-adv-name.html"
}
],
"mozilla/bluetooth/requestDevice/canonicalizeFilter/max-length-for-name-in-adv-namePrefix.html": [
{
"path": "mozilla/bluetooth/requestDevice/canonicalizeFilter/max-length-for-name-in-adv-namePrefix.html",
"url": "/_mozilla/mozilla/bluetooth/requestDevice/canonicalizeFilter/max-length-for-name-in-adv-namePrefix.html"
}
],
"mozilla/bluetooth/requestDevice/canonicalizeFilter/no-arguments.html": [
{
"path": "mozilla/bluetooth/requestDevice/canonicalizeFilter/no-arguments.html",
Expand All @@ -7802,18 +7790,6 @@
"url": "/_mozilla/mozilla/bluetooth/requestDevice/canonicalizeFilter/unicode-max-length-for-device-name-namePrefix.html"
}
],
"mozilla/bluetooth/requestDevice/canonicalizeFilter/unicode-max-length-for-name-in-adv-name.html": [
{
"path": "mozilla/bluetooth/requestDevice/canonicalizeFilter/unicode-max-length-for-name-in-adv-name.html",
"url": "/_mozilla/mozilla/bluetooth/requestDevice/canonicalizeFilter/unicode-max-length-for-name-in-adv-name.html"
}
],
"mozilla/bluetooth/requestDevice/canonicalizeFilter/unicode-max-length-for-name-in-adv-namePrefix.html": [
{
"path": "mozilla/bluetooth/requestDevice/canonicalizeFilter/unicode-max-length-for-name-in-adv-namePrefix.html",
"url": "/_mozilla/mozilla/bluetooth/requestDevice/canonicalizeFilter/unicode-max-length-for-name-in-adv-namePrefix.html"
}
],
"mozilla/bluetooth/requestDevice/canonicalizeFilter/unicode-valid-length-name-name.html": [
{
"path": "mozilla/bluetooth/requestDevice/canonicalizeFilter/unicode-valid-length-name-name.html",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit b52f9e4

Please sign in to comment.