mirror of
https://github.com/beetbox/beets.git
synced 2026-02-13 10:51:59 +01:00
Only execute pathfields expressions and functions if they are called with an Item argument. Otherwise, return an empty string.
This commit is contained in:
parent
3f4e194c41
commit
e3fa403ad2
1 changed files with 4 additions and 0 deletions
|
|
@ -80,6 +80,8 @@ def compile_inline(python_code):
|
|||
if is_expr:
|
||||
# For expressions, just evaluate and return the result.
|
||||
def _expr_func(obj):
|
||||
if not isinstance(obj, Item):
|
||||
return u''
|
||||
values = _record(obj)
|
||||
try:
|
||||
return eval(code, values)
|
||||
|
|
@ -90,6 +92,8 @@ def compile_inline(python_code):
|
|||
# For function bodies, invoke the function with values as global
|
||||
# variables.
|
||||
def _func_func(obj):
|
||||
if not isinstance(obj, Item):
|
||||
return u''
|
||||
func.__globals__.update(_record(obj))
|
||||
try:
|
||||
return func()
|
||||
|
|
|
|||
Loading…
Reference in a new issue