Title: [211502] trunk
Revision
211502
Author
bfulg...@apple.com
Date
2017-02-01 12:00:18 -0800 (Wed, 01 Feb 2017)

Log Message

Correct "filesHaveSameVolume" predicate
https://bugs.webkit.org/show_bug.cgi?id=167696
<rdar://problem/30298722>

Reviewed by David Kilzer.

Source/WebCore:

We are passing %-encoded strings to the underlying operating system's file system APIs.
This doesn't work. Instead, we need to present a decoded version of the file path
that matches what the system APIs expect.

Tested by new TestWebKitAPI Test.

* platform/FileSystem.cpp:
(WebCore::filesHaveSameVolume): Make sure the file paths we give to the underlying
operating system are not percent encoded.
* platform/FileSystem.h: Export 'filesHaveSameVolume' for use by testing system.

Tools:

Add new tests that confirm that the 'filesHaveSamePath' predicate properly handles
percent-escaped path inputs.

* TestWebKitAPI/Tests/WebCore/FileSystem.cpp:
(TestWebKitAPI::FileSystemTest::spaceContainingFilePath):
(TestWebKitAPI::FileSystemTest::bangContainingFilePath):
(TestWebKitAPI::FileSystemTest::quoteContainingFilePath):
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211501 => 211502)


--- trunk/Source/WebCore/ChangeLog	2017-02-01 19:54:25 UTC (rev 211501)
+++ trunk/Source/WebCore/ChangeLog	2017-02-01 20:00:18 UTC (rev 211502)
@@ -1,3 +1,22 @@
+2017-02-01  Brent Fulgham  <bfulg...@apple.com>
+
+        Correct "filesHaveSameVolume" predicate
+        https://bugs.webkit.org/show_bug.cgi?id=167696
+        <rdar://problem/30298722>
+
+        Reviewed by David Kilzer.
+
+        We are passing %-encoded strings to the underlying operating system's file system APIs.
+        This doesn't work. Instead, we need to present a decoded version of the file path
+        that matches what the system APIs expect.
+
+        Tested by new TestWebKitAPI Test.
+
+        * platform/FileSystem.cpp:
+        (WebCore::filesHaveSameVolume): Make sure the file paths we give to the underlying
+        operating system are not percent encoded.
+        * platform/FileSystem.h: Export 'filesHaveSameVolume' for use by testing system.
+
 2017-02-01  Antoine Quint  <grao...@apple.com>
 
         [mac-wk1] LayoutTest media/modern-media-controls/tracks-support/tracks-support-click-track-in-panel.html is a flaky timeout

Modified: trunk/Source/WebCore/platform/FileSystem.cpp (211501 => 211502)


--- trunk/Source/WebCore/platform/FileSystem.cpp	2017-02-01 19:54:25 UTC (rev 211501)
+++ trunk/Source/WebCore/platform/FileSystem.cpp	2017-02-01 20:00:18 UTC (rev 211502)
@@ -28,6 +28,7 @@
 #include "FileSystem.h"
 
 #include "ScopeGuard.h"
+#include "URL.h"
 #include <wtf/HexNumber.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
@@ -236,8 +237,8 @@
     
 bool filesHaveSameVolume(const String& fileA, const String& fileB)
 {
-    auto fsRepFileA = fileSystemRepresentation(fileA);
-    auto fsRepFileB = fileSystemRepresentation(fileB);
+    auto fsRepFileA = fileSystemRepresentation(decodeURLEscapeSequences(fileA));
+    auto fsRepFileB = fileSystemRepresentation(decodeURLEscapeSequences(fileB));
     
     if (fsRepFileA.isNull() || fsRepFileB.isNull())
         return false;

Modified: trunk/Source/WebCore/platform/FileSystem.h (211501 => 211502)


--- trunk/Source/WebCore/platform/FileSystem.h	2017-02-01 19:54:25 UTC (rev 211501)
+++ trunk/Source/WebCore/platform/FileSystem.h	2017-02-01 20:00:18 UTC (rev 211502)
@@ -194,7 +194,7 @@
 WEBCORE_EXPORT String encodeForFileName(const String&);
 String decodeFromFilename(const String&);
 
-bool filesHaveSameVolume(const String&, const String&);
+WEBCORE_EXPORT bool filesHaveSameVolume(const String&, const String&);
 
 #if USE(CF)
 RetainPtr<CFURLRef> pathAsURL(const String&);

Modified: trunk/Tools/ChangeLog (211501 => 211502)


--- trunk/Tools/ChangeLog	2017-02-01 19:54:25 UTC (rev 211501)
+++ trunk/Tools/ChangeLog	2017-02-01 20:00:18 UTC (rev 211502)
@@ -1,3 +1,20 @@
+2017-02-01  Brent Fulgham  <bfulg...@apple.com>
+
+        Correct "filesHaveSameVolume" predicate
+        https://bugs.webkit.org/show_bug.cgi?id=167696
+        <rdar://problem/30298722>
+
+        Reviewed by David Kilzer.
+
+        Add new tests that confirm that the 'filesHaveSamePath' predicate properly handles
+        percent-escaped path inputs.
+
+        * TestWebKitAPI/Tests/WebCore/FileSystem.cpp:
+        (TestWebKitAPI::FileSystemTest::spaceContainingFilePath):
+        (TestWebKitAPI::FileSystemTest::bangContainingFilePath):
+        (TestWebKitAPI::FileSystemTest::quoteContainingFilePath):
+        (TestWebKitAPI::TEST_F):
+
 2017-02-01  Tomas Popela  <tpop...@redhat.com>
 
         Unreviewed. Fix coding style in MiniBrowser

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/FileSystem.cpp (211501 => 211502)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/FileSystem.cpp	2017-02-01 19:54:25 UTC (rev 211501)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/FileSystem.cpp	2017-02-01 20:00:18 UTC (rev 211502)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2015 Canon Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,6 +28,7 @@
 
 #include "Test.h"
 #include <WebCore/FileSystem.h>
+#include <WebCore/URL.h>
 #include <wtf/MainThread.h>
 #include <wtf/StringExtras.h>
 
@@ -50,21 +52,39 @@
         closeFile(handle); 
 
         m_tempEmptyFilePath = openTemporaryFile("tempEmptyTestFile", handle);
-        closeFile(handle); 
-    }
+        closeFile(handle);
 
+        m_spaceContainingFilePath = encodeWithURLEscapeSequences(openTemporaryFile("temp Empty Test File", handle));
+        closeFile(handle);
+
+        m_bangContainingFilePath = encodeWithURLEscapeSequences(openTemporaryFile("temp!Empty!Test!File", handle));
+        closeFile(handle);
+
+        m_quoteContainingFilePath = encodeWithURLEscapeSequences(openTemporaryFile("temp\"Empty\"TestFile", handle));
+        closeFile(handle);
+}
+
     void TearDown() override
     {
         deleteFile(m_tempFilePath);
         deleteFile(m_tempEmptyFilePath);
+        deleteFile(m_spaceContainingFilePath);
+        deleteFile(m_bangContainingFilePath);
+        deleteFile(m_quoteContainingFilePath);
     }
 
     const String& tempFilePath() { return m_tempFilePath; }
     const String& tempEmptyFilePath() { return m_tempEmptyFilePath; }
+    const String& spaceContainingFilePath() { return m_spaceContainingFilePath; }
+    const String& bangContainingFilePath() { return m_bangContainingFilePath; }
+    const String& quoteContainingFilePath() { return m_quoteContainingFilePath; }
 
 private:
     String m_tempFilePath;
     String m_tempEmptyFilePath;
+    String m_spaceContainingFilePath;
+    String m_bangContainingFilePath;
+    String m_quoteContainingFilePath;
 };
 
 TEST_F(FileSystemTest, MappingMissingFile)
@@ -93,4 +113,11 @@
     EXPECT_TRUE(!mappedFileData);
 }
 
+TEST_F(FileSystemTest, FilesHaveSameVolume)
+{
+    EXPECT_TRUE(filesHaveSameVolume(tempFilePath(), spaceContainingFilePath()));
+    EXPECT_TRUE(filesHaveSameVolume(spaceContainingFilePath(), bangContainingFilePath()));
+    EXPECT_TRUE(filesHaveSameVolume(bangContainingFilePath(), quoteContainingFilePath()));
 }
+
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to