Commit a745ce58 authored by Evan Simpson's avatar Evan Simpson

Fix bug with expressions containing newlines.

parent cfe8ff8d
......@@ -10,3 +10,4 @@ Page Template changes
Bugs Fixed
- Expressions with embedded newlines were broken
......@@ -86,10 +86,11 @@
"""Generic Python Expression Handler
"""
__version__='$Revision: 1.4 $'[11:-2]
__version__='$Revision: 1.5 $'[11:-2]
from TALES import CompilerError
from string import strip, split, join, replace, lstrip
from sys import exc_info
class getSecurityManager:
'''Null security manager'''
......@@ -106,7 +107,7 @@ class PythonExpr:
self._f = d['f']
except:
raise CompilerError, ('Python expression error:\n'
'%s: %s') % sys.exc_info()[:2]
'%s: %s') % exc_info()[:2]
self._get_used_names()
def _get_used_names(self):
......
......@@ -87,7 +87,7 @@
An implementation of a generic TALES engine
"""
__version__='$Revision: 1.18 $'[11:-2]
__version__='$Revision: 1.19 $'[11:-2]
import re, sys, ZTUtils
from MultiMapping import MultiMapping
......@@ -95,7 +95,7 @@ from MultiMapping import MultiMapping
StringType = type('')
NAME_RE = r"[a-zA-Z][a-zA-Z0-9_]*"
_parse_expr = re.compile(r"(%s):(.*)" % NAME_RE).match
_parse_expr = re.compile(r"(%s):" % NAME_RE).match
_valid_name = re.compile('%s$' % NAME_RE).match
class TALESError(Exception):
......@@ -195,7 +195,8 @@ class Engine:
def compile(self, expression):
m = _parse_expr(expression)
if m:
type, expr = m.group(1, 2)
type = m.group(1)
expr = expression[m.end():]
else:
type = "standard"
expr = expression
......
......@@ -15,6 +15,7 @@ class ExpressionTests(unittest.TestCase):
e.compile('string:A$B')
e.compile('string:a ${x/y} b ${y/z} c')
e.compile('python: 2 + 2')
e.compile('python: 2 \n+\n 2\n')
def test_suite():
return unittest.makeSuite(ExpressionTests)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment