[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 12:32:14 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a25a1c55f14a80f675d520d2411765d9503520bc
Author: kinuko at chromium.org <kinuko at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 25 04:31:20 2010 +0000

    2010-08-24  Kinuko Yasuda  <kinuko at chromium.org>
    
            Reviewed by Dumitru Daniliuc.
    
            Implement virtual path utilities for FileSystem API
            https://bugs.webkit.org/show_bug.cgi?id=44132
    
            No new tests; tests will be added later. (Each DOMFilePath's method is briefly tested locally.)
    
            * CMakeLists.txt:
            * GNUmakefile.am:
            * WebCore.gypi:
            * WebCore.pro:
            * WebCore.vcproj/WebCore.vcproj:
            * WebCore.xcodeproj/project.pbxproj:
            * storage/DOMFilePath.cpp: Added.
            * storage/DOMFilePath.h: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65975 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 93b13a2..32d2d57 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1459,6 +1459,7 @@ SET(WebCore_SOURCES
     storage/DatabaseTracker.cpp
     storage/DirectoryEntry.cpp
     storage/DirectoryReader.cpp
+    storage/DOMFilePath.cpp
     storage/DOMFileSystem.cpp
     storage/Entry.cpp
     storage/EntryArray.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0d1dfae..4ecb448 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2010-08-24  Kinuko Yasuda  <kinuko at chromium.org>
+
+        Reviewed by Dumitru Daniliuc.
+
+        Implement virtual path utilities for FileSystem API
+        https://bugs.webkit.org/show_bug.cgi?id=44132
+
+        No new tests; tests will be added later. (Each DOMFilePath's method is briefly tested locally.)
+
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * storage/DOMFilePath.cpp: Added.
+        * storage/DOMFilePath.h: Added.
+
 2010-08-24  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Eric Seidel.
@@ -1199,7 +1217,6 @@
 
         * html/HTMLTreeBuilder.cpp:
 
->>>>>>> .r65945
 2010-08-23  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index c1c3b0c..c3d230a 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -2994,12 +2994,12 @@ webcore_sources += \
 endif # END ENABLE_DOM_STORAGE
 
 # ----
-# HTML5 FileSystem API support
+# FileSystem API support
 # ----
 if ENABLE_FILE_SYSTEM
+
 FEATURE_DEFINES += ENABLE_FILE_SYSTEM=1
 webcore_cppflags += -DENABLE_FILE_SYSTEM=1
-endif # END ENABLE_FILE_SYSTEM
 
 webcore_built_sources += \
        DerivedSources/WebCore/JSDirectoryEntry.cpp \
@@ -3034,6 +3034,8 @@ webcore_sources += \
        WebCore/storage/DirectoryEntry.h \
        WebCore/storage/DirectoryReader.cpp \
        WebCore/storage/DirectoryReader.h \
+       WebCore/storage/DOMFilePath.cpp \
+       WebCore/storage/DOMFilePath.h \
        WebCore/storage/DOMFileSystem.cpp \
        WebCore/storage/DOMFileSystem.h \
        WebCore/storage/EntriesCallback.h \
@@ -3052,6 +3054,8 @@ webcore_sources += \
        WebCore/storage/Metadata.h \
        WebCore/storage/MetadataCallback.h
 
+endif # END ENABLE_FILE_SYSTEM
+
 # ----
 # Speech Input API support
 # ----
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index ad1a7d5..8117dfe 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -3558,6 +3558,8 @@
             'storage/DirectoryEntry.h',
             'storage/DirectoryReader.cpp',
             'storage/DirectoryReader.h',
+            'storage/DOMFilePath.cpp',
+            'storage/DOMFilePath.h',
             'storage/DOMFileSystem.cpp',
             'storage/DOMFileSystem.h',
             'storage/EntriesCallback.h',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 848e991..62d1c68 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -2585,6 +2585,7 @@ contains(DEFINES, ENABLE_FILE_SYSTEM=1) {
     HEADERS += \
         storage/DirectoryEntry.h \
         storage/DirectoryReader.h \
+        storage/DOMFilePath.h \
         storage/DOMFileSystem.h \
         storage/EntriesCallback.h \
         storage/Entry.h \
@@ -2601,6 +2602,7 @@ contains(DEFINES, ENABLE_FILE_SYSTEM=1) {
     SOURCES += \
         storage/DirectoryEntry.cpp \
         storage/DirectoryReader.cpp \
+        storage/DOMFilePath.cpp \
         storage/DOMFileSystem.cpp \
         storage/Entry.cpp \
         storage/EntryArray.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index e93bfb3..f79206b 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -51165,6 +51165,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\storage\DOMFilePath.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\storage\DOMFilePath.h"
+				>
+			</File>
+			<File
 				RelativePath="..\storage\DOMFileSystem.cpp"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 04cfd11..a96824b 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -2382,11 +2382,19 @@
 		85FF315A0AAFBFCB00374F38 /* DOMKeyboardEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 85FF31580AAFBFCB00374F38 /* DOMKeyboardEvent.h */; };
 		85FF315B0AAFBFCB00374F38 /* DOMKeyboardEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */; };
 		86243D0111BC31F700CC006A /* JSArrayBufferViewHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */; };
+		8947A82912222C4700D95F2D /* JSMetadata.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8947A82512222C4700D95F2D /* JSMetadata.cpp */; };
+		8947A82A12222C4700D95F2D /* JSMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 8947A82612222C4700D95F2D /* JSMetadata.h */; };
+		8947A82B12222C4700D95F2D /* JSMetadataCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8947A82712222C4700D95F2D /* JSMetadataCallback.cpp */; };
+		8947A82C12222C4700D95F2D /* JSMetadataCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 8947A82812222C4700D95F2D /* JSMetadataCallback.h */; };
+		8947A83C122234F400D95F2D /* Metadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 897A2D73120001440082740C /* Metadata.h */; };
+		8947A83D122234F900D95F2D /* MetadataCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 897A2D75120001440082740C /* MetadataCallback.h */; };
 		8952535211641B3400CABF00 /* FileThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8952535011641B3400CABF00 /* FileThread.cpp */; };
 		8952535311641B3400CABF00 /* FileThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 8952535111641B3400CABF00 /* FileThread.h */; };
 		895253DC116C4EF500CABF00 /* FileStreamProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 895253DA116C4EF500CABF00 /* FileStreamProxy.cpp */; };
 		895253DD116C4EF500CABF00 /* FileStreamProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 895253DB116C4EF500CABF00 /* FileStreamProxy.h */; };
 		895253DF116C4F0600CABF00 /* FileThreadTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 895253DE116C4F0600CABF00 /* FileThreadTask.h */; };
+		89686C9F122244A00076EAA4 /* DOMFilePath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 89686C9D122244A00076EAA4 /* DOMFilePath.cpp */; };
+		89686CA0122244A00076EAA4 /* DOMFilePath.h in Headers */ = {isa = PBXBuildFile; fileRef = 89686C9E122244A00076EAA4 /* DOMFilePath.h */; };
 		8988E10E11A3508B00DB732E /* BlobItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8988E10C11A3508B00DB732E /* BlobItem.cpp */; };
 		8988E10F11A3508B00DB732E /* BlobItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 8988E10D11A3508B00DB732E /* BlobItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		899ABC261215E4A300F9F219 /* DirectoryEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 899ABC201215E4A300F9F219 /* DirectoryEntry.cpp */; };
@@ -8242,11 +8250,17 @@
 		85FF31580AAFBFCB00374F38 /* DOMKeyboardEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMKeyboardEvent.h; sourceTree = "<group>"; };
 		85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMKeyboardEvent.mm; sourceTree = "<group>"; };
 		86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferViewHelper.h; sourceTree = "<group>"; };
+		8947A82512222C4700D95F2D /* JSMetadata.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMetadata.cpp; sourceTree = "<group>"; };
+		8947A82612222C4700D95F2D /* JSMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMetadata.h; sourceTree = "<group>"; };
+		8947A82712222C4700D95F2D /* JSMetadataCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMetadataCallback.cpp; sourceTree = "<group>"; };
+		8947A82812222C4700D95F2D /* JSMetadataCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMetadataCallback.h; sourceTree = "<group>"; };
 		8952535011641B3400CABF00 /* FileThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileThread.cpp; sourceTree = "<group>"; };
 		8952535111641B3400CABF00 /* FileThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileThread.h; sourceTree = "<group>"; };
 		895253DA116C4EF500CABF00 /* FileStreamProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileStreamProxy.cpp; sourceTree = "<group>"; };
 		895253DB116C4EF500CABF00 /* FileStreamProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStreamProxy.h; sourceTree = "<group>"; };
 		895253DE116C4F0600CABF00 /* FileThreadTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileThreadTask.h; sourceTree = "<group>"; };
+		89686C9D122244A00076EAA4 /* DOMFilePath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMFilePath.cpp; sourceTree = "<group>"; };
+		89686C9E122244A00076EAA4 /* DOMFilePath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMFilePath.h; sourceTree = "<group>"; };
 		897A2D1911FF58A50082740C /* DOMFileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMFileSystem.cpp; sourceTree = "<group>"; };
 		897A2D1A11FF58A50082740C /* DOMFileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMFileSystem.h; sourceTree = "<group>"; };
 		897A2D1B11FF58A50082740C /* DOMFileSystem.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMFileSystem.idl; sourceTree = "<group>"; };
@@ -11592,6 +11606,8 @@
 				899ABC231215E4A300F9F219 /* DirectoryReader.cpp */,
 				899ABC241215E4A300F9F219 /* DirectoryReader.h */,
 				899ABC251215E4A300F9F219 /* DirectoryReader.idl */,
+				89686C9D122244A00076EAA4 /* DOMFilePath.cpp */,
+				89686C9E122244A00076EAA4 /* DOMFilePath.h */,
 				897A2D1911FF58A50082740C /* DOMFileSystem.cpp */,
 				897A2D1A11FF58A50082740C /* DOMFileSystem.h */,
 				897A2D1B11FF58A50082740C /* DOMFileSystem.idl */,
@@ -15150,6 +15166,10 @@
 				C585A67B11D4FB07004C3E4B /* JSIDBSuccessEvent.h */,
 				B656626F120B1227006EA85C /* JSIDBTransaction.cpp */,
 				B656626E120B1227006EA85C /* JSIDBTransaction.h */,
+				8947A82512222C4700D95F2D /* JSMetadata.cpp */,
+				8947A82612222C4700D95F2D /* JSMetadata.h */,
+				8947A82712222C4700D95F2D /* JSMetadataCallback.cpp */,
+				8947A82812222C4700D95F2D /* JSMetadataCallback.h */,
 				514C76350CE9225E007EF3CD /* JSSQLError.cpp */,
 				BC8243250D0CE8A200460C8F /* JSSQLError.h */,
 				B525A96411CA2340003A23A8 /* JSSQLException.cpp */,
@@ -20361,6 +20381,11 @@
 				CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */,
 				9F0D6B2F121BFEBA006C0288 /* InspectorProfilerAgent.h in Headers */,
 				2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */,
+				89686CA0122244A00076EAA4 /* DOMFilePath.h in Headers */,
+				8947A82A12222C4700D95F2D /* JSMetadata.h in Headers */,
+				8947A82C12222C4700D95F2D /* JSMetadataCallback.h in Headers */,
+				8947A83C122234F400D95F2D /* Metadata.h in Headers */,
+				8947A83D122234F900D95F2D /* MetadataCallback.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -22816,6 +22841,9 @@
 				CE057FA51220731100A476D5 /* DocumentMarkerController.cpp in Sources */,
 				9F0D6B2E121BFEBA006C0288 /* InspectorProfilerAgent.cpp in Sources */,
 				2EB4BCD2121F03E300EC4885 /* BlobResourceHandle.cpp in Sources */,
+				89686C9F122244A00076EAA4 /* DOMFilePath.cpp in Sources */,
+				8947A82912222C4700D95F2D /* JSMetadata.cpp in Sources */,
+				8947A82B12222C4700D95F2D /* JSMetadataCallback.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/storage/DOMFilePath.cpp b/WebCore/storage/DOMFilePath.cpp
new file mode 100644
index 0000000..2da057c
--- /dev/null
+++ b/WebCore/storage/DOMFilePath.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DOMFilePath.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "RegularExpression.h"
+#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+const char DOMFilePath::separator = '/';
+const char DOMFilePath::root[] = "/";
+
+String DOMFilePath::append(const String& base, const String& components)
+{
+    return ensureDirectoryPath(base) + components;
+}
+
+String DOMFilePath::ensureDirectoryPath(const String& path)
+{
+    if (!DOMFilePath::endsWithSeparator(path)) {
+        String newPath = path;
+        newPath.append(DOMFilePath::separator);
+        return newPath;
+    }
+    return path;
+}
+
+String DOMFilePath::getName(const String& path)
+{
+    int index = path.reverseFind(DOMFilePath::separator);
+    if (index != -1)
+        return path.substring(index);
+    return path;
+}
+
+String DOMFilePath::getDirectory(const String& path)
+{
+    int index = path.reverseFind(DOMFilePath::separator);
+    if (index == 0)
+        return DOMFilePath::root;
+    if (index != -1)
+        return path.substring(0, index);
+    return ".";
+}
+
+bool DOMFilePath::isParentOf(const String& parent, const String& mayBeChild)
+{
+    ASSERT(DOMFilePath::isAbsolute(parent));
+    ASSERT(DOMFilePath::isAbsolute(mayBeChild));
+    if (parent == DOMFilePath::root && mayBeChild != DOMFilePath::root)
+        return true;
+    if (parent.length() >= mayBeChild.length() || !mayBeChild.startsWith(parent, false))
+        return false;
+    if (mayBeChild[parent.length()] != DOMFilePath::separator)
+        return false;
+    return true;
+}
+
+String DOMFilePath::removeExtraParentReferences(const String& path)
+{
+    ASSERT(DOMFilePath::isAbsolute(path));
+    Vector<String> components;
+    Vector<String> canonicalized;
+    path.split(DOMFilePath::separator, components);
+    for (size_t i = 0; i < components.size(); ++i) {
+        if (components[i] == ".")
+            continue;
+        if (components[i] == "..") {
+            if (canonicalized.size() > 0)
+                canonicalized.removeLast();
+            continue;
+        }
+        canonicalized.append(components[i]);
+    }
+    if (canonicalized.isEmpty())
+        return DOMFilePath::root;
+    String result;
+    for (size_t i = 0; i < canonicalized.size(); ++i) {
+        result.append(DOMFilePath::separator);
+        result.append(canonicalized[i]);
+    }
+    return result;
+}
+
+// Check the naming restrictions defined in FileSystem API 8.3.
+// http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#naming-restrictions
+bool DOMFilePath::isValidPath(const String& path)
+{
+    if (path.isEmpty() || path == DOMFilePath::root)
+        return true;
+
+    // Chars 0-31 in UTF-8 prepresentation are not allowed.
+    for (size_t i = 0; i < path.length(); ++i)
+        if (path[i] < 32)
+            return false;
+
+    // Unallowed names.
+    DEFINE_STATIC_LOCAL(RegularExpression, unallowedNamesRegExp1, ("(/|^)(CON|PRN|AUX|NUL)([\\./]|$)", TextCaseInsensitive));
+    DEFINE_STATIC_LOCAL(RegularExpression, unallowedNamesRegExp2, ("(/|^)(COM|LPT)[1-9]([\\./]|$)", TextCaseInsensitive));
+
+    if (unallowedNamesRegExp1.match(path) >= 0)
+        return false;
+    if (unallowedNamesRegExp2.match(path) >= 0)
+        return false;
+
+    // Names must not end with period or whitespace.
+    DEFINE_STATIC_LOCAL(RegularExpression, endingRegExp, ("[\\.\\s](/|$)", TextCaseInsensitive));
+
+    if (endingRegExp.match(path) >= 0)
+        return false;
+
+    // Unallowed chars: '\', '<', '>', ':', '?', '*', '"', '|'
+    // (We don't check '/' here as this method takes paths as its argument.)
+    DEFINE_STATIC_LOCAL(RegularExpression, unallowedCharsRegExp, ("[\\\\<>:\\?\\*\"|]", TextCaseInsensitive));
+
+    if (unallowedCharsRegExp.match(path) >= 0)
+        return false;
+
+    return true;
+}
+
+bool DOMFilePath::isValidName(const String& name)
+{
+    if (name.isEmpty())
+        return true;
+    // '/' is not allowed in name.
+    if (name.contains('/'))
+        return false;
+    return isValidPath(name);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/WebCore/storage/DOMFilePath.h b/WebCore/storage/DOMFilePath.h
new file mode 100644
index 0000000..2f2bb23
--- /dev/null
+++ b/WebCore/storage/DOMFilePath.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DOMFilePath_h
+#define DOMFilePath_h
+
+#include "PlatformString.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+// DOMFileSystem path utilities. All methods in this class are static.
+class DOMFilePath {
+public:
+    static const char separator;
+    static const char root[];
+
+    // Returns the name part from the given path.
+    static String getName(const String& path);
+
+    // Returns the parent directory path of the given path.
+    static String getDirectory(const String& path);
+
+    // Checks if a given path is a parent of mayBeChild. This method assumes given paths are absolute and do not have extra references to a parent (i.e. "../").
+    static bool isParentOf(const String& path, const String& mayBeChild);
+
+    // Appends the separator at the end of the path if it's not there already.
+    static String ensureDirectoryPath(const String& path);
+
+    // Returns a new path by appending a separator and the supplied path component to the path.
+    static String append(const String& path, const String& component);
+
+    static bool isAbsolute(const String& path)
+    {
+        return path.startsWith(DOMFilePath::root);
+    }
+
+    static bool endsWithSeparator(const String& path)
+    {
+        return path[path.length() - 1] == DOMFilePath::separator;
+    }
+
+    // Evaluates all "../" and "./" segments.  Note that "/../" expands to "/", so you can't ever refer to anything above the root directory.
+    static String removeExtraParentReferences(const String& path);
+
+    // Checks if the given path follows the FileSystem API naming restrictions.
+    static bool isValidPath(const String& path);
+
+    // Checks if the given name follows the FileSystem API naming restrictions.
+    static bool isValidName(const String& name);
+
+private:
+    DOMFilePath() { }
+};
+
+} // namespace WebCore
+
+#endif // DOMFilePath_h

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list