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

Regression in unescaping backslash in attribute #1358

Closed
oprypin opened this issue Jul 18, 2023 · 2 comments · Fixed by #1359
Closed

Regression in unescaping backslash in attribute #1358

oprypin opened this issue Jul 18, 2023 · 2 comments · Fixed by #1359
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code.

Comments

@oprypin
Copy link
Contributor

oprypin commented Jul 18, 2023

Regression in 3.4 - c0f6e5a is the first bad commit

Reproduction code:

import markdown

s = r'''
<img src="..\..\foo.png">
'''
print(repr(markdown.markdown(s)))

Output before vs after:

'<p><img src="..\\..\\foo.png"></p>'
'<p><img src="..\\\x0246\x03.\\foo.png"></p>'
@waylan
Copy link
Member

waylan commented Jul 19, 2023

This is definitely a bug. The final output should not still contain placeholders. Thank you for the report.

However, even if that is resolved, the input still has a problem. Consider the simple input \.. That would correctly output <p>.</p>. Notice that the backslash is removed; which is the correct behavior as the escape character should not be in the final output. However, in a URL ..\ has a specific meaning and the backslash should remain in the output. Therefore, the document author should escape the backslash: ..\\. Although, it appears that that is not currently working correctly either.

I will note that as a workaround, the document author can use forward slashes instead. The only system which uses backslashes is the DOS/Windows local file system, and most browsers will translate from forward slashes to backward slashes properly. Of course, that's not an excuse for the bug, but it does avoid the escaping issue altogether.

...and I just realized this issue is specific to raw HTML. We shouldn't be altering the raw HTML at all.

@waylan waylan added bug Bug report. core Related to the core parser code. confirmed Confirmed bug report or approved feature request. labels Jul 19, 2023
waylan added a commit to waylan/markdown that referenced this issue Jul 19, 2023
waylan added a commit that referenced this issue Jul 19, 2023
@oprypin
Copy link
Contributor Author

oprypin commented Jul 19, 2023

Thanks for the quick fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants