diff --git a/dom/bluetooth/BluetoothOppManager.cpp b/dom/bluetooth/BluetoothOppManager.cpp index f68dac9c0774..e54296cf7417 100644 --- a/dom/bluetooth/BluetoothOppManager.cpp +++ b/dom/bluetooth/BluetoothOppManager.cpp @@ -621,6 +621,28 @@ BluetoothOppManager::ExtractBlobHeaders() return true; } +bool +BluetoothOppManager::IsReservedChar(PRUnichar c) +{ + return (c < 0x0020 || + c == PRUnichar('?') || c == PRUnichar('|') || c == PRUnichar('<') || + c == PRUnichar('>') || c == PRUnichar('"') || c == PRUnichar(':') || + c == PRUnichar('/') || c == PRUnichar('*') || c == PRUnichar('\\')); +} + +void +BluetoothOppManager::ValidateFileName() +{ + int length = sFileName.Length(); + + for (int i = 0; i < length; ++i) { + // Replace reserved char of fat file system with '_' + if (IsReservedChar(sFileName.CharAt(i))) { + sFileName.Replace(i, 1, PRUnichar('_')); + } + } +} + void BluetoothOppManager::ServerDataHandler(UnixSocketRawData* aMessage) { @@ -707,6 +729,7 @@ BluetoothOppManager::ServerDataHandler(UnixSocketRawData* aMessage) mReceivedDataBufferOffset, &pktHeaders); ExtractPacketHeaders(pktHeaders); + ValidateFileName(); mReceivedDataBufferOffset = 0; diff --git a/dom/bluetooth/BluetoothOppManager.h b/dom/bluetooth/BluetoothOppManager.h index 2654009059fd..b22c39287e5d 100644 --- a/dom/bluetooth/BluetoothOppManager.h +++ b/dom/bluetooth/BluetoothOppManager.h @@ -87,6 +87,9 @@ private: void AfterOppConnected(); void AfterFirstPut(); void AfterOppDisconnected(); + void ValidateFileName(); + bool IsReservedChar(PRUnichar c); + virtual void OnConnectSuccess() MOZ_OVERRIDE; virtual void OnConnectError() MOZ_OVERRIDE; virtual void OnDisconnect() MOZ_OVERRIDE;