replace insecure use of eval() with proper use of units
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user