Change to test to see if ast.literal_eval exists; if not fallback to eval (which is not safe)
svn: r13394
This commit is contained in:
parent
ed788f0507
commit
4ffac19071
@ -34,12 +34,17 @@ This package implements access to GRAMPS configuration.
|
|||||||
#
|
#
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
import os
|
import os
|
||||||
import ast
|
|
||||||
import time
|
import time
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import errno
|
import errno
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
try:
|
||||||
|
from ast import literal_eval as safe_eval
|
||||||
|
except:
|
||||||
|
# not safe, but works:
|
||||||
|
safe_eval = eval
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Gramps imports
|
# Gramps imports
|
||||||
@ -177,8 +182,8 @@ class ConfigManager(object):
|
|||||||
continue # with next setting
|
continue # with next setting
|
||||||
####################### End upgrade code
|
####################### End upgrade code
|
||||||
else:
|
else:
|
||||||
# a simple eval (does not eval expressions):
|
# as safe as we can be:
|
||||||
value = ast.literal_eval(setting)
|
value = safe_eval(setting)
|
||||||
####################### Now, let's test and set:
|
####################### Now, let's test and set:
|
||||||
if opt.lower() in self.default[name]:
|
if opt.lower() in self.default[name]:
|
||||||
if type(value) == type(self.default[name][opt.lower()]):
|
if type(value) == type(self.default[name][opt.lower()]):
|
||||||
|
Loading…
Reference in New Issue
Block a user