Fix edge case in kwarg parsing for template

This commit is contained in:
Griatch 2020-10-04 21:27:42 +00:00
parent 1746aaf06b
commit ef13565b76

View file

@ -1664,24 +1664,25 @@ def _process_callable(caller, goto, goto_callables, raw_string,
gotokwargs = match.group("kwargs") or "" gotokwargs = match.group("kwargs") or ""
if gotofunc in goto_callables: if gotofunc in goto_callables:
for kwarg in gotokwargs.split(","): for kwarg in gotokwargs.split(","):
key, value = [part.strip() for part in kwarg.split("=", 1)] if kwarg and "=" in kwarg:
if key in ("evmenu_goto", "evmenu_gotomap", "_current_nodename", key, value = [part.strip() for part in kwarg.split("=", 1)]
"evmenu_current_nodename", "evmenu_goto_callables"): if key in ("evmenu_goto", "evmenu_gotomap", "_current_nodename",
raise RuntimeError( "evmenu_current_nodename", "evmenu_goto_callables"):
f"EvMenu template error: goto-callable '{goto}' uses a " raise RuntimeError(
f"kwarg ({kwarg}) that is reserved for the EvMenu templating " f"EvMenu template error: goto-callable '{goto}' uses a "
"system. Rename the kwarg.") f"kwarg ({kwarg}) that is reserved for the EvMenu templating "
try: "system. Rename the kwarg.")
key = literal_eval(key) try:
except ValueError: key = literal_eval(key)
pass except ValueError:
try: pass
value = literal_eval(value) try:
except ValueError: value = literal_eval(value)
pass except ValueError:
kwargs[key] = value pass
kwargs[key] = value
goto = goto_callables[gotofunc](caller, raw_string, **kwargs) goto = goto_callables[gotofunc](caller, raw_string, **kwargs)
if goto is None: if goto is None:
return goto, {"generated_nodename": current_nodename} return goto, {"generated_nodename": current_nodename}
return goto, {"generated_nodename": goto} return goto, {"generated_nodename": goto}