diff --git a/evennia/prototypes/protfuncs.py b/evennia/prototypes/protfuncs.py index 853634d9f6..6e9c7e5679 100644 --- a/evennia/prototypes/protfuncs.py +++ b/evennia/prototypes/protfuncs.py @@ -87,7 +87,14 @@ def protfunc_parser(value, available_functions=None, **kwargs): if not isinstance(value, basestring): return value available_functions = _PROT_FUNCS if available_functions is None else available_functions - result = inlinefuncs.parse_inlinefunc(value, _available_funcs=available_functions, **kwargs) + result = inlinefuncs.parse_inlinefunc(value, available_funcs=available_functions, **kwargs) + # at this point we have a string where all procfuncs were parsed + try: + result = literal_eval(result) + except ValueError: + # this is due to the string not being valid for literal_eval - keep it a string + pass + result = _PROTLIB.value_to_obj_or_any(result) try: return literal_eval(result) diff --git a/evennia/utils/inlinefuncs.py b/evennia/utils/inlinefuncs.py index 2646fb3991..575baf281f 100644 --- a/evennia/utils/inlinefuncs.py +++ b/evennia/utils/inlinefuncs.py @@ -157,6 +157,9 @@ def clr(*args, **kwargs): return text +def null(*args, **kwargs): + return args[0] if args else '' + # we specify a default nomatch function to use if no matching func was # found. This will be overloaded by any nomatch function defined in # the imported modules. @@ -177,10 +180,6 @@ for module in utils.make_iter(settings.INLINEFUNC_MODULES): raise -# remove the core function if we include examples in this module itself -#_INLINE_FUNCS.pop("inline_func_parse", None) - - # The stack size is a security measure. Set to <=0 to disable. try: _STACK_MAXSIZE = settings.INLINEFUNC_STACK_MAXSIZE @@ -198,7 +197,7 @@ _RE_TOKEN = re.compile(r""" (?P(?(?\\'|\\"|\\\)|\\$\w+\()| # escaped tokens should re-appear in text - (?P[\w\s.-\/#!%\^&\*;:=\-_`~\|\(}{\[\]]+|\"{1}|\'{1}) # everything else should also be included""", + (?P[\w\s.-\/#@$\>\ 0 and _STACK_MAXSIZE < len(stack): # if stack is larger than limit, throw away parsing return string + gdict["stackfull"](*args, **kwargs) - else: - # cache the stack + elif usecache: + # cache the stack - we do this also if we don't check the cache above _PARSING_CACHE[string] = stack # run the stack recursively @@ -368,8 +370,8 @@ def parse_inlinefunc(string, strip=False, _available_funcs=None, **kwargs): retval = "" if strip else func(*args, **kwargs) return utils.to_str(retval, force_string=True) - # execute the stack from the cache - return "".join(_run_stack(item) for item in _PARSING_CACHE[string]) + # execute the stack + return "".join(_run_stack(item) for item in stack) # # Nick templating