md_is_autolink_email: Fix an off-by-one error. Fixes #100.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d063d25..a83c44b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,10 @@ Fixes:
(This does not affect you unless you are on Windows and explicitly define
the macro when building MD4C.)
+ * [#100](https://github.com/mity/md4c/issues/100):
+ Fixed an off-by-one error in the maximal length limit of some segments
+ of e-mail addresses used in autolinks.
+
## Version 0.4.2
diff --git a/md4c/md4c.c b/md4c/md4c.c
index 8737eba..c84c18d 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -2900,7 +2900,7 @@ md_is_autolink_email(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end)
return FALSE;
off++;
- /* Labels delimited with '.'; each label is sequence of 1 - 62 alnum
+ /* Labels delimited with '.'; each label is sequence of 1 - 63 alnum
* characters or '-', but '-' is not allowed as first or last char. */
label_len = 0;
while(off < max_end) {
@@ -2913,7 +2913,7 @@ md_is_autolink_email(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end)
else
break;
- if(label_len > 62)
+ if(label_len > 63)
return FALSE;
off++;
diff --git a/test/coverage.txt b/test/coverage.txt
index 7847736..0ff1a2f 100644
--- a/test/coverage.txt
+++ b/test/coverage.txt
@@ -232,7 +232,6 @@ foo
### [Issue 97](https://github.com/mity/md4c/issues/97)
-
```````````````````````````````` example
*a **b c* d**
.
@@ -241,6 +240,22 @@ foo
````````````````````````````````
+### [Issue 100](https://github.com/mity/md4c/issues/100)
+
+```````````````````````````````` example
+<foo@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123>
+.
+<p><a href="mailto:foo@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123">foo@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123</a></p>
+````````````````````````````````
+
+```````````````````````````````` example
+<foo@123456789012345678901234567890123456789012345678901234567890123x.123456789012345678901234567890123456789012345678901234567890123>
+.
+<p><foo@123456789012345678901234567890123456789012345678901234567890123x.123456789012345678901234567890123456789012345678901234567890123></p>
+````````````````````````````````
+(Note the `x` here which turns it over the max. allowed length limit.)
+
+
## Code coverage
### `md_is_unicode_whitespace__()`