From a95c07ecc0a2f1205883d8420a8280c5701c901c Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Mon, 17 Oct 2016 21:49:17 +0200 Subject: Bug 772574 - __xxx__ not interpreted as markdown when xxx begins with a non-word character (e.g. __-1__) --- src/markdown.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/markdown.cpp b/src/markdown.cpp index d63e149..22e0d50 100644 --- a/src/markdown.cpp +++ b/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; } -- cgit v0.12