Bug 1020170 - markdown.markdown fails with leading '<' character
Summary: markdown.markdown fails with leading '<' character
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: python-markdown
Version: 6.6
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Lumír Balhar
QA Contact: Jan Kepler
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-17 07:56 UTC by Nick Coghlan
Modified: 2017-03-21 11:42 UTC (History)
11 users (show)

Fixed In Version: python-markdown-2.0.1-4.el6
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1020153
Environment:
Last Closed: 2017-03-21 11:42:46 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1020153 0 medium CLOSED Starting system note with '<' causes 500 internal error 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2017:0773 0 normal SHIPPED_LIVE python-markdown bug fix update 2017-03-21 12:48:21 UTC

Internal Links: 1020153

Description Nick Coghlan 2013-10-17 07:56:29 UTC
+++ This bug was initially created as a clone of Bug #1020153 +++

Beaker (http://beaker-project.org) recently started supporting the use of markdown in system note fields. HSS QE discovered that starting a note with a "<" caused a 500 internal server error, and traced it back to this failure in the markdown renderer 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, the more recent version of python-markdown handles this correctly:

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

The relevant issue and patch appear to be:

* https://github.com/waylan/Python-Markdown/issues/70
* https://github.com/waylan/Python-Markdown/commit/07bc7a4c8f2e834e0f8150de004c1f8fd98a3d60

Comment 8 errata-xmlrpc 2017-03-21 11:42:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2017-0773.html


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