Bug 1020153 - Starting system note with '<' causes 500 internal error
Starting system note with '<' causes 500 internal error
Status: CLOSED CURRENTRELEASE
Product: Beaker
Classification: Community
Component: web UI (Show other bugs)
develop
Unspecified Unspecified
medium Severity medium (vote)
: 0.15.1
: ---
Assigned To: xjia
tools-bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-17 03:22 EDT by xjia
Modified: 2015-07-19 20:52 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1020170 (view as bug list)
Environment:
Last Closed: 2013-10-23 02:57:20 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Verify this bug (12.56 KB, image/png)
2013-10-20 22:20 EDT, xjia
no flags Details

  None (edit)
Description xjia 2013-10-17 03:22:09 EDT
Description of problem:
Open one system, and add "<>" in the system notes. will show 500 internal error.

Version-Release number of selected component (if applicable):
0.15.1

How reproducible:
100%

Steps to Reproduce:
1.Open one system
2.Add "<>" in the system notes, click "Add" button
3.

Actual results:
500 error

Expected results:
No error or other wrong message to tell user.

Additional info:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:  Traceback (most recent call last):
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/CherryPy-2.3.0-py2.6.egg/cherrypy/_cphttptools.py", line 121, in _run
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      self.main()
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/CherryPy-2.3.0-py2.6.egg/cherrypy/_cphttptools.py", line 264, in main
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      body = page_handler(*virtual_path, **self.params)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/bkr/server/controllers.py", line 888, in view
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return self._view_system_as_html(fqdn, **kwargs)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "<string>", line 3, in _view_system_as_html
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbogears/controllers.py", line 361, in expose
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      *args, **kw)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/bkr/server/wsgi.py", line 54, in run_with_transaction_noop
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return func(*args, **kwargs)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "<generated code>", line 0, in _expose
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/peak/rules/core.py", line 153, in __call__
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return self.body(*args, **kw)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbogears/controllers.py", line 390, in <lambda>
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      fragment, options, args, kw)))
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbogears/controllers.py", line 451, in _execute_func
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      fragment, **options)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbogears/controllers.py", line 100, in _process_output
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      headers=headers, fragment=fragment, **options)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbogears/view/base.py", line 203, in render
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return engine.render(**kw)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbokid/kidsupport.py", line 220, in render
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      output=output, format=format)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/__init__.py", line 301, in serialize
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      raise_template_error(module=self.__module__)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/__init__.py", line 299, in serialize
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return serializer.serialize(self, encoding, fragment, format)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/serialization.py", line 107, in serialize
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      text = ''.join(self.generate(stream, encoding, fragment, format))
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/serialization.py", line 629, in generate
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in self.apply_filters(stream, format):
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/serialization.py", line 165, in format_stream
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 221, in _coalesce
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/serialization.py", line 477, in inject_meta_tags
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 179, in _track
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for p in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/filter.py", line 32, in apply_matches
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      item = stream.expand()
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 108, in expand
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in self._iter:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 179, in _track
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for p in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 221, in _coalesce
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "build/lib/bkr/server/templates/system.py", line 407, in _pull
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbogears/widgets/base.py", line 401, in display
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return super(CompoundWidget, self).display(value, **params)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbogears/widgets/forms.py", line 48, in _update_path
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      returnval = func(self, *args, **kw)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbogears/widgets/forms.py", line 232, in display
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return super(InputWidget, self).display(value, **params)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbogears/widgets/base.py", line 297, in display
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      output = transform(params, self.template_c)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/turbokid/kidsupport.py", line 234, in transform
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return kid.ElementStream(template.transform()).expand()
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 108, in expand
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in self._iter:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 179, in _track
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for p in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 179, in _track
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for p in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/filter.py", line 26, in apply_matches
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 179, in _track
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for p in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/kid/parser.py", line 221, in _coalesce
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      for ev, item in stream:
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "build/lib/bkr/server/templates/system_notes.py", line 137, in _pull
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/bkr/server/model.py", line 4092, in html
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return XML(markdown(self.text, safe_mode='escape'))
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/markdown/__init__.py", line 587, in markdown
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return md.convert(text)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/markdown/__init__.py", line 386, in convert
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      self.lines = prep.run(self.lines)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/markdown/preprocessors.py", line 128, in run
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      left_tag = self._get_left_tag(block)
Oct 17 07:03:41 beaker-devel beaker-server[25726]:    File "/usr/lib/python2.6/site-packages/markdown/preprocessors.py", line 82, in _get_left_tag
Oct 17 07:03:41 beaker-devel beaker-server[25726]:      return block[1:].replace(">", " ", 1).split()[0].lower()
Oct 17 07:03:41 beaker-devel beaker-server[25726]:  IndexError: list index out of range
Oct 17 07:03:41 beaker-devel beaker-server[25726]:  Error in code generated from template file 'build/lib/bkr/server/templates/system.kid'
Oct 17 07:03:41 beaker-devel beaker-server[25726]: bkr.server.wsgi DEBUG Rolling back for 500 response
Comment 2 Nick Coghlan 2013-10-17 03:42:10 EDT
I spent some time poking around with this, and the problem occurs if the note *starts* with a "<" character, regardless of what comes after that.

It's actually an upstream python-markdown bug. On RHEL6:

Python 2.6.6 (r266:84292, May 27 2013, 05:35:12) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from markdown import markdown
>>> markdown('<')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/markdown/__init__.py", line 587, in markdown
    return md.convert(text)
  File "/usr/lib/python2.6/site-packages/markdown/__init__.py", line 386, in convert
    self.lines = prep.run(self.lines)
  File "/usr/lib/python2.6/site-packages/markdown/preprocessors.py", line 128, in run
    left_tag = self._get_left_tag(block)
  File "/usr/lib/python2.6/site-packages/markdown/preprocessors.py", line 82, in _get_left_tag
    return block[1:].replace(">", " ", 1).split()[0].lower()
IndexError: list index out of range
>>> 
-bash-4.1$ rpm -qa python-markdown
python-markdown-2.0.1-3.1.el6.noarch

On Fedora:

Python 2.7.3 (default, Aug  9 2012, 17:23:57) 
[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from markdown import markdown
>>> markdown("<")
u'<p>&lt;</p>'
>>> 
[ncoghlan@dhcp-41-79 beaker]$ rpm -qa python-markdown
python-markdown-2.2.1-1.fc18.noarch
Comment 3 Nick Coghlan 2013-10-17 05:21:19 EDT
On Gerrit: http://gerrit.beaker-project.org/2368
Comment 4 Nick Coghlan 2013-10-20 07:15:04 EDT
This bug fix is included in beaker-server-0.15.0-1.git.36.022d760.el6eng which is now available for testing here:

https://beaker-devel.app.eng.bos.redhat.com/
Comment 5 xjia 2013-10-20 22:20:42 EDT
Created attachment 814384 [details]
Verify this bug

Verify:
Add "<>" in system notes, and no error happened.
Comment 6 Raymond Mancy 2013-10-23 02:57:20 EDT
beaker 0.15.1 has been released.

Note You need to log in before you can comment on or make changes to this bug.