diff src/lib/Bbcode.luan @ 30:8ff35379cc89

regex cleanup
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 25 Jul 2022 22:10:28 -0600
parents a1db5223ced1
children 298c71e0c854
line wrap: on
line diff
--- a/src/lib/Bbcode.luan	Mon Jul 25 21:28:10 2022 -0600
+++ b/src/lib/Bbcode.luan	Mon Jul 25 22:10:28 2022 -0600
@@ -109,8 +109,8 @@
 
 local video_handlers = {}
 do
-	local ptn1 = regex[[https://youtu.be/([a-zA-Z0-9_-]+)(?:\?t=([0-9]+))?]]
-	local ptn2 = regex[[https://www.youtube.com/watch\?v=([a-zA-Z0-9_-]+)(?:&t=([0-9]+)s)?]]
+	local ptn1 = regex[[^\Qhttps://youtu.be/\E([a-zA-Z0-9_-]+)(?:\?t=([0-9]+))?]]
+	local ptn2 = regex[[^\Qhttps://www.youtube.com/watch?v=\E([a-zA-Z0-9_-]+)(?:&t=([0-9]+)s)?]]
 	function video_handlers.youtube(url)
 		local id, start = ptn1.match(url)
 		if id == nil then
@@ -128,7 +128,7 @@
 	end
 end
 do
-	local ptn = regex[[https://rumble.com/embed/[a-z0-9]+/\?pub=[a-z0-9]+]]
+	local ptn = regex[[^\Qhttps://rumble.com/embed/\E[a-z0-9]+/\?pub=[a-z0-9]+]]
 	function video_handlers.rumble(url)
 		if not ptn.matches(url) then
 			return false
@@ -138,7 +138,7 @@
 	end
 end
 do
-	local ptn = regex[[https://www.bitchute.com/video/([a-zA-Z0-9]+)/]]
+	local ptn = regex[[^\Qhttps://www.bitchute.com/video/\E([a-zA-Z0-9]+)/]]
 	function video_handlers.bitchute(url)
 		local id = ptn.match(url)
 		if id == nil then
@@ -150,7 +150,7 @@
 	end
 end
 do
-	local ptn = regex[[https://vimeo.com/([0-9]+)]]
+	local ptn = regex[[^\Qhttps://vimeo.com/\E([0-9]+)]]
 	function video_handlers.vimeo(url)
 		local id = ptn.match(url)
 		if id == nil then
@@ -162,7 +162,7 @@
 	end
 end
 do
-	local ptn = regex[[https://dai.ly/([a-z0-9]+)]]
+	local ptn = regex[[^\Qhttps://dai.ly/\E([a-z0-9]+)]]
 	function video_handlers.dailymotion(url)
 		local id = ptn.match(url)
 		if id == nil then
@@ -174,7 +174,7 @@
 	end
 end
 do
-	local ptn = regex[[https://www.tiktok.com/[^/]+/video/([0-9]+)]]
+	local ptn = regex[[^\Qhttps://www.tiktok.com/\E[^/]+/video/([0-9]+)]]
 	function video_handlers.tiktok(url)
 		local id = ptn.match(url)
 		if id == nil then