diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 3c5d106db9ca4b561488751c690edffd38c3512b..31c986425649ec622cc1c6dc9c8f86dc1f40fdef 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -6299,6 +6299,10 @@ ErrCode BundleMgrHostImpl::GetAbilityResourceInfo(const std::string &fileType, } RemoveSameAbilityResourceInfo(launcherAbilityResourceInfos); } else { + if (fileType.find('.') != fileType.rfind('.')) { + APP_LOGW("fileType format error"); + return ERR_APPEXECFWK_INPUT_WRONG_TYPE_FILE; + } Want want; want.SetAction(ACTION_VIEW_DATA); want.SetUri(FILE_URI + Constants::SCHEME_SEPARATOR + fileType); diff --git a/services/bundlemgr/test/unittest/bms_bundle_manager_test/bms_bundle_manager_test_three.cpp b/services/bundlemgr/test/unittest/bms_bundle_manager_test/bms_bundle_manager_test_three.cpp index 28ebf6c5239d8add8eb83b1b75e2e7fba7060706..ccfc1bd4411e658b5729b44ffdd1bd41adc79eea 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_manager_test/bms_bundle_manager_test_three.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_manager_test/bms_bundle_manager_test_three.cpp @@ -2194,6 +2194,21 @@ HWTEST_F(BmsBundleManagerTest3, GetAbilityResourceInfo_0004, Function | MediumTe EXPECT_EQ(testRet, ERR_OK); } +/** + * @tc.number: GetAbilityResourceInfo_0005 + * @tc.name: test GetAbilityResourceInfo + * @tc.desc: 1.test GetAbilityResourceInfo + 2.text fileType + */ +HWTEST_F(BmsBundleManagerTest3, GetAbilityResourceInfo_0005, Function | MediumTest | Level1) +{ + auto hostImpl = std::make_unique(); + std::string fileType = "...jpg"; + std::vector launcherAbilityResourceInfos; + auto testRet = hostImpl->GetAbilityResourceInfo(fileType, launcherAbilityResourceInfos); + EXPECT_EQ(testRet, ERR_APPEXECFWK_INPUT_WRONG_TYPE_FILE); +} + /** * @tc.number: GetSpecificResourceInfo_0001 * @tc.name: test GetSpecificResourceInfo