mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-04 22:52:23 +08:00
fix(security): restrict external URL opening
Close: 7800
This commit is contained in:
@@ -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())
|
||||
}
|
||||
Reference in New Issue
Block a user