Edgewall Software

Opened 5 years ago

Closed 5 years ago

#12767 closed defect (fixed)

Test failure with Genshi not installed

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.3.2
Component: general Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:


Noted in gmessage:trac-dev:WNUV3uCJkYk/9oKMfmGXAwAJ:

ERROR: test_input_type_password (trac.util.tests.html.TracHTMLSanitizerTestCase)
Traceback (most recent call last):
  File "/Users/rjollos/Documents/Workspace/trac-dev/trac-trunk/trac/util/tests/html.py", line 104, in test_input_type_password
    self.assertEqual('', self.sanitize(html))
  File "/Users/rjollos/Documents/Workspace/trac-dev/trac-trunk/trac/util/tests/html.py", line 100, in sanitize
    return unicode(TracHTMLSanitizer().sanitize(html))
  File "/Users/rjollos/Documents/Workspace/trac-dev/trac-trunk/trac/util/html.py", line 639, in sanitize
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py", line 117, in feed
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py", line 161, in goahead
    k = self.parse_starttag(i)
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py", line 325, in parse_starttag
    self.handle_startendtag(tag, attrs)
  File "/Users/rjollos/Documents/Workspace/trac-dev/trac-trunk/trac/util/html.py", line 980, in handle_startendtag
    self._handle_start(tag, attrs, '/')
  File "/Users/rjollos/Documents/Workspace/trac-dev/trac-trunk/trac/util/html.py", line 962, in _handle_start
    if not self.sanitizer.is_safe_elem(tag, attrs):
  File "/Users/rjollos/Documents/Workspace/trac-dev/trac-trunk/trac/util/html.py", line 710, in is_safe_elem
    if isinstance(attrs, Attrs):
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types

Ran 2112 tests in 146.305s

Attachments (0)

Change History (3)

comment:1 by Ryan J Ollos, 5 years ago

Attrs is None when Genshi not installed: trunk/trac/util/html.py@15614:50#:L40.

Is the following patch sufficient?:

  • trac/util/html.py

    707707            tag = tag.localname
    708708        if tag == 'input':
    709709            # TODO (1.5.1) no more Attrs
    710             if isinstance(attrs, Attrs):
     710            if Attrs and isinstance(attrs, Attrs):
    711711                input_type = attrs.get('type', '').lower()
    712712                if input_type == 'password':
    713713                    return False

comment:2 by Christian Boos, 5 years ago

Yes, looks good.

comment:3 by Ryan J Ollos, 5 years ago

Resolution: fixed
Status: assignedclosed

Thanks, committed to trunk in r15766.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.