diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2021-05-05 18:39:54 +0200 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2021-05-12 21:03:33 +0200 |
commit | ade5679e6de16bfe7bf4d3c56701947b1396b0a3 (patch) | |
tree | 9f222b308ed0f508782cc146baf1f10d4c2f1086 | |
parent | 33e08cdfdfcb6ed759d5ba529db7e7b31484ee16 (diff) |
Fix FilePickerController's path validation for windows and corresponding tests
Change-Id: If2445171232864cb4ac51888ccc93bc00cb099a2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r-- | src/core/file_picker_controller.cpp | 4 | ||||
-rw-r--r-- | tests/auto/quick/qmltests2/data/tst_filePicker.qml | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp index 334321273..4b0576465 100644 --- a/src/core/file_picker_controller.cpp +++ b/src/core/file_picker_controller.cpp @@ -95,7 +95,7 @@ void FilePickerController::accepted(const QStringList &files) if (urlString.startsWith("file:")) { base::FilePath filePath = toFilePath(urlString).NormalizePathSeparators(); std::vector<base::FilePath::StringType> pathComponents; - // Splits the file URL into host name, path and file name. + // Splits the file URL into scheme, host name, path and file name. filePath.GetComponents(&pathComponents); QString absolutePath; @@ -107,7 +107,7 @@ void FilePickerController::accepted(const QStringList &files) if (scheme.size() > 5) { #if defined(OS_WIN) // There is no slash at the end of the file scheme and it is valid on Windows: file:C:/ - if (scheme.at(5).isLetter() && scheme.at(6) != ':') { + if (scheme.size() == 7 && scheme.at(5).isLetter() && scheme.at(6) == ':') { absolutePath += scheme.at(5) + ":/"; } else { #endif diff --git a/tests/auto/quick/qmltests2/data/tst_filePicker.qml b/tests/auto/quick/qmltests2/data/tst_filePicker.qml index 4313c8d9e..26d74e2d3 100644 --- a/tests/auto/quick/qmltests2/data/tst_filePicker.qml +++ b/tests/auto/quick/qmltests2/data/tst_filePicker.qml @@ -227,15 +227,15 @@ TestWebEngineView { { tag: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", input: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", expected: "test.txt"}, { tag: "file://applib/products/a-b/abc_1/t.est/test.txt", input: "file://applib/products/a-b/abc_1/t.est/test.txt", expected: "test.txt"}, { tag: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", input: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", expected: "test.txt"}, - { tag: "file:C:/test.txt", input: "file:C:/test.txt", expected: "test.tx"}, - { tag: "file:/C:/test.txt", input: "file:/C:/test.txt", expected: "test.tx"}, + { tag: "file:C:/test.txt", input: "file:C:/test.txt", expected: "test.txt"}, + { tag: "file:/C:/test.txt", input: "file:/C:/test.txt", expected: "test.txt"}, { tag: "file://C:/test.txt", input: "file://C:/test.txt", expected: "Failed to Upload"}, { tag: "file:///C:test.txt", input: "file:///C:test.txt", expected: "Failed to Upload"}, { tag: "file:///C:/test.txt", input: "file:///C:/test.txt", expected: "test.txt"}, { tag: "file:///C:\\test.txt", input: "file:///C:\\test.txt", expected: "test.txt"}, { tag: "file:\\//C:/test.txt", input: "file:\\//C:/test.txt", expected: "test.txt"}, { tag: "file:\\\\/C:\\test.txt", input: "file:\\\\/C:\\test.txt", expected: "test.txt"}, - { tag: "\\\\?\\C:/test.txt", input: "\\\\?\\C:/test.txt", expected: "test.tx"}, + { tag: "\\\\?\\C:/test.txt", input: "\\\\?\\C:/test.txt", expected: "test.txt"}, ]; } |