summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Savage-Jones <edward.savage-jones@sonyericsson.com>2010-09-28 14:39:44 +0200
committerJohan Redestig <johan.redestig@sonyericsson.com>2010-12-22 14:16:38 +0100
commit5e9a02df66c6044bd4a06b9d53e6cdbd8ad22606 (patch)
treec24bfbd1a33923773251eff8b7087830030499ca
parente7f887dab2591a46ecf80616e00f33bb5d847935 (diff)
downloadandroid_packages_apps_Bluetooth-5e9a02df66c6044bd4a06b9d53e6cdbd8ad22606.tar.gz
android_packages_apps_Bluetooth-5e9a02df66c6044bd4a06b9d53e6cdbd8ad22606.tar.bz2
android_packages_apps_Bluetooth-5e9a02df66c6044bd4a06b9d53e6cdbd8ad22606.zip
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
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java b/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java
index b5ac2742d..913e28c17 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java
@@ -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) {