yuin / goldmark

:trophy: A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.
MIT License
3.68k stars 255 forks source link

Linkify extension doesn't match hosts that start with single-letter domain label #190

Closed moorereason closed 3 years ago

moorereason commented 3 years ago

Google's g.page hostname is not being matched by the Linkify extension.

Example rendering by Github in this issue editor: https://g.page/foo

Originally reported by a Hugo user, but this is an issue with goldmark.

Questionaire:

1. What version of goldmark are you using? :

master (c4b3054802054bacb6445f3af7ce2d0fbbaaea1f)

2. What version of Go are you using? :

go1.16rc1

3. What operating system and processor architecture are you using? :

linux/amd64

4. What did you do? :

diff --git a/extension/_test/linkify.txt b/extension/_test/linkify.txt
index d619a8b..134f52b 100644
--- a/extension/_test/linkify.txt
+++ b/extension/_test/linkify.txt
@@ -169,3 +169,11 @@ http://server.intranet.acme.com:1313
 //- - - - - - - - -//
 <p><a href="http://server.intranet.acme.com:1313">http://server.intranet.acme.com:1313</a></p>
 //= = = = = = = = = = = = = = = = = = = = = = = =//
+
+
+17
+//- - - - - - - - -//
+https://g.page/foo
+//- - - - - - - - -//
+<p><a href="https://g.page/foo">https://g.page/foo</a></p>
+//= = = = = = = = = = = = = = = = = = = = = = = =//

5. What did you expect to see? :

passing test

6. What did you see instead? :

--- FAIL: TestLinkify (0.00s)
    testutil.go:176: ============= case 17 ================
        Markdown:
        -----------
        https://g.page/foo

        Expected:
        ----------
        <p><a href="https://g.page/foo">https://g.page/foo</a></p>

        Actual
        ---------
        <p>https://g.page/foo</p>

7. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?:

Linkify extension not part of CommonMark spec.

cmosetick commented 3 years ago

@moorereason Thank you for chasing this rendering issue to Linkify extension! I guessed a while back that goldmark was the source of the single character TLD issue, but was not able to find the actual source at the time. So I just created the issue in the hugo issue tracker as a starting point.

I honestly was not sure if it was a single character TLD issue, or an issue with .page TLD. Nice find!