Sanitize Bluetooth device names without regex

Saves a considerable amount of RAM.

Fixes: 145623858
Test: Pair with a simulated device with whitespace in the name
Change-Id: I1c8b00922534ee5941be6b14948c0941c5640862
This commit is contained in:
Dan Sandler
2019-12-03 18:32:14 -05:00
committed by Myles Watson
parent f1a0c3abea
commit 1add9f0bc2

View File

@@ -1025,7 +1025,11 @@ public final class BluetoothDevice implements Parcelable {
try {
String name = service.getRemoteName(this);
if (name != null) {
return name.replaceAll("[\\t\\n\\r]+", " ");
// remove whitespace characters from the name
return name
.replace('\t', ' ')
.replace('\n', ' ')
.replace('\r', ' ');
}
return null;
} catch (RemoteException e) {