From c83fff12a910a4bc90b7f419f9e1e52e1c1d582e Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 12 Feb 2013 17:09:04 -0800 Subject: [PATCH] Match HTML colors in a way that actually works in extract_color Lua patterns don't have optional capture groups, so instead make the contents of the capture groups optional. Closes #1575. --- aegisub/automation/include/utils-auto4.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aegisub/automation/include/utils-auto4.lua b/aegisub/automation/include/utils-auto4.lua index 552598191..a227d37f7 100644 --- a/aegisub/automation/include/utils-auto4.lua +++ b/aegisub/automation/include/utils-auto4.lua @@ -104,9 +104,9 @@ function extract_color(s) end -- Ok how about HTML format then? - r, g, b, a = s:match("#(%x%x)(%x%x)?(%x%x)?(%x%x)?") + r, g, b, a = s:match("#(%x%x)(%x?%x?)(%x?%x?)(%x?%x?)") if r then - return tonumber(r or 0, 16), tonumber(g or 0, 16), tonumber(b or 0, 16), tonumber(a or 0, 16) + return tonumber(r, 16), tonumber(g, 16) or 0, tonumber(b, 16) or 0, tonumber(a, 16) or 0 end -- Failed...