VercodeOperation: only allow simple math expresssions and %c

This commit is contained in:
Hans-Christoph Steiner 2018-03-02 12:50:48 +01:00
parent 6876e28bb4
commit 8f30c892c5
4 changed files with 58 additions and 0 deletions

View file

@ -429,6 +429,9 @@ def checkupdates_app(app):
msg = 'Invalid update check method'
if version and vercode and app.VercodeOperation:
if not common.VERCODE_OPERATION_RE.match(app.VercodeOperation):
raise MetaDataException(_('Invalid VercodeOperation: {field}')
.format(field=app.VercodeOperation))
oldvercode = str(int(vercode))
op = app.VercodeOperation.replace("%c", oldvercode)
vercode = str(eval(op))