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

Invalid HTML with --fpermissive-url-autolinks #53

Closed
mitxela opened this issue Feb 9, 2019 · 3 comments
Closed

Invalid HTML with --fpermissive-url-autolinks #53

mitxela opened this issue Feb 9, 2019 · 3 comments
Labels

Comments

@mitxela
Copy link

mitxela commented Feb 9, 2019

With permissive-url-autolinks enabled, md2html appears to generate an extra closing tag after an ordinary inline link.

$ echo "This is a [link](http://github.com/)." | ./md2html
<p>This is a <a href="http://github.com/">link</a>.</p>

$ echo "This is a [link](http://github.com/)." | ./md2html --fpermissive-url-autolinks
<p>This is a <a href="http://github.com/">link</a></a>.</p>
@mity mity added the bug label Feb 9, 2019
@mity
Copy link
Owner

mity commented Feb 9, 2019

Thanks, will take a look at it.

@mity
Copy link
Owner

mity commented Feb 9, 2019

Interesting. The bug depends on the char just after the link.

When dot follows:

 $ echo '[link](http://github.com).' | md2html/md2html.exe --github
<p><a href="http://github.com">link</a></a>.</p>

When a letter follows, it's broken in a different way:

$ echo '[link](http://github.com)X' | md2html/md2html.exe --github
<p><a href="http://github.com">link</a>X</a></p>

And when space or EOF follows, it works correctly:

$ echo '[link](http://github.com) ' | md2html/md2html.exe --github
<p><a href="http://github.com">link</a></p>

@mity
Copy link
Owner

mity commented Feb 9, 2019

With permissive WWW autolinks, there is the same issue:

/prj/md4c/build $ echo '[link](www.github.com).' | md2html/md2html.exe --github
<p><a href="www.github.com">link</a></a>.</p>
/prj/md4c/build $ echo '[link](www.github.com)X' | md2html/md2html.exe --github
<p><a href="www.github.com">link</a>X</a></p>

@mity mity closed this as completed in d32aa2e Feb 9, 2019
ec1oud pushed a commit to ec1oud/md4c that referenced this issue Apr 17, 2019
The issues is caused by the fact that we do not know exact position
of permissive auto-link in time of md_collect_marks() because there
is no syntax to mark its end on the 1st place.

This causes that eventually, the closer mark in ctx->marks[] can be
out-of-order somewhat.

As a consequence, if some other mark range (e.g. ordinary link)
shadows the auto-link, the closer mark may be left outside the shadowed
range and survive till the phase when we generate the output.

We fix by using an extra mark flag to remember we did really output
the opener mark, and output the closer only in such case.

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

No branches or pull requests

2 participants