Commit 2cb4f23f37948f79c49a53efaf049f872ab5bcc7

Martin Mitas 2024-01-22T09:14:58

md_collect_marks: Improve pre-test for '.'.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/md4c.c b/src/md4c.c
index 98cdd8f..710c059 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -3245,7 +3245,9 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, int n_lines, int table_mode)
 
             /* A potential permissive WWW autolink. */
             if(ch == _T('.')) {
-                if(line->beg + 3 <= off  &&  md_ascii_eq(STR(off-3), _T("www"), 3)) {
+                if(line->beg + 3 <= off  &&  md_ascii_eq(STR(off-3), _T("www"), 3)  &&
+                   (off-3 == line->beg || ISUNICODEWHITESPACEBEFORE(off-3) || ISUNICODEPUNCTBEFORE(off-3)))
+                {
                     ADD_MARK(ch, off-3, off+1, MD_MARK_POTENTIAL_OPENER);
                     /* Push a dummy as a reserve for a closer. */
                     ADD_MARK('D', line->beg, line->end, 0);