diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-01-13 11:59:36 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-01-13 11:59:36 +0200 |
commit | c14195a0a2e6f9b234cdc247507c2609943498c5 (patch) | |
tree | fa77e74ac4dca4978fa2fe74ae0dfcfbd90c461d | |
parent | 89963368ae5560ffb2a3f00ccdc80a6b218cc608 (diff) | |
download | cmdtest-c14195a0a2e6f9b234cdc247507c2609943498c5.tar.gz |
Fix: undo HTML escaping of code blocks
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | htmlesc.scenario | 13 | ||||
-rwxr-xr-x | yarn.tests/htmlescape.script | 5 | ||||
-rw-r--r-- | yarnlib/mdparser.py | 5 |
4 files changed, 24 insertions, 1 deletions
@@ -6,6 +6,8 @@ This file summarizes changes between releases of cmdtest. Version 0.32+git, not yet released ---------------------------------- +* Undo HTML escaping of code blocks done by the Python Markdown + parser. Version 0.32, released 2018-02-24 ---------------------------------- diff --git a/htmlesc.scenario b/htmlesc.scenario new file mode 100644 index 0000000..cb80865 --- /dev/null +++ b/htmlesc.scenario @@ -0,0 +1,13 @@ +An HTML escaping scenario +========================= + +Test HTML escapes in IMPLEMENTS code. At some point after Debian 9 was +released, the Python markdown library yarn uses started to HTML escape +code blocks. This breaks any shell scripts that use redirection. Make +sure this works. + + SCENARIO html escaping + THEN greet + + IMPLEMENTS THEN greet + echo hello > /dev/null diff --git a/yarn.tests/htmlescape.script b/yarn.tests/htmlescape.script new file mode 100755 index 0000000..b3a7840 --- /dev/null +++ b/yarn.tests/htmlescape.script @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eu + +./run-yarn htmlesc.scenario diff --git a/yarnlib/mdparser.py b/yarnlib/mdparser.py index 4bd59d3..67851ec 100644 --- a/yarnlib/mdparser.py +++ b/yarnlib/mdparser.py @@ -17,6 +17,7 @@ import logging +import HTMLParser import markdown import StringIO from markdown.treeprocessors import Treeprocessor @@ -40,10 +41,12 @@ class GatherCodeBlocks(Treeprocessor): self.blocks = blocks def run(self, root): + h = HTMLParser.HTMLParser() for child in root.getchildren(): if child.tag == 'pre': code = child.find('code') - self.blocks.append(code.text) + text = h.unescape(code.text) + self.blocks.append(text) return root # This is the Python Markdown extension to call the code block |