[Zope-Checkins] SVN: Zope/trunk/src/OFS/ Forward port better fix and test for LP #491224 from 2.8 branch.
Tres Seaver
tseaver at palladion.com
Mon Jan 11 17:24:29 EST 2010
Log message for revision 108039:
Forward port better fix and test for LP #491224 from 2.8 branch.
Changed:
U Zope/trunk/src/OFS/SimpleItem.py
U Zope/trunk/src/OFS/tests/testSimpleItem.py
-=-
Modified: Zope/trunk/src/OFS/SimpleItem.py
===================================================================
--- Zope/trunk/src/OFS/SimpleItem.py 2010-01-11 22:23:10 UTC (rev 108038)
+++ Zope/trunk/src/OFS/SimpleItem.py 2010-01-11 22:24:28 UTC (rev 108039)
@@ -50,7 +50,6 @@
from ExtensionClass import Base
from Persistence import Persistent
from webdav.Resource import Resource
-from webdav.xmltools import escape as xml_escape
from zExceptions import Redirect
from zExceptions import upgradeException
from zExceptions.ExceptionFormatter import format_exception
@@ -295,7 +294,7 @@
exc_info=True
)
try:
- strv = str(error_value)
+ strv = repr(error_value) # quotes tainted strings
except:
strv = ('<unprintable %s object>' %
str(type(error_value).__name__))
@@ -311,7 +310,6 @@
# return the rendered exception and let the
# ZPublisher Exception Hook deal with it.
return error_type, v, tb
- v = xml_escape(v)
raise error_type, v, tb
finally:
if hasattr(self, '_v_eek'): del self._v_eek
Modified: Zope/trunk/src/OFS/tests/testSimpleItem.py
===================================================================
--- Zope/trunk/src/OFS/tests/testSimpleItem.py 2010-01-11 22:23:10 UTC (rev 108038)
+++ Zope/trunk/src/OFS/tests/testSimpleItem.py 2010-01-11 22:24:28 UTC (rev 108039)
@@ -3,16 +3,68 @@
class TestItem(unittest.TestCase):
- def test_z3interfaces(self):
+ def _getTargetClass(self):
+ from OFS.SimpleItem import Item
+ return Item
+
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
+
+ def test_conforms_to_IItem(self):
from OFS.interfaces import IItem
+ from zope.interface.verify import verifyClass
+
+ verifyClass(IItem, self._getTargetClass())
+
+ def test_conforms_to_IManageable(self):
from OFS.interfaces import IManageable
- from OFS.SimpleItem import Item
from zope.interface.verify import verifyClass
- verifyClass(IItem, Item)
- verifyClass(IManageable, Item)
+ verifyClass(IManageable, self._getTargetClass())
+ def test_raise_StandardErrorMessage_str_errorValue(self):
+ class REQUEST(object):
+ class RESPONSE(object):
+ handle_errors = True
+ item = self._makeOne()
+ def _raise_during_standard_error_message(*args, **kw):
+ raise ZeroDivisionError('testing')
+ item.standard_error_message = _raise_during_standard_error_message
+ try:
+ item.raise_standardErrorMessage(
+ error_type=OverflowError,
+ error_value='simple',
+ REQUEST=REQUEST(),
+ )
+ except:
+ import sys
+ self.assertEqual(sys.exc_info()[0], OverflowError)
+ value = sys.exc_info()[1]
+ self.failUnless(value.message.startswith("'simple'"))
+ self.failUnless('full details: testing' in value.message)
+ def test_raise_StandardErrorMessage_TaintedString_errorValue(self):
+ from ZPublisher.TaintedString import TaintedString
+ class REQUEST(object):
+ class RESPONSE(object):
+ handle_errors = True
+ item = self._makeOne()
+ def _raise_during_standard_error_message(*args, **kw):
+ raise ZeroDivisionError('testing')
+ item.standard_error_message = _raise_during_standard_error_message
+ try:
+ item.raise_standardErrorMessage(
+ error_type=OverflowError,
+ error_value=TaintedString('<simple>'),
+ REQUEST=REQUEST(),
+ )
+ except:
+ import sys
+ self.assertEqual(sys.exc_info()[0], OverflowError)
+ value = sys.exc_info()[1]
+ self.failIf('<' in value.message)
+
+
class TestItem_w__name__(unittest.TestCase):
def test_z3interfaces(self):
More information about the Zope-Checkins
mailing list