From 74763465a8c1862315bff916e1872f080b74bc97 Mon Sep 17 00:00:00 2001 From: shortcutme <tamas@zeronet.io> Date: Fri, 14 Jul 2017 10:34:57 +0200 Subject: [PATCH] Use SafeRe to match file patterns in dbschema.json --- src/Db/Db.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Db/Db.py b/src/Db/Db.py index df73bde7..c2de5509 100644 --- a/src/Db/Db.py +++ b/src/Db/Db.py @@ -8,6 +8,7 @@ import gevent from DbCursor import DbCursor from Config import config +from util import SafeRe opened_dbs = [] @@ -230,8 +231,11 @@ class Db(object): # Check if filename matches any of mappings in schema matched_maps = [] for match, map_settings in self.schema["maps"].items(): - if re.match(match, relative_path): - matched_maps.append(map_settings) + try: + if SafeRe.match(match, relative_path): + matched_maps.append(map_settings) + except SafeRe.UnsafePatternError as err: + self.log.error(err) # No match found for the file if not matched_maps: