fix(gui): tighten youtube id validation

Use the explicit base64url-like character class for YouTube IDs so background validation no longer accepts punctuation matched by A-z ranges.

Tested: rtk docker compose run --rm test
pull/2550/head
Hong Phuc 3 weeks ago
parent d12faef764
commit 02141fef50

@ -178,7 +178,7 @@ def delete_background(key):
# Add background video
def add_background(youtube_uri, filename, citation, position):
# Validate YouTube URI
regex = re.compile(r"(?:\/|%3D|v=|vi=)([0-9A-z\-_]{11})(?:[%#?&]|$)").search(youtube_uri)
regex = re.compile(r"(?:\/|%3D|v=|vi=)([0-9A-Za-z_-]{11})(?:[%#?&]|$)").search(youtube_uri)
if not regex:
flash("YouTube URI is invalid!", "error")

Loading…
Cancel
Save