Permalink
Browse files

Bug 772574 - __xxx__ not interpreted as markdown when xxx begins with…

… a non-word character (e.g. __-1__)
  • Loading branch information...
Dimitri van Heesch
Dimitri van Heesch committed Oct 17, 2016
1 parent 985faf2 commit a95c07ecc0a2f1205883d8420a8280c5701c901c
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/markdown.cpp
@@ -59,6 +59,11 @@
(data[i]>='0' && data[i]<='9') || \
(((unsigned char)data[i])>=0x80)) // unicode characters
#define extraChar(i) \
(data[i]=='-' || data[i]=='+' || data[i]=='!' || \
data[i]=='?' || data[i]=='$' || data[i]=='@' || \
data[i]=='&' || data[i]=='*' || data[i]=='%')
// is character at position i in data allowed before an emphasis section
#define isOpenEmphChar(i) \
(data[i]=='\n' || data[i]==' ' || data[i]=='\'' || data[i]=='<' || \
@@ -592,8 +597,8 @@ static int processHtmlTag(GrowBuf &out,const char *data,int offset,int size)
static int processEmphasis(GrowBuf &out,const char *data,int offset,int size)
{
if ((offset>0 && !isOpenEmphChar(-1)) || // invalid char before * or _
(size>1 && data[0]!=data[1] && !(isIdChar(1) || data[1]=='[')) || // invalid char after * or _
(size>2 && data[0]==data[1] && !(isIdChar(2) || data[2]=='['))) // invalid char after ** or __
(size>1 && data[0]!=data[1] && !(isIdChar(1) || extraChar(1) || data[1]=='[')) || // invalid char after * or _
(size>2 && data[0]==data[1] && !(isIdChar(2) || extraChar(2) || data[2]=='['))) // invalid char after ** or __
{
return 0;
}

0 comments on commit a95c07e

Please sign in to comment.