From 246ef30f958ee3f9a957703a385fcc65607f07a1 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Tue, 16 Apr 2013 18:47:44 +0200 Subject: Preventing loop-references in fontconfig files I just had this case on a recent Ubuntu... --- otfl-font-nms.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index e6faeab..0f44eb4 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -518,12 +518,13 @@ end in OSFONTDIR. ]] -local function read_fonts_conf(path, results) +local function read_fonts_conf(path, results, passed_paths) --[[ This function parses /etc/fonts/fonts.conf and returns all the dir it finds. The code is minimal, please report any error it may generate. ]] local f = io.open(path) + table.insert(passed_paths, path) if not f then logs.info("Warning: unable to read "..path.. ", skipping...") return results @@ -575,14 +576,14 @@ local function read_fonts_conf(path, results) elseif not lfs.isfile(include) and not lfs.isdir(include) then include = file.join(file.dirname(path), include) end - if lfs.isfile(include) and kpse.readable_file(include) then + if lfs.isfile(include) and kpse.readable_file(include) and not table.contains(passed_paths, include) then -- maybe we should prevent loops here? -- we exclude path with texmf in them, as they should -- be found otherwise - read_fonts_conf(include, results) + read_fonts_conf(include, results, passed_paths) elseif lfs.isdir(include) then for _,f in next, glob(file.join(include, "*.conf")) do - read_fonts_conf(f, results) + read_fonts_conf(f, results, passed_paths) end end end @@ -608,7 +609,7 @@ local function get_os_dirs() local windir = os.getenv("WINDIR") return { file.join(windir, 'Fonts') } else - return read_fonts_conf("/etc/fonts/fonts.conf", {}) + return read_fonts_conf("/etc/fonts/fonts.conf", {}, {}) end end -- cgit v1.2.3