manage_edit fails on DTMLDocument

Bug #142590 reported by Drew Ferguson
2
Affects Status Importance Assigned to Milestone
Zope 2
Fix Released
Medium
Unassigned

Bug Description

Uploaded: zopebug.

Tags: bug zope
Revision history for this message
Drew Ferguson (blacktav) wrote :

Calling manage_edit on a DTMLDocument sometimes barfs with

Traceback (innermost last):
  Module ZPublisher.Publish, line 98, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 39, in call_object
  Module OFS.DTMLMethod, line 126, in __call__
  Module DocumentTemplate.DT_String, line 474, in __call__
  Module DocumentTemplate.DT_Util, line 201, in eval
   - __traceback_info__: setBodyContents
  Module <string>, line 2, in f
  Module Shared.DC.Scripts.Bindings, line 252, in __call__
  Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
  Module Products.PythonScripts.PythonScript, line 315, in _exec
  Module Script (Python), line 11, in setBodyContents
   - <PythonScript at /PF/setBodyContents used for /PF/news>
   - Line 11
  Module OFS.DTMLDocument, line 77, in manage_edit
  Module ZPublisher.TaintedString, line 89, in __getattr__
AttributeError: read

For instance, from a python script

  bodyStr = string.replace( bodyStr, '\015\012\015\012', '<br>\015\012<br>\015\012' )
  context['body_contents'].manage_edit( data=bodyStr, title='Body Contents' )

For plain text, the call is fine - if the text contains markup, it fails

Relevant line (77) in DTMLDocumemt.py is

  if type(data) is not type(''): data=data.read()

For data containing markup, type(data) is resolving as <type instance> which presumably has no attribute read.

Workaround is to coerce the variable to a string with

  context['body_contents'].manage_edit( data=str(bodyStr), title='Body Contents' )

Changed in zope2:
status: New → Confirmed
Changed in zope2:
assignee: nobody → Jens Vagelpohl (jens-dataflake)
Revision history for this message
Jens Vagelpohl (dataflake-deactivatedaccount-deactivatedaccount) wrote :

DTMLDocument (and DTMLMethod) were not prepared to deal with TaintedString instances. This is now fixed.

Zope 2.12 branch: http://svn.zope.org/?view=rev&rev=112536

Zope trunk: http://svn.zope.org/?view=rev&rev=112537

Changed in zope2:
status: Confirmed → Fix Committed
Changed in zope2:
milestone: none → 2.12.7
Changed in zope2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.