Browse Source

Verify regexes at config parse stage ;3

Wazakindjes 4 years ago
parent
commit
600de8c488
1 changed files with 13 additions and 1 deletions
  1. 13 1
      hurr.py

+ 13 - 1
hurr.py

@@ -198,6 +198,7 @@ if __name__ == "__main__":
 		sys.exit(1)
 
 	for csect in Config.sections():
+		errd = False
 		for copt in Config.options(csect):
 			try:
 				if copt in MUHCONF:
@@ -213,10 +214,21 @@ if __name__ == "__main__":
 							print "[%s] Expanding special path characters in %s" % (copt, cval)
 							cval = os.path.expanduser(cval)
 
+						if copt.find("scrotpattern") != -1:
+							try:
+								p = re.compile(cval, re.I)
+							except re.error as e:
+								errd = True
+								print "Invalid regular expression for %s: %s" % (copt, cval)
+								print "Regex error: [%s]" % e.message
+
 					if copt in MUHCONF.keys() and not cval in [None, -1, '']:
 						MUHCONF[copt] = cval
 			except:
-				print "Invalid value '%s' for %s" % (cval, copt)
+				if errd == False:
+					print "Invalid value '%s' for %s" % (cval, copt)
+
+			if errd == True:
 				sys.exit(1)
 
 	if None in MUHCONF.values():