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:
committed by
Myles Watson
parent
f1a0c3abea
commit
1add9f0bc2
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user