fix(security): restrict external URL opening

Close: 7800
This commit is contained in:
Tunglies
2026-08-25 16:11:47 +08:00
parent b7c4f7d39b
commit 695fadf21e
17 changed files with 136 additions and 61 deletions
+8 -3
View File
@@ -25,8 +25,9 @@ import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router'
import { useAppRefreshers } from '@/providers/app-data-context'
import { openWebUrl, updateProfile } from '@/services/cmds'
import { updateProfile } from '@/services/cmds'
import { showNotice } from '@/services/notice-service'
import { openExternalUrl } from '@/utils/open-external-url'
import parseTraffic from '@/utils/parse-traffic'
import { EnhancedCard } from './enhanced-card'
@@ -49,6 +50,10 @@ const parseExpire = (expire?: number) => {
return dayjs(expire * 1000).format('YYYY-MM-DD')
}
const openProfileHome = (url: string) => {
void openExternalUrl(url).catch(showNotice.error)
}
// 使用类型定义,而不是导入
interface ProfileExtra {
upload: number
@@ -115,7 +120,7 @@ const ProfileDetails = ({
{current.home ? (
<Link
component="button"
onClick={() => current.home && openWebUrl(current.home)}
onClick={() => current.home && openProfileHome(current.home)}
sx={{
display: 'inline-flex',
alignItems: 'center',
@@ -318,7 +323,7 @@ export const HomeProfileCard = ({
<Link
component="button"
variant="h6"
onClick={() => current.home && openWebUrl(current.home)}
onClick={() => current.home && openProfileHome(current.home)}
sx={{
color: 'inherit',
textDecoration: 'none',