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

Commit 5e9a02df authored by Edward Savage-Jones's avatar Edward Savage-Jones Committed by Johan Redestig
Browse files

Sanitise Bluetooth file name hint when receiving a contact

If a contact name is entered with any of the following characters

  :"<>*?|\n\t

the transfer of that contact fails.  This is due to the underlying
filesystem (FAT) not being able to handle these characters in a
file name.  This fix corrects that situation by replacing any
whitespace characters with a space and illegal FAT filesystem
characters with underscore.

Change-Id: I5021bd26a16c31810a61bac3f70439c1153451c2
parent e7f887da
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -244,6 +244,11 @@ public class BluetoothOppReceiveFileInfo {
            // Prevent abuse of path backslashes by converting all backlashes '\\' chars
            // to UNIX-style forward-slashes '/'
            hint = hint.replace('\\', '/');
            // Convert all whitespace characters to spaces.
            hint = hint.replaceAll("\\s", " ");
            // Replace illegal fat filesystem characters from the
            // filename hint i.e. :"<>*?| with something safe.
            hint = hint.replaceAll("[:\"<>*?|]", "_");
            if (V) Log.v(Constants.TAG, "getting filename from hint");
            int index = hint.lastIndexOf('/') + 1;
            if (index > 0) {