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

HTML tags inside image alt shouldn't be parsed #896

Closed
nschonni opened this issue Sep 11, 2022 · 10 comments
Closed

HTML tags inside image alt shouldn't be parsed #896

nschonni opened this issue Sep 11, 2022 · 10 comments

Comments

@puzrin
Copy link
Member

puzrin commented Sep 11, 2022

CM Dingus https://spec.commonmark.org/dingus/?text=%23%20Issue%20579%0A%0A!%5Btext%20%3Ctextarea%3E%20text%5D(image.png)%0A

As far as i remember, tags are parsed in alt, but ignored later for security reasons.

@nschonni
Copy link
Author

Found a relevant discussion commonmark/commonmark-spec#716 but there is no resolution right now

@puzrin
Copy link
Member

puzrin commented Oct 21, 2022

Let's close this as spec-related. When reference parser updates behaviour, that will be reflected here.

@puzrin puzrin closed this as completed Oct 21, 2022
@nschonni
Copy link
Author

The reference parser already has this behaviour as you showed in the dingus link

@puzrin puzrin reopened this Oct 21, 2022
@nschonni
Copy link
Author

Thanks for re-opening!
It is definitely under-speced, but one where this is doing something different than remark, so there are conflicts between Prettier (that uses remark) and Markdownlint that uses this library

@rlidwka
Copy link
Member

rlidwka commented Nov 10, 2022

The reference parser already has this behaviour as you showed in the dingus link

Which reference parser?

This is commonmark.js (javascript):

$ echo '![text <textarea> text](image.png)' | /home/user/commonmark.js/bin/commonmark
<p><img src="image.png" alt="text <textarea> text" /></p>

This is cmark (C):

$ echo '![text <textarea> text](image.png)' | /home/user/cmark/build/src/cmark
<p><img src="image.png" alt="text &lt;textarea&gt; text" /></p>

This is commonmark-hs (haskell):

$ echo '![text <textarea> text](image.png)' | /home/user/.local/bin/commonmark
<p><img src="image.png" alt="text  text" /></p>

This behavior is absolutely trivial to fix, but maybe people should first agree on how to fix it.

@puzrin
Copy link
Member

puzrin commented Nov 19, 2023

This is pending too long. Need to decide something

} else if (tokens[i].type === 'image') {
- blocking this feature via renderer patch is quite easy. But I agree, such behaviour can be very unexpected for ordinary use. Probably, it would be better add option and disable that by default.

Could you suggest short and verbose option name? Something like imageAttrHtml but more pretty.

@DavidAnson
Copy link

Just to be clear, it seems to me that of the options above, "text <textarea> text" is the least surprising result (and therefore the best choice in my mind). Is that what you are suggesting to make the default?

@puzrin
Copy link
Member

puzrin commented Nov 19, 2023

My proposal is to disable HTML in image attrs by default (except commonmark mode). So, by default < and > in text <textarea> text will be escaped.

@puzrin
Copy link
Member

puzrin commented Dec 6, 2023

Solved in master

@puzrin puzrin closed this as completed Dec 6, 2023
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

4 participants