[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Improve color error handling (f52a5a8)
Marcel Fabian Krüger
tex at 2krueger.de
Mon Jun 6 18:22:11 CEST 2022
Repository : https://github.com/latex3/luaotfload
On branch : dev
Link : https://github.com/latex3/luaotfload/commit/f52a5a80f441a8fa67b19cab3be46235a4b249cd
>---------------------------------------------------------------
commit f52a5a80f441a8fa67b19cab3be46235a4b249cd
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Mon Jun 6 18:22:11 2022 +0200
Improve color error handling
>---------------------------------------------------------------
f52a5a80f441a8fa67b19cab3be46235a4b249cd
src/luaotfload-colors.lua | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/src/luaotfload-colors.lua b/src/luaotfload-colors.lua
index 0637d07..71e7c0e 100644
--- a/src/luaotfload-colors.lua
+++ b/src/luaotfload-colors.lua
@@ -110,27 +110,44 @@ local function sanitize_color_expression (digits)
rgb, a = custom_splitcolor (digits)
else
rgb, a = lpegmatch(split_color, digits)
+ if not rgb and not a then
+ logreport("both", 0, "color",
+ "%q is not a valid rgb[a] color expression",
+ digits)
+ return
+ end
end
if rgb then
if custom_parsecolor then
rgb = custom_parsecolor(rgb)
else
rgb = lpegmatch(extract_color, rgb)
+ if not rgb then
+ logreport("both", 0, "color",
+ "Invalid color part in color expression %q",
+ digits)
+ return
+ end
end
end
if a then
if custom_parsetransparent then
a = custom_parsetransparent(a)
else
- a = pageresources(lpegmatch(extract_transparent, a))
+ if type(a) == 'string' then
+ a = lpegmatch(extract_transparent, a)
+ if not a then
+ logreport("both", 0, "color",
+ "Invalid transparency part in color expression %q",
+ digits)
+ return
+ end
+ end
+ if a then
+ a = pageresources(a)
+ end
end
end
- if not rgb and not a then
- logreport("both", 0, "color",
- "%q is not a valid rgb[a] color expression",
- digits)
- return
- end
return rgb, a
end
More information about the latex3-commits
mailing list.