mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
756 stars 138 forks source link

tests/normalize.py failing #123

Closed protoCall7 closed 3 years ago

protoCall7 commented 3 years ago

Hello,

I am in the process of porting md4c release 0.4.4 to OpenBSD, and noticed that the test infrastructure is generating stack traces with every test:

image

I am including the following patch in our package, which seems to make the tests run as intended:

$OpenBSD$

Index: test/normalize.py
--- test/normalize.py.orig
+++ test/normalize.py
@@ -14,6 +14,7 @@ from html.entities import name2codepoint
 import sys
 import re
 import cgi
+import html

 # Normalization code, adapted from
 # https://github.com/karlcow/markdown-testsuite/
@@ -66,7 +67,7 @@ class MyHTMLParser(HTMLParser):
                     self.output += ("=" + '"' +
                             urllib.quote(urllib.unquote(v), safe='/') + '"')
                 elif v != None:
-                    self.output += ("=" + '"' + cgi.escape(v,quote=True) + '"')
+                    self.output += ("=" + '"' + html.escape(v,quote=True) + '"')
         self.output += ">"
         self.last_tag = tag
         self.last = "starttag"

I wanted to make you aware that we were going to be carrying a patch. If you would prefer me to work around the broken tests in a different manner, please let me know.

Thanks!

mity commented 3 years ago

Thanks, applied to the upstream (with also removing the now bogus import cgi line).

mity commented 3 years ago

If you would prefer me to work around the broken tests in a different manner, please let me know.

I'll happily leave all packaging burden completely on your shoulders, so anything what serves your purpose :-)

protoCall7 commented 3 years ago

Thanks for the quick response @mity! I've now dropped the include cgi in my patch as well. Once the next version is released, I'll remove the patch all together.