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
+11
View File
@@ -0,0 +1,11 @@
import { openUrl } from '@tauri-apps/plugin-opener'
export async function openExternalUrl(raw: string) {
const url = new URL(raw.trim())
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
throw new Error('Only HTTP and HTTPS URLs are allowed')
}
await openUrl(url.toString())
}