From 97674cd3da41892e2f70dfbfd24211c28af57133 Mon Sep 17 00:00:00 2001 From: Hyunjee Kim Date: Thu, 14 May 2020 13:32:38 +0900 Subject: [PATCH] Imported Upstream version 3.2.1 Change-Id: I9c8753dc556f770e78c5aab466cc99d68009d31e Signed-off-by: Hyunjee Kim --- Markdown.egg-info/PKG-INFO | 4 +-- PKG-INFO | 4 +-- docs/change_log/index.md | 5 ++++ markdown/__meta__.py | 2 +- markdown/extensions/toc.py | 5 ++-- tests/test_extensions.py | 50 ++++++++++++++++++++++++++++---------- 6 files changed, 50 insertions(+), 20 deletions(-) diff --git a/Markdown.egg-info/PKG-INFO b/Markdown.egg-info/PKG-INFO index 3455bb3..9526d2b 100644 --- a/Markdown.egg-info/PKG-INFO +++ b/Markdown.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: Markdown -Version: 3.2 +Version: 3.2.1 Summary: Python implementation of Markdown. Home-page: https://Python-Markdown.github.io/ Author: Manfred Stienstra, Yuri takhteyev and Waylan limberg @@ -8,7 +8,7 @@ Author-email: waylan.limberg@icloud.com Maintainer: Waylan Limberg Maintainer-email: waylan.limberg@icloud.com License: BSD License -Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-3.2-py2.py3-none-any.whl +Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-3.2.1-py2.py3-none-any.whl Description: This is a Python implementation of John Gruber's Markdown_. It is almost completely compliant with the reference implementation, diff --git a/PKG-INFO b/PKG-INFO index 3455bb3..9526d2b 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: Markdown -Version: 3.2 +Version: 3.2.1 Summary: Python implementation of Markdown. Home-page: https://Python-Markdown.github.io/ Author: Manfred Stienstra, Yuri takhteyev and Waylan limberg @@ -8,7 +8,7 @@ Author-email: waylan.limberg@icloud.com Maintainer: Waylan Limberg Maintainer-email: waylan.limberg@icloud.com License: BSD License -Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-3.2-py2.py3-none-any.whl +Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-3.2.1-py2.py3-none-any.whl Description: This is a Python implementation of John Gruber's Markdown_. It is almost completely compliant with the reference implementation, diff --git a/docs/change_log/index.md b/docs/change_log/index.md index 9d17a42..62fe4b2 100644 --- a/docs/change_log/index.md +++ b/docs/change_log/index.md @@ -3,6 +3,11 @@ title: Change Log Python-Markdown Change Log ========================= +Feb 12, 2020: Released version 3.2.1 (a bug-fix release). + +* The `name` property in `toc_tokens` from the TOC extension now + escapes HTML special characters (`<`, `>`, and `&`). + Feb 7, 2020: Released version 3.2 ([Notes](release-3.2.md)). May 20, 2019: Released version 3.1.1 (a bug-fix release). diff --git a/markdown/__meta__.py b/markdown/__meta__.py index ec83f15..ead7c31 100644 --- a/markdown/__meta__.py +++ b/markdown/__meta__.py @@ -31,7 +31,7 @@ except ImportError: # (1, 2, 0, 'beta', 2) => "1.2b2" # (1, 2, 0, 'rc', 4) => "1.2rc4" # (1, 2, 0, 'final', 0) => "1.2" -__version_info__ = (3, 2, 0, 'final', 0) +__version_info__ = (3, 2, 1, 'final', 0) def _get_version(): # pragma: no cover diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index dc80c7e..8f2b13f 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -15,7 +15,7 @@ License: [BSD](https://opensource.org/licenses/bsd-license.php) from . import Extension from ..treeprocessors import Treeprocessor -from ..util import parseBoolValue, AMP_SUBSTITUTE, HTML_PLACEHOLDER_RE +from ..util import code_escape, parseBoolValue, AMP_SUBSTITUTE, HTML_PLACEHOLDER_RE from ..postprocessors import UnescapePostprocessor import re import unicodedata @@ -264,7 +264,8 @@ class TocTreeprocessor(Treeprocessor): 'level': int(el.tag[-1]), 'id': el.attrib["id"], 'name': unescape(stashedHTML2text( - el.attrib.get('data-toc-label', text), self.md, strip_entities=False + code_escape(el.attrib.get('data-toc-label', text)), + self.md, strip_entities=False )) }) diff --git a/tests/test_extensions.py b/tests/test_extensions.py index c787886..8ecbe0d 100644 --- a/tests/test_extensions.py +++ b/tests/test_extensions.py @@ -827,6 +827,25 @@ class TestTOC(TestCaseWithAssertStartsWith): {'level': 1, 'id': 'foo-bar', 'name': 'Foo & bar', 'children': []}, ]) + def testHtmlSpecialChars(self): + """ Test Headers with HTML special characters. """ + text = '# Foo > & bar' + self.assertEqual( + self.md.convert(text), + '

Foo > & bar

' + ) + self.assertEqual( + self.md.toc, + '
\n' + '\n' # noqa + '
\n' + ) + self.assertEqual(self.md.toc_tokens, [ + {'level': 1, 'id': 'foo-bar', 'name': 'Foo > & bar', 'children': []}, + ]) + def testRawHtml(self): """ Test Headers with raw HTML. """ text = '# Foo Bar Baz.' @@ -1000,27 +1019,31 @@ class TestTOC(TestCaseWithAssertStartsWith): md = markdown.Markdown(extensions=['toc', 'attr_list']) text = ('# Header 1\n\n' '## Header 2 { #foo }\n\n' - '## Header 3 { data-toc-label="Foo Bar"}\n\n' - '# Header 4 { data-toc-label="Foo Baz" }') + '## Header 3 { data-toc-label="Foo Bar" }\n\n' + '# Header 4 { data-toc-label="Foo > Baz" }\n\n' + '# Header 5 { data-toc-label="Foo Quux" }') + self.assertEqual( md.convert(text), '

Header 1

\n' '

Header 2

\n' '

Header 3

\n' - '

Header 4

' + '

Header 4

\n' + '

Header 5

' ) self.assertEqual( md.toc, '
\n' - '\n' # noqa + '\n' # noqa '
\n' ) self.assertEqual(md.toc_tokens, [ @@ -1028,7 +1051,8 @@ class TestTOC(TestCaseWithAssertStartsWith): {'level': 2, 'id': 'foo', 'name': 'Header 2', 'children': []}, {'level': 2, 'id': 'header-3', 'name': 'Foo Bar', 'children': []} ]}, - {'level': 1, 'id': 'header-4', 'name': 'Foo Baz', 'children': []}, + {'level': 1, 'id': 'header-4', 'name': 'Foo > Baz', 'children': []}, + {'level': 1, 'id': 'header-5', 'name': 'Foo Quux', 'children': []}, ]) def testUniqueFunc(self): -- 2.34.1