Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\! is being bleached to ?33? for a reason I can't understand. #4

Open
Asday opened this issue May 19, 2018 · 3 comments
Open

\! is being bleached to ?33? for a reason I can't understand. #4

Asday opened this issue May 19, 2018 · 3 comments

Comments

@Asday
Copy link

Asday commented May 19, 2018

Python 3.6.5 (default, Mar 29 2018, 03:28:50) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import markdown
>>> from mdx_bleach.extension import BleachExtension
>>> bleach = BleachExtension()
>>> md = markdown.Markdown(extensions=[bleach])
>>> md.convert('\\!')
'<p>?33?</p>'
>>> md_no_bleach = markdown.Markdown()
>>> md_no_bleach.convert('\\!')
'<p>!</p>'
>>> import bleach
>>> bleach.clean('\\!')
'\\!'
>>> bleach.__version__
'2.1.3'
>>> markdown.__version__.version
'2.6.11'
>>> import mdx_bleach
>>> mdx_bleach.VERSION
'0.1.2'
>>> 

As demonstrated, the issue only occurs when using this extension, but looking over the code I can't figure out why.

@Wenzil
Copy link
Owner

Wenzil commented May 19, 2018

After some testing I found this was caused by a breaking change in Bleach 2.0.

I published a new release that freezes the bleach dependency to versions below 2.0 and it seems to have fixed it. Try reinstalling mdx_bleach and let me know if it works

@Asday
Copy link
Author

Asday commented May 19, 2018

Thank you.

I trust you that it does, but I would argue that that's not the best solution. Bleach being a security library; forcing users to be on an old version seems bad.

@Wenzil
Copy link
Owner

Wenzil commented May 19, 2018

Good point, I'll revert the change I made.

Here's a link to the downstream breaking change. It's not documenting very well the reason behind it though. I suggest asking them about it.

https://bleach.readthedocs.io/en/latest/changes.html#version-2-0-march-8th-2017

bleach.clean and friends were rewritten

clean was reimplemented as an html5lib filter and happens at a different step in the HTML parsing -> traversing -> serializing process. Because of that, there are some differences in clean’s output as compared with previous versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants