Bug 1321534 - File::Constructor should normalize the filename, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 01 Dec 2016 15:14:45 +0100
changeset 446597 1857e763332c21cb50da642cf583b95379df275f
parent 446596 9ad9c6b4c8d632aa4db6e7e5efe42c7e9516fc99
child 446598 5e62704ca1a6c1af44e35e0b05d0b2916dbd25c5
child 446599 5236ca9ae120d46c35b77784c0e8d431d4136a03
child 446600 f7f2dde16a04012a998c4c163594eedf14569160
child 446602 07b9aab24f30b7172e4b6553773c382200b32488
child 447430 0c6e2a5d9dc5b9ef089b741305cf95c57ef0b9bc
push id37820
push userbmo:afarre@mozilla.com
push dateThu, 01 Dec 2016 15:12:21 +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