Commit 778d5646 authored by Toby Dickenson's avatar Toby Dickenson

merging toby-unicode-size-branch, a fix for a regression introduced by...

merging toby-unicode-size-branch, a fix for a regression introduced by TaintedString changes, reported as collector #565
parent ae145fea
...@@ -151,8 +151,8 @@ Evaluating expressions without rendering results ...@@ -151,8 +151,8 @@ Evaluating expressions without rendering results
''' # ' ''' # '
__rcs_id__='$Id: DT_Var.py,v 1.57 2002/08/14 22:29:52 mj Exp $' __rcs_id__='$Id: DT_Var.py,v 1.58 2002/09/16 10:09:11 htrd Exp $'
__version__='$Revision: 1.57 $'[11:-2] __version__='$Revision: 1.58 $'[11:-2]
from DT_Util import parse_params, name_param, str, ustr from DT_Util import parse_params, name_param, str, ustr
import os, string, re, sys import os, string, re, sys
...@@ -284,7 +284,7 @@ class Var: ...@@ -284,7 +284,7 @@ class Var:
if fmt=='s': if fmt=='s':
# Keep tainted strings as tainted strings here. # Keep tainted strings as tainted strings here.
if not isinstance(val, TaintedString): if not isinstance(val, TaintedString):
val=str(val) val=ustr(val)
else: else:
# Keep tainted strings as tainted strings here. # Keep tainted strings as tainted strings here.
wastainted = 0 wastainted = 0
...@@ -350,7 +350,7 @@ def newline_to_br(v, name='(Unknown name)', md={}): ...@@ -350,7 +350,7 @@ def newline_to_br(v, name='(Unknown name)', md={}):
# Unsafe data is explicitly quoted here; we don't expect this to be HTML # Unsafe data is explicitly quoted here; we don't expect this to be HTML
# quoted later on anyway. # quoted later on anyway.
if isinstance(v, TaintedString): v = v.quoted() if isinstance(v, TaintedString): v = v.quoted()
v=str(v) v=ustr(v)
if v.find('\r') >= 0: v=''.join(v.split('\r')) if v.find('\r') >= 0: v=''.join(v.split('\r'))
if v.find('\n') >= 0: v='<br />\n'.join(v.split('\n')) if v.find('\n') >= 0: v='<br />\n'.join(v.split('\n'))
return v return v
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"""Document Template Tests """Document Template Tests
""" """
__rcs_id__='$Id: testDTMLUnicode.py,v 1.3 2002/08/14 22:29:53 mj Exp $' __rcs_id__='$Id: testDTMLUnicode.py,v 1.4 2002/09/16 10:09:11 htrd Exp $'
__version__='$Revision: 1.3 $'[11:-2] __version__='$Revision: 1.4 $'[11:-2]
import sys, os import sys, os
import unittest import unittest
...@@ -81,6 +81,12 @@ class DTMLUnicodeTests (unittest.TestCase): ...@@ -81,6 +81,12 @@ class DTMLUnicodeTests (unittest.TestCase):
res = html(a=u'he>llo',b=chr(200)) res = html(a=u'he>llo',b=chr(200))
assert res == expected, `res` assert res == expected, `res`
def testSize(self):
html=self.doc_class('<dtml-var "_.unichr(200)*4" size=2>')
expected = unichr(200)*2+'...'
res = html()
assert res == expected, `res`
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( DTMLUnicodeTests ) ) suite.addTest( unittest.makeSuite( DTMLUnicodeTests ) )
......
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