diff --git a/interfaces/common/src/common_func.cpp b/interfaces/common/src/common_func.cpp index ac37cffbd004a4b95acef657b4a46227e7845918..1218cf70e07d751677c93060f4cec5605fcf0a44 100644 --- a/interfaces/common/src/common_func.cpp +++ b/interfaces/common/src/common_func.cpp @@ -111,7 +111,7 @@ static void NormalizePath(string &path) string CommonFunc::GetUriFromPath(const string &path) { if (!SandboxHelper::IsValidPath(path)) { - LOGE("path is ValidPath, The path contains '/./' or '../'characters"); + LOGE("path is ValidPath, The path contains '../' characters"); return ""; } if (path.find(FILE_SCHEME_PREFIX) == 0) { diff --git a/interfaces/common/src/sandbox_helper.cpp b/interfaces/common/src/sandbox_helper.cpp index 854ddcab08fc8641a05062c06367407563bad465..6c274917b843fe66ccbeb635fea035a1d5b9a192 100644 --- a/interfaces/common/src/sandbox_helper.cpp +++ b/interfaces/common/src/sandbox_helper.cpp @@ -376,7 +376,7 @@ int32_t SandboxHelper::GetPhysicalPath(const std::string &fileUri, const std::st std::string &physicalPath) { if (!IsValidPath(fileUri)) { - LOGE("fileUri is ValidUri, The fileUri contains '/./' or '../'characters"); + LOGE("fileUri is ValidUri, The fileUri contains '../' characters"); return -EINVAL; } Uri uri(fileUri); @@ -416,7 +416,7 @@ int32_t SandboxHelper::GetBackupPhysicalPath(const std::string &fileUri, const s std::string &physicalPath) { if (!IsValidPath(fileUri)) { - LOGE("fileUri is ValidUri, The fileUri contains '/./' or '../'characters"); + LOGE("fileUri is ValidUri, The fileUri contains '../' characters"); return -EINVAL; } Uri uri(fileUri); @@ -454,9 +454,6 @@ int32_t SandboxHelper::GetBackupPhysicalPath(const std::string &fileUri, const s bool SandboxHelper::IsValidPath(const std::string &filePath) { - if (filePath.find("/./") != std::string::npos) { - return false; - } size_t pos = filePath.find(PATH_INVALID_FLAG1); while (pos != string::npos) { if (pos == 0 || filePath[pos - 1] == BACKSLASH) { diff --git a/interfaces/innerkits/native/file_uri/src/file_uri.cpp b/interfaces/innerkits/native/file_uri/src/file_uri.cpp index d13f58ab00e685a782d844963db7b472ec880199..b7674f81e6beeb29833a16a0cd1522d6930a13e5 100644 --- a/interfaces/innerkits/native/file_uri/src/file_uri.cpp +++ b/interfaces/innerkits/native/file_uri/src/file_uri.cpp @@ -151,7 +151,7 @@ string FileUri::GetRealPathBySA(const std::string &targetBundleName) { string sandboxPath = DecodeBySA(uri_.GetPath()); if (sandboxPath.empty() || !SandboxHelper::IsValidPath(sandboxPath)) { - LOGE("path is ValidPath, The path contains '/./' or '../'characters"); + LOGE("path is ValidPath, The path contains '../' characters"); return ""; } string realPath = sandboxPath; @@ -174,7 +174,7 @@ string FileUri::GetFullDirectoryUri() { string uri = uri_.ToString(); if (!SandboxHelper::IsValidPath(uri)) { - LOGE("uri is ValidUri, The uri contains '/./' or '../'characters"); + LOGE("uri is ValidUri, The uri contains '../' characters"); return ""; } struct stat fileInfo; @@ -213,7 +213,7 @@ bool FileUri::CheckUriFormat(const std::string &uri) return false; } if (!SandboxHelper::IsValidPath(uri)) { - LOGE("uri is ValidPath, The uri contains '/./' or '../'characters"); + LOGE("uri is ValidPath, The uri contains '../' characters"); return false; } return true; diff --git a/test/unittest/remote_file_share/remote_file_share_test.cpp b/test/unittest/remote_file_share/remote_file_share_test.cpp index 5df49b3223a62c48e99469c81c842bd1e68c29ee..9a4a769411052f2400c99715e14f1b37431775e2 100644 --- a/test/unittest/remote_file_share/remote_file_share_test.cpp +++ b/test/unittest/remote_file_share/remote_file_share_test.cpp @@ -252,7 +252,7 @@ namespace { HWTEST_F(RemoteFileShareTest, Remote_file_share_GetDfsUriFromLocal_0007, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "RemoteFileShareTest-begin Remote_file_share_GetDfsUriFromLocal_0007"; - const string uriStr = "file://com.demo.a/./data/storage/el2/base/remote_file_share_test.txt"; + const string uriStr = "file://com.demo.a/../data/storage/el2/base/remote_file_share_test.txt"; const int userId = 100; HmdfsUriInfo hui; int ret = RemoteFileShare::GetDfsUriFromLocal(uriStr, userId, hui); @@ -732,7 +732,7 @@ namespace { HWTEST_F(RemoteFileShareTest, remote_file_share_test_0017, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "RemoteFileShareTest-begin remote_file_share_test_0017"; - vector uriList = {"file://docs/storage/Users/currentUser/./Document/1.txt"}; + vector uriList = {"file://docs/storage/Users/currentUser/../Document/1.txt"}; const string networkId = "100"; const string deviceId = "001"; vector resultList;