replace insecure use of eval() with proper use of units

This commit is contained in:
wmayer
2019-05-11 12:50:36 +02:00
parent 5654829e96
commit 34f280d094

View File

@@ -138,11 +138,13 @@ def cmdCreateImageScaling(name):
def accept(self):
sel = FreeCADGui.Selection.getSelection()
try:
locale=QtCore.QLocale.system()
#d, ok = locale.toFloat(str(eval(self.lineEdit.text())))
try:
d = float(str(eval(self.lineEdit.text().replace(',','.'))))
ok = True
q = FreeCAD.Units.parseQuantity(self.lineEdit.text())
d = q.Value
if q.Unit == FreeCAD.Units.Unit(): # plain number
ok = True
elif q.Unit == FreeCAD.Units.Length:
ok = True
except:
ok = False
if not ok: