From: johnnyg@google.com Date: Tue, 20 Sep 2011 23:49:19 +0000 (+0000) Subject: Directory Upload: parent path can truncate first char of the correct path X-Git-Tag: 070512121124~24029 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be0e9faadd14d48afab7c37f7d953b246d15ec05;p=profile%2Fivi%2Fwebkit-efl.git Directory Upload: parent path can truncate first char of the correct path https://bugs.webkit.org/show_bug.cgi?id=66695 Source/WebCore: In some cases, if the parent path we compute ends with a separator character like '/' or 'C:\', by adding one in an attempt to grab the subsequent separator we actually grab a character of the real path, which is incorrect. Reviewed by Darin Fisher. * html/FileInputType.cpp: (WebCore::FileInputType::setFileList): LayoutTests: Add a test case for when the parent path is '/'. Reviewed by Darin Fisher. * fast/forms/input-file-directory-upload.html: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95582 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 3b5abed..2fa4c65 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,14 @@ +2011-09-20 John Gregg + + Directory Upload: parent path can truncate first char of the correct path + https://bugs.webkit.org/show_bug.cgi?id=66695 + + Add a test case for when the parent path is '/'. + + Reviewed by Darin Fisher. + + * fast/forms/input-file-directory-upload.html: + 2011-09-20 Jochen Eisinger Invoke CachedResourceLoader::canRequest for all URLs in a redirect chain diff --git a/LayoutTests/fast/forms/input-file-directory-upload.html b/LayoutTests/fast/forms/input-file-directory-upload.html index 0123ee4..683ded3 100644 --- a/LayoutTests/fast/forms/input-file-directory-upload.html +++ b/LayoutTests/fast/forms/input-file-directory-upload.html @@ -31,6 +31,12 @@ var testFileList4 = [ {'path': 'resources/dirupload/path1/subpath1/file1', 'expect-relpath': 'path1/subpath1/file1' }, ]; +var testFileList5 = [ + {'path': '/foo/baz', 'expect-relpath': 'foo/baz'}, + {'path': '/foo/bar/baz', 'expect-relpath': 'foo/bar/baz'}, + {'path': '/foo2/baz', 'expect-relpath': 'foo2/baz'}, +]; + function log(message) { document.getElementById('output').appendChild(document.createTextNode(message + "\n")); @@ -71,7 +77,8 @@ if (window.eventSender) { doTest(testFileList1); doTest(testFileList2); doTest(testFileList3); - doTest(testFileList4, true); + doTest(testFileList4); + doTest(testFileList5, true); } diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 6468a3d..c852014 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,18 @@ +2011-09-20 John Gregg + + Directory Upload: parent path can truncate first char of the correct path + https://bugs.webkit.org/show_bug.cgi?id=66695 + + In some cases, if the parent path we compute ends with a separator + character like '/' or 'C:\', by adding one in an attempt to grab the + subsequent separator we actually grab a character of the real path, + which is incorrect. + + Reviewed by Darin Fisher. + + * html/FileInputType.cpp: + (WebCore::FileInputType::setFileList): + 2011-09-20 Jochen Eisinger Invoke CachedResourceLoader::canRequest for all URLs in a redirect chain diff --git a/Source/WebCore/html/FileInputType.cpp b/Source/WebCore/html/FileInputType.cpp index a999345..cc5e679 100644 --- a/Source/WebCore/html/FileInputType.cpp +++ b/Source/WebCore/html/FileInputType.cpp @@ -241,9 +241,12 @@ void FileInputType::setFileList(const Vector& paths) } rootPath = directoryName(rootPath); ASSERT(rootPath.length()); + int rootLength = rootPath.length(); + if (rootPath[rootLength - 1] != '\\' && rootPath[rootLength - 1] != '/') + rootLength += 1; for (size_t i = 0; i < size; i++) { // Normalize backslashes to slashes before exposing the relative path to script. - String relativePath = paths[i].substring(1 + rootPath.length()).replace('\\', '/'); + String relativePath = paths[i].substring(rootLength).replace('\\', '/'); m_fileList->append(File::createWithRelativePath(paths[i], relativePath)); } return;