Commit 267e82dfdcc3ceb7b3caae521b8b4eb7c097eb5b

Martin Mitas 2019-05-16T22:59:45

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.

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 {