From c493f8921e537ba974f600e2141ae2f4af29bbd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Wed, 28 Feb 2024 20:29:06 -0800 Subject: [PATCH] Add missing regex anchor detected by CodeQL --- internal/reader/processor/processor.go | 2 +- internal/reader/rewrite/rewrite_functions.go | 2 +- internal/reader/sanitizer/sanitizer.go | 2 +- internal/reader/subscription/finder.go | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/reader/processor/processor.go b/internal/reader/processor/processor.go index 3f4c12c3..0656670f 100644 --- a/internal/reader/processor/processor.go +++ b/internal/reader/processor/processor.go @@ -26,7 +26,7 @@ import ( ) var ( - youtubeRegex = regexp.MustCompile(`youtube\.com/watch\?v=(.*)`) + youtubeRegex = regexp.MustCompile(`youtube\.com/watch\?v=(.*)$`) odyseeRegex = regexp.MustCompile(`^https://odysee\.com`) iso8601Regex = regexp.MustCompile(`^P((?P\d+)Y)?((?P\d+)M)?((?P\d+)W)?((?P\d+)D)?(T((?P\d+)H)?((?P\d+)M)?((?P\d+)S)?)?$`) customReplaceRuleRegex = regexp.MustCompile(`rewrite\("(.*)"\|"(.*)"\)`) diff --git a/internal/reader/rewrite/rewrite_functions.go b/internal/reader/rewrite/rewrite_functions.go index daaf2312..fcccd358 100644 --- a/internal/reader/rewrite/rewrite_functions.go +++ b/internal/reader/rewrite/rewrite_functions.go @@ -20,7 +20,7 @@ import ( ) var ( - youtubeRegex = regexp.MustCompile(`youtube\.com/watch\?v=(.*)`) + youtubeRegex = regexp.MustCompile(`youtube\.com/watch\?v=(.*)$`) youtubeIdRegex = regexp.MustCompile(`youtube_id"?\s*[:=]\s*"([a-zA-Z0-9_-]{11})"`) invidioRegex = regexp.MustCompile(`https?://(.*)/watch\?v=(.*)`) imgRegex = regexp.MustCompile(`]+>`) diff --git a/internal/reader/sanitizer/sanitizer.go b/internal/reader/sanitizer/sanitizer.go index fd39f754..dda98153 100644 --- a/internal/reader/sanitizer/sanitizer.go +++ b/internal/reader/sanitizer/sanitizer.go @@ -19,7 +19,7 @@ import ( ) var ( - youtubeEmbedRegex = regexp.MustCompile(`//www\.youtube\.com/embed/(.*)`) + youtubeEmbedRegex = regexp.MustCompile(`//www\.youtube\.com/embed/(.*)$`) tagAllowList = map[string][]string{ "a": {"href", "title", "id"}, "abbr": {"title"}, diff --git a/internal/reader/subscription/finder.go b/internal/reader/subscription/finder.go index e514a00b..74123195 100644 --- a/internal/reader/subscription/finder.go +++ b/internal/reader/subscription/finder.go @@ -23,8 +23,8 @@ import ( ) var ( - youtubeChannelRegex = regexp.MustCompile(`youtube\.com/channel/(.*)`) - youtubeVideoRegex = regexp.MustCompile(`youtube\.com/watch\?v=(.*)`) + youtubeChannelRegex = regexp.MustCompile(`youtube\.com/channel/(.*)$`) + youtubeVideoRegex = regexp.MustCompile(`youtube\.com/watch\?v=(.*)$`) ) type SubscriptionFinder struct {