Bug 1321534 - File::Constructor should normalize the filename, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 01 Dec 2016 15:14:45 +0100
changeset 325015 1857e763332c21cb50da642cf583b95379df275f
parent 325014 9ad9c6b4c8d632aa4db6e7e5efe42c7e9516fc99
child 325016 07b9aab24f30b7172e4b6553773c382200b32488
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerssmaug
bugs1321534
milestone53.0a1
Bug 1321534 - File::Constructor should normalize the filename, r=smaug
dom/file/File.cpp
testing/web-platform/meta/FileAPI/file/File-constructor.html.ini
--- a/dom/file/File.cpp
+++ b/dom/file/File.cpp
@@ -550,17 +550,21 @@ ParseSize(int64_t aSize, int64_t& aStart
 
 /* static */ already_AddRefed<File>
 File::Constructor(const GlobalObject& aGlobal,
                   const Sequence<BlobPart>& aData,
                   const nsAString& aName,
                   const FilePropertyBag& aBag,
                   ErrorResult& aRv)
 {
-  RefPtr<MultipartBlobImpl> impl = new MultipartBlobImpl(aName);
+  // Normalizing the filename
+  nsString name(aName);
+  name.ReplaceChar('/', ':');
+
+  RefPtr<MultipartBlobImpl> impl = new MultipartBlobImpl(name);
 
   nsAutoString type(aBag.mType);
   MakeValidBlobType(type);
   impl->InitializeBlob(aGlobal.Context(), aData, type, false, aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
   MOZ_ASSERT(impl->IsFile());
deleted file mode 100644
--- a/testing/web-platform/meta/FileAPI/file/File-constructor.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[File-constructor.html]
-  type: testharness
-  [Using special character in fileName]
-    expected: FAIL