[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

kinuko at chromium.org kinuko at chromium.org
Wed Dec 22 14:25:23 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit cd7e964d8edfffc9916b691fde93e9fce8352371
Author: kinuko at chromium.org <kinuko at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 8 08:38:45 2010 +0000

    2010-10-08  Kinuko Yasuda  <kinuko at chromium.org>
    
            Reviewed by David Levin.
    
            Fix FileSystem path validation order to normalize '..' and '.' before restriction checks
            https://bugs.webkit.org/show_bug.cgi?id=47309
    
            Test: fast/filesystem/op-get-entry.html
    
            * fileapi/DOMFileSystemBase.cpp:
            (WebCore::DOMFileSystemBase::getFile): Fixed the path validation order.
            (WebCore::DOMFileSystemBase::getDirectory): Fixed the path validation order.
    2010-10-08  Kinuko Yasuda  <kinuko at chromium.org>
    
            Reviewed by David Levin.
    
            Fix FileSystem path validation order to normalize '..' and '.' before restriction checks
            https://bugs.webkit.org/show_bug.cgi?id=47309
    
            * fast/filesystem/op-get-entry-expected.txt: Updated.
            * fast/filesystem/resources/op-get-entry.js: Updated.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69382 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 061c75b..819e03d 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-08  Kinuko Yasuda  <kinuko at chromium.org>
+
+        Reviewed by David Levin.
+
+        Fix FileSystem path validation order to normalize '..' and '.' before restriction checks
+        https://bugs.webkit.org/show_bug.cgi?id=47309
+
+        * fast/filesystem/op-get-entry-expected.txt: Updated.
+        * fast/filesystem/resources/op-get-entry.js: Updated.
+
 2010-10-07  Martin Robinson  <mrobinson at igalia.com>
 
         Rebaseline failing GTK+ tests.
diff --git a/LayoutTests/fast/filesystem/op-get-entry-expected.txt b/LayoutTests/fast/filesystem/op-get-entry-expected.txt
index 91d564e..8779318 100644
--- a/LayoutTests/fast/filesystem/op-get-entry-expected.txt
+++ b/LayoutTests/fast/filesystem/op-get-entry-expected.txt
@@ -19,9 +19,39 @@ PASS Succeeded: "/dummy".getFile("/a/b/c/d/e")
 PASS Verified entry: ENTRY {path:/dummy name:dummy type:DIRECTORY}
 PASS Verified entry: ENTRY {path:/a/b/c/d/e name:e type:FILE}
 * Running: CreateNestedWithRelativePath
+PASS Succeeded: "/a".getDirectory("./b")
+PASS Succeeded: "/a".getDirectory("../b")
+PASS Succeeded: "/a".getDirectory("../../b/c")
+PASS Succeeded: "/a".getDirectory("/a/../../d")
+PASS Succeeded: "/a".getDirectory("/a/../../b/./c/../../../../../e")
 PASS this.expectedErrorCode + "" is "13"
 PASS this.expectedErrorCode + "" is "13"
+PASS Succeeded: "/a".getFile("./b.txt")
+PASS Succeeded: "/a".getFile("../b.txt")
+PASS Succeeded: "/a".getFile("../../b/c.txt")
+PASS Succeeded: "/a".getFile("/a/../../d.txt")
+PASS Succeeded: "/a".getFile("/a/../../b/./c/../../../../../e.txt")
 PASS this.expectedErrorCode + "" is "13"
+PASS this.expectedErrorCode + "" is "13"
+PASS Verified entry: ENTRY {path:/a name:a type:DIRECTORY}
+PASS Verified entry: ENTRY {path:/a/b name:b type:DIRECTORY}
+PASS Verified entry: ENTRY {path:/b name:b type:DIRECTORY}
+PASS Verified entry: ENTRY {path:/b/c name:c type:DIRECTORY}
+PASS Verified entry: ENTRY {path:/d name:d type:DIRECTORY}
+PASS Verified entry: ENTRY {path:/e name:e type:DIRECTORY}
+PASS Verified entry does NOT exist: /f
+PASS Verified entry does NOT exist: /a/f
+PASS Verified entry does NOT exist: /g
+PASS Verified entry does NOT exist: /a/g
+PASS Verified entry: ENTRY {path:/a/b.txt name:b.txt type:FILE}
+PASS Verified entry: ENTRY {path:/b.txt name:b.txt type:FILE}
+PASS Verified entry: ENTRY {path:/b/c.txt name:c.txt type:FILE}
+PASS Verified entry: ENTRY {path:/d.txt name:d.txt type:FILE}
+PASS Verified entry: ENTRY {path:/e.txt name:e.txt type:FILE}
+PASS Verified entry does NOT exist: /f.txt
+PASS Verified entry does NOT exist: /a/f.txt
+PASS Verified entry does NOT exist: /g.txt
+PASS Verified entry does NOT exist: /a/g.txt
 * Running: GetExistingEntry
 PASS Succeeded: "/".getDirectory("a")
 PASS Succeeded: "/".getFile("b")
diff --git a/LayoutTests/fast/filesystem/resources/op-get-entry.js b/LayoutTests/fast/filesystem/resources/op-get-entry.js
index 5551a37..c0d94a9 100644
--- a/LayoutTests/fast/filesystem/resources/op-get-entry.js
+++ b/LayoutTests/fast/filesystem/resources/op-get-entry.js
@@ -48,12 +48,42 @@ var testCases = [
             {fullPath:'/a', isDirectory:true},
         ],
         tests: [
-            // FIXME: For now they throw an error because they fail the check for restricted-names: 'a path component should not end with period'.
-            function(helper) { helper.getDirectory('/a', './b', {create:true}, FileError.INVALID_MODIFICATION_ERR); },
-            function(helper) { helper.getDirectory('/a', '../b', {create:true}, FileError.INVALID_MODIFICATION_ERR); },
-            function(helper) { helper.getDirectory('/a', '/a/../../b', {create:true}, FileError.INVALID_MODIFICATION_ERR); },
+            function(helper) { helper.getDirectory('/a', './b', {create:true}); },
+            function(helper) { helper.getDirectory('/a', '../b', {create:true}); },
+            function(helper) { helper.getDirectory('/a', '../../b/c', {create:true}); },
+            function(helper) { helper.getDirectory('/a', '/a/../../d', {create:true}); },
+            function(helper) { helper.getDirectory('/a', '/a/../../b/./c/../../../../../e', {create:true}); },
+            function(helper) { helper.getDirectory('/a', '.../f', {create:true}, FileError.INVALID_MODIFICATION_ERR); },
+            function(helper) { helper.getDirectory('/a', '/a/../.../g', {create:true}, FileError.INVALID_MODIFICATION_ERR); },
+            function(helper) { helper.getFile('/a', './b.txt', {create:true}); },
+            function(helper) { helper.getFile('/a', '../b.txt', {create:true}); },
+            function(helper) { helper.getFile('/a', '../../b/c.txt', {create:true}); },
+            function(helper) { helper.getFile('/a', '/a/../../d.txt', {create:true}); },
+            function(helper) { helper.getFile('/a', '/a/../../b/./c/../../../../../e.txt', {create:true}); },
+            function(helper) { helper.getFile('/a', '.../f.txt', {create:true}, FileError.INVALID_MODIFICATION_ERR); },
+            function(helper) { helper.getFile('/a', '/a/../.../g.txt', {create:true}, FileError.INVALID_MODIFICATION_ERR); },
+        ],
+        postcondition: [
+            {fullPath:'/a', isDirectory:true},
+            {fullPath:'/a/b', isDirectory:true},
+            {fullPath:'/b', isDirectory:true},
+            {fullPath:'/b/c', isDirectory:true},
+            {fullPath:'/d', isDirectory:true},
+            {fullPath:'/e', isDirectory:true},
+            {fullPath:'/f', nonexistent:true},
+            {fullPath:'/a/f', nonexistent:true},
+            {fullPath:'/g', nonexistent:true},
+            {fullPath:'/a/g', nonexistent:true},
+            {fullPath:'/a/b.txt'},
+            {fullPath:'/b.txt'},
+            {fullPath:'/b/c.txt'},
+            {fullPath:'/d.txt'},
+            {fullPath:'/e.txt'},
+            {fullPath:'/f.txt', nonexistent:true},
+            {fullPath:'/a/f.txt', nonexistent:true},
+            {fullPath:'/g.txt', nonexistent:true},
+            {fullPath:'/a/g.txt', nonexistent:true},
         ],
-        postcondition: [ ],
     },
     {
         name: 'GetExistingEntry',
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0783b13..05b1705 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,16 @@
+2010-10-08  Kinuko Yasuda  <kinuko at chromium.org>
+
+        Reviewed by David Levin.
+
+        Fix FileSystem path validation order to normalize '..' and '.' before restriction checks
+        https://bugs.webkit.org/show_bug.cgi?id=47309
+
+        Test: fast/filesystem/op-get-entry.html
+
+        * fileapi/DOMFileSystemBase.cpp:
+        (WebCore::DOMFileSystemBase::getFile): Fixed the path validation order.
+        (WebCore::DOMFileSystemBase::getDirectory): Fixed the path validation order.
+
 2010-10-08  Carlos Garcia Campos  <cgarcia at igalia.com>
 
         Reviewed by Xan Lopez.
diff --git a/WebCore/fileapi/DOMFileSystemBase.cpp b/WebCore/fileapi/DOMFileSystemBase.cpp
index 63c6e5b..d4dd7a5 100644
--- a/WebCore/fileapi/DOMFileSystemBase.cpp
+++ b/WebCore/fileapi/DOMFileSystemBase.cpp
@@ -65,7 +65,7 @@ bool DOMFileSystemBase::getMetadata(const EntryBase* entry, PassRefPtr<MetadataC
     return true;
 }
 
-static bool checkValidityForForCopyOrMove(const EntryBase* source, EntryBase* parent, const String& newName)
+static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source, EntryBase* parent, const String& newName, String& destinationPath)
 {
     ASSERT(source);
 
@@ -83,19 +83,33 @@ static bool checkValidityForForCopyOrMove(const EntryBase* source, EntryBase* pa
     if ((newName.isEmpty() || source->name() == newName) && DOMFilePath::getDirectory(source->fullPath()) == parent->fullPath())
         return false;
 
+    destinationPath = parent->fullPath();
+    if (!newName.isEmpty())
+        destinationPath = DOMFilePath::append(destinationPath, newName);
+    else
+        destinationPath = DOMFilePath::append(destinationPath, source->name());
+
     return true;
 }
 
-bool DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
+static bool pathToAbsolutePath(const EntryBase* base, String path, String& absolutePath)
 {
-    if (!checkValidityForForCopyOrMove(source, parent, newName))
+    ASSERT(base);
+
+    if (!DOMFilePath::isAbsolute(path))
+        path = DOMFilePath::append(base->fullPath(), path);
+    absolutePath = DOMFilePath::removeExtraParentReferences(path);
+
+    if (!DOMFilePath::isValidPath(absolutePath))
         return false;
+    return true;
+}
 
-    String destinationPath = parent->fullPath();
-    if (!newName.isEmpty())
-        destinationPath = DOMFilePath::append(destinationPath, newName);
-    else
-        destinationPath = DOMFilePath::append(destinationPath, source->name());
+bool DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
+{
+    String destinationPath;
+    if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, destinationPath))
+        return false;
 
     String sourcePlatformPath = m_asyncFileSystem->virtualToPlatformPath(source->fullPath());
     String destinationPlatformPath = parent->filesystem()->asyncFileSystem()->virtualToPlatformPath(destinationPath);
@@ -105,15 +119,10 @@ bool DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const S
 
 bool DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
-    if (!checkValidityForForCopyOrMove(source, parent, newName))
+    String destinationPath;
+    if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, destinationPath))
         return false;
 
-    String destinationPath = parent->fullPath();
-    if (!newName.isEmpty())
-        destinationPath = DOMFilePath::append(destinationPath, newName);
-    else
-        destinationPath = DOMFilePath::append(destinationPath, source->name());
-
     String sourcePlatformPath = m_asyncFileSystem->virtualToPlatformPath(source->fullPath());
     String destinationPlatformPath = parent->filesystem()->asyncFileSystem()->virtualToPlatformPath(destinationPath);
     m_asyncFileSystem->copy(sourcePlatformPath, destinationPlatformPath, EntryCallbacks::create(successCallback, errorCallback, this, destinationPath, source->isDirectory()));
@@ -139,15 +148,11 @@ bool DOMFileSystemBase::getParent(const EntryBase* entry, PassRefPtr<EntryCallba
 
 bool DOMFileSystemBase::getFile(const EntryBase* base, const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
-    ASSERT(base);
-    if (!DOMFilePath::isValidPath(path))
+    String absolutePath;
+    if (!pathToAbsolutePath(base, path, absolutePath))
         return false;
 
-    String absolutePath = path;
-    if (!DOMFilePath::isAbsolute(path))
-        absolutePath = DOMFilePath::removeExtraParentReferences(DOMFilePath::append(base->fullPath(), path));
     String platformPath = m_asyncFileSystem->virtualToPlatformPath(absolutePath);
-
     OwnPtr<EntryCallbacks> callbacks = EntryCallbacks::create(successCallback, errorCallback, this, absolutePath, false);
     if (flags && flags->isCreate())
         m_asyncFileSystem->createFile(platformPath, flags->isExclusive(), callbacks.release());
@@ -158,15 +163,11 @@ bool DOMFileSystemBase::getFile(const EntryBase* base, const String& path, PassR
 
 bool DOMFileSystemBase::getDirectory(const EntryBase* base, const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
-    ASSERT(base);
-    if (!DOMFilePath::isValidPath(path))
+    String absolutePath;
+    if (!pathToAbsolutePath(base, path, absolutePath))
         return false;
 
-    String absolutePath = path;
-    if (!DOMFilePath::isAbsolute(path))
-        absolutePath = DOMFilePath::removeExtraParentReferences(DOMFilePath::append(base->fullPath(), path));
     String platformPath = m_asyncFileSystem->virtualToPlatformPath(absolutePath);
-
     OwnPtr<EntryCallbacks> callbacks = EntryCallbacks::create(successCallback, errorCallback, this, absolutePath, true);
     if (flags && flags->isCreate())
         m_asyncFileSystem->createDirectory(platformPath, flags->isExclusive(), callbacks.release());

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list