diff --git a/app/models/validators.py b/app/models/validators.py index e1e93375f..027f1e9e6 100644 --- a/app/models/validators.py +++ b/app/models/validators.py @@ -2,6 +2,7 @@ from datetime import datetime from decimal import Decimal from typing import Optional +from urllib.parse import urlparse from app.db.models import UserStatusCreate @@ -173,8 +174,11 @@ def validate_proxy_url(value: str | None) -> str | None: class DiscordValidator: @staticmethod def validate_webhook(value: str | None): - if value and not value.startswith("https://discord.com"): - raise ValueError("Discord webhook must start with 'https://discord.com'") + if value: + parsed = urlparse(value) + # validate scheme and hostname + if parsed.scheme != "https" or parsed.hostname not in {"discord.com"}: + raise ValueError("Discord webhook must use https scheme and point to 'discord.com'") return value