From e336d8a2b980d78c8b0e2d943b57dd10f9f77993 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Fri, 19 Jul 2013 14:00:35 +0200 Subject: [PATCH] Strip spaces off of function names before looking them up. They shouldn't ever be significant. --- src/calibre/utils/formatter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index eff38203a0..2fa5901dde 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -137,6 +137,7 @@ class _Parser(object): # We have a function. # Check if it is a known one. We do this here so error reporting is # better, as it can identify the tokens near the problem. + id = id.strip() if id not in funcs: self.error(_('unknown function {0}').format(id)) @@ -246,6 +247,7 @@ class _CompileParser(_Parser): # We have a function. # Check if it is a known one. We do this here so error reporting is # better, as it can identify the tokens near the problem. + id = id.strip() if id not in funcs: self.error(_('unknown function {0}').format(id)) @@ -457,7 +459,7 @@ class TemplateFormatter(string.Formatter): colon += 1 funcs = formatter_functions().get_functions() - fname = fmt[colon:p] + fname = fmt[colon:p].strip() if fname in funcs: func = funcs[fname] if func.arg_count == 2: