Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c81b1cb

Browse files
committed
Switch from yaml.load to yaml.safe_load for security.
1 parent 7e095b5 commit c81b1cb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ua_parser/user_agent_parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _repl(m):
170170
if index < len(group):
171171
return group[index]
172172
return ''
173-
173+
174174
_string = re.sub(r'\$(\d)', _repl, string)
175175
_string = re.sub(r'^\s+|\s+$', '', _string)
176176
if _string == '':
@@ -180,7 +180,7 @@ def _repl(m):
180180
def Parse(self, user_agent_string):
181181
device, brand, model = None, None, None
182182
match = self.user_agent_re.search(user_agent_string)
183-
if match:
183+
if match:
184184
if self.device_replacement:
185185
device = self.MultiReplace(self.device_replacement, match)
186186
else:
@@ -444,7 +444,7 @@ def GetFilters(user_agent_string, js_user_agent_string=None,
444444
import yaml
445445

446446
yamlFile = open(UA_PARSER_YAML)
447-
regexes = yaml.load(yamlFile)
447+
regexes = yaml.safe_load(yamlFile)
448448
yamlFile.close()
449449

450450
# If UA_PARSER_YAML is not specified, load regexes from regexes.json before
@@ -458,7 +458,7 @@ def GetFilters(user_agent_string, js_user_agent_string=None,
458458
import yaml
459459

460460
yamlFile = open(yamlPath)
461-
regexes = yaml.load(yamlFile)
461+
regexes = yaml.safe_load(yamlFile)
462462
yamlFile.close()
463463

464464

0 commit comments

Comments
 (0)