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

Escape sequences in links are not unescaped #3166

Closed
AndreasMadsen opened this issue Jan 18, 2024 · 1 comment
Closed

Escape sequences in links are not unescaped #3166

AndreasMadsen opened this issue Jan 18, 2024 · 1 comment

Comments

@AndreasMadsen
Copy link

Marked version:
v11.1.1

Describe the bug
Hi, thanks for providing a great package.

It looks like escape sequences in links are not unescaped. Different Markdown renders treat this edge case slightly different. For example, GitHub does not unescape, but VS Code and CommonMark does unescape. As it's unusual to have a \ in a link, but common to have \., I think it will be safe to always unescaped.

This is likely a duplicate of #829. But this was closed and moved to the consolidation issue #984, and then never fixed. Hence, I'm posting this with a clear test case.

Thanks again.

To Reproduce

import { marked } from 'marked';
import { equal } from 'node:assert/strict'

const escaped = "Link must have the format: https://youtu\\.be/\\_\\_"
const expected = '<p>Link must have the format: <a href="https://youtu.be/__">https://youtu.be/__</a></p>\n'

equal(marked.parse(escaped), expected);
  1. Marked Demo
  2. CommonMark Demo

Expected behavior

Actual output: Link must have the format: https://youtu\.be/\_\_
Expected output: Link must have the format: https://youtu.be/__.

@AndreasMadsen
Copy link
Author

Oh, I now realize this happens because GitHub flavor is the default. Sorry for the noise.

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

1 participant