diff --git a/interfaces/kits/js/src/mod_fs/common_func.cpp b/interfaces/kits/js/src/mod_fs/common_func.cpp index 74f50bccabfba3639e77200cce539ad606495586..858493a4af8ee5f4316e981cc006662049e20e4b 100644 --- a/interfaces/kits/js/src/mod_fs/common_func.cpp +++ b/interfaces/kits/js/src/mod_fs/common_func.cpp @@ -377,7 +377,11 @@ string CommonFunc::GetModeFromFlags(unsigned int flags) bool CommonFunc::CheckPublicDirPath(const std::string &sandboxPath) { for (const std::string &path : PUBLIC_DIR_PATHS) { - if (sandboxPath.find(path) == 0) { + if (sandboxPath == path) { + return true; + } + + if (sandboxPath.find(path + "/") == 0) { return true; } } diff --git a/interfaces/kits/js/src/mod_fs/fs_utils.cpp b/interfaces/kits/js/src/mod_fs/fs_utils.cpp index d8331b21bc4480a94e9b1c0acdf3b52035a1a268..a0379ef5213b0460bf6da1d5121470e3010755e2 100644 --- a/interfaces/kits/js/src/mod_fs/fs_utils.cpp +++ b/interfaces/kits/js/src/mod_fs/fs_utils.cpp @@ -88,7 +88,11 @@ string FsUtils::GetModeFromFlags(const uint32_t &flags) bool FsUtils::CheckPublicDirPath(const string &sandboxPath) { for (const string &path : PUBLIC_DIR_PATHS) { - if (sandboxPath.find(path) == 0) { + if (sandboxPath == path) { + return true; + } + + if (sandboxPath.find(path + "/") == 0) { return true; } }