md_is_[hex|dec]_entity_contents: Fix maximal entity length. Spec. version 0.29 limits the decimal character length to at most 7 decimal digits and hexadecimal character length to at most 6 hexadecimal digits. Fixes #77.
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
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 817e717..bf9f1f2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
# MD4C Change Log
+## Next Version (Work in Progress)
+
+Fixes:
+ * [#77](https://github.com/mity/md4c/issues/77):
+ Fix maximal counts of digits for numerical character references, as requested
+ by CommonMark specification 0.29.
+
+
## Version 0.3.3
Changes:
diff --git a/md4c/md4c.c b/md4c/md4c.c
index 3070bf5..d86f8f5 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -1224,7 +1224,7 @@ md_is_hex_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, O
while(off < max_end && ISXDIGIT_(text[off]) && off - beg <= 8)
off++;
- if(1 <= off - beg && off - beg <= 8) {
+ if(1 <= off - beg && off - beg <= 6) {
*p_end = off;
return TRUE;
} else {
@@ -1240,7 +1240,7 @@ md_is_dec_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, O
while(off < max_end && ISDIGIT_(text[off]) && off - beg <= 8)
off++;
- if(1 <= off - beg && off - beg <= 8) {
+ if(1 <= off - beg && off - beg <= 7) {
*p_end = off;
return TRUE;
} else {