Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1add9f0b authored by Dan Sandler's avatar Dan Sandler Committed by Myles Watson
Browse files

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
parent f1a0c3ab
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -1025,7 +1025,11 @@ public final class BluetoothDevice implements Parcelable {
        try {
        try {
            String name = service.getRemoteName(this);
            String name = service.getRemoteName(this);
            if (name != null) {
            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;
            return null;
        } catch (RemoteException e) {
        } catch (RemoteException e) {