the behavior of tags-starting-with-alpha-/-! was not like that of the reference implementation; fixed (in a very script-kiddy leaky fashion which I can't resolve with a runtime flag thanks to the 32 bit flags field in the 2.x series :-(

This commit is contained in:
david parsons
2022-10-04 11:49:20 -07:00
parent 10c99d3a64
commit 376656c77c
4 changed files with 26 additions and 39 deletions
+17 -30
View File
@@ -1046,49 +1046,36 @@ process_possible_link(MMIOT *f, int size)
static int
maybe_tag_or_link(MMIOT *f)
{
int c, size;
int maybetag = 1;
int c, size=0;
if ( is_flag_set(&f->flags, MKD_TAGTEXT) )
return 0;
for ( size=0; (c = peek(f, size+1)) != '>'; size++) {
if ( c == EOF )
return 0;
else if ( c == '\\' ) {
maybetag=0;
if ( peek(f, size+2) != EOF )
size++;
}
else if ( isspace(c) )
break;
else if ( ! (c == '/'
|| (is_flag_set(&f->flags, MKD_GITHUBTAGS) && (c == '-' || c == '_'))
|| isalnum(c) ) )
maybetag=0;
}
c = peek(f, 1);
if ( size ) {
if ( maybetag || (size >= 3 && strncmp(cursor(f), "!--", 3) == 0) ) {
/* It is not a html tag unless we find the closing '>' in
* the same block.
*/
while ( (c = peek(f, size+1)) != '>' )
if ( isalpha(c) || c == '/' || c == '!' ) {
/* By decree of Markdown.pl *this is a tag* */
while ( (c=peek(f,size+1)) != '>' )
if ( c == EOF )
return 0;
else
size++;
}
if ( size > 0 ) {
if ( process_possible_link(f, size) ) {
shift(f, size+1);
return 1;
}
else {
int i;
if ( forbidden_tag(f) )
return 0;
Qchar('<', f);
while ( ((c = peek(f, 1)) != EOF) && (c != '>') )
Qchar(pull(f), f);
return 1;
}
else if ( !isspace(c) && process_possible_link(f, size) ) {
for ( i=0; i <= size+1; i++ )
Qchar(peek(f, i), f);
shift(f, size+1);
return 1;
}
+4 -4
View File
@@ -13,11 +13,11 @@ try 'http:foo/bar' '<http:foo/bar>' '<p><a href="http:foo/bar">http:foo/bar<
try '</foo/bar>' '</foo/bar>' '<p></foo/bar></p>'
match '<orc@pell.portland.or.us>' '<orc@pell.portland.or.us>' '<a href='
match '<orc@pell.com.>' '<orc@pell.com.>' '<a href='
try 'invalid <orc@>' '<orc@>' '<p>&lt;orc@></p>'
try 'invalid <orc@>' '<orc@>' '<p><orc@></p>'
try 'invalid <@pell>' '<@pell>' '<p>&lt;@pell></p>'
try 'invalid <orc@pell>' '<orc@pell>' '<p>&lt;orc@pell></p>'
try 'invalid <orc@.pell>' '<orc@.pell>' '<p>&lt;orc@.pell></p>'
try 'invalid <orc@pell.>' '<orc@pell.>' '<p>&lt;orc@pell.></p>'
try 'invalid <orc@pell>' '<orc@pell>' '<p><orc@pell></p>'
try 'invalid <orc@.pell>' '<orc@.pell>' '<p><orc@.pell></p>'
try 'invalid <orc@pell.>' '<orc@pell.>' '<p><orc@pell.></p>'
match '<mailto:orc@pell>' '<mailto:orc@pell>' '<a href='
match '<mailto:orc@pell.com>' '<mailto:orc@pell.com>' '<a href='
match '<mailto:orc@>' '<mailto:orc@>' '<a href='
+3 -3
View File
@@ -7,9 +7,9 @@ MARKDOWN_FLAGS=
SRC='<element-name>content</element-name>'
try 'github tags disabled by default' \
"$SRC" \
'<p>&lt;element-name>content&lt;/element-name></p>'
# try 'github tags disabled by default' \
# "$SRC" \
# '<p>&lt;element-name>content&lt;/element-name></p>'
try -fgithubtags 'github tags' \
"$SRC" \
+2 -2
View File
@@ -105,7 +105,7 @@ try 'id_000177_06' '<dl
</d>00000</p>'
try 'id_000182_06' '<p></>-' '<p><p></>-</p>'
try 'id_000189_06' '<ol></o>#0' '<p><ol></o>#0</p>'
try 'id_000190_06' '<p/</>*' '<p>&lt;p/</>*</p>'
try 'id_000190_06' '<p/</>*' '<p><p/</>*</p>'
try 'id_000192_06' '<div </di>*' '<p><div </di>*</p>'
try 'id_000197_06' '<ul></u
>0' '<p><ul>&lt;/u</p>
@@ -120,7 +120,7 @@ try 'id_000209_06' '<!--
-->00000</p>'
try 'id_000211_06' '<p></>+' '<p><p></>+</p>'
try 'id_000219_06' '<!-->*' '<p><!-->*</p>'
try 'id_000222_06' '<p/</>-' '<p>&lt;p/</>-</p>'
try 'id_000222_06' '<p/</>-' '<p><p/</>-</p>'
try -ftabstop 'id_000223_06' '<!--
-->00000' '<p><!--
-->00000</p>'