Skip to content

Commit

Permalink
merging toby-unicode-size-branch, a fix for a regression introduced b…
Browse files Browse the repository at this point in the history
…y TaintedString changes, reported as collector #565
  • Loading branch information
Toby Dickenson committed Sep 16, 2002
1 parent cf90b7d commit a4eedb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions DT_Var.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@
''' # '
__rcs_id__='$Id: DT_Var.py,v 1.57 2002/08/14 22:29:52 mj Exp $'
__version__='$Revision: 1.57 $'[11:-2]
__rcs_id__='$Id: DT_Var.py,v 1.58 2002/09/16 10:09:11 htrd Exp $'
__version__='$Revision: 1.58 $'[11:-2]

from DT_Util import parse_params, name_param, str, ustr
import os, string, re, sys
Expand Down Expand Up @@ -284,7 +284,7 @@ def render(self, md):
if fmt=='s':
# Keep tainted strings as tainted strings here.
if not isinstance(val, TaintedString):
val=str(val)
val=ustr(val)
else:
# Keep tainted strings as tainted strings here.
wastainted = 0
Expand Down Expand Up @@ -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
# quoted later on anyway.
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('\n') >= 0: v='<br />\n'.join(v.split('\n'))
return v
Expand Down
10 changes: 8 additions & 2 deletions tests/testDTMLUnicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"""Document Template Tests
"""

__rcs_id__='$Id: testDTMLUnicode.py,v 1.3 2002/08/14 22:29:53 mj Exp $'
__version__='$Revision: 1.3 $'[11:-2]
__rcs_id__='$Id: testDTMLUnicode.py,v 1.4 2002/09/16 10:09:11 htrd Exp $'
__version__='$Revision: 1.4 $'[11:-2]

import sys, os
import unittest
Expand Down Expand Up @@ -81,6 +81,12 @@ def testUqB(self):
res = html(a=u'he>llo',b=chr(200))
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():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( DTMLUnicodeTests ) )
Expand Down

0 comments on commit a4eedb3

Please sign in to comment.