diff --git a/lib/filter_scene.py b/lib/filter_scene.py index 053743b..c5f8280 100644 --- a/lib/filter_scene.py +++ b/lib/filter_scene.py @@ -1,4 +1,4 @@ -# -*- coding: UTF-8 -*- +# -*- coding: utf-8 -*- # Version 3.1; Erik Husby, Ryan Shellberg; Polar Geospatial Center, University of Minnesota; 2019 # Translated from MATLAB code written by Ian Howat, Ohio State University, 2018 @@ -1882,7 +1882,10 @@ def readFromXml(xmlFile, xml_paramstrs): while line != '' and None in values: for ps in xml_paramstrs_left: if ps in line: - values[xml_paramstrs.index(ps)] = line.replace("<{}>".format(ps), '').replace("".format(ps), '') + if not re.match(r"^[A-Za-z0-9-_\.]+$", ps): + raise InvalidArgumentError(f"Error: Illegal XML tag name: {ps}") + regex = "<([^:]*:){0,1}"+ps+">(.*)" + values[xml_paramstrs.index(ps)] = re.sub(regex, r"\2", line) xml_paramstrs_left.remove(ps) break xmlFile_fp.close()