diff options
author | albert-github <albert.tests@gmail.com> | 2021-01-29 18:13:03 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2021-01-29 18:13:03 (GMT) |
commit | 3d6df187044d03c28c5ed5d1be2f0a6b53f59b51 (patch) | |
tree | a7cf32715a99cb870151bd9254da1831caa86ecf /src | |
parent | 6a7201851a1667da40b4e2a1cf7b481c2d386803 (diff) | |
download | Doxygen-3d6df187044d03c28c5ed5d1be2f0a6b53f59b51.zip Doxygen-3d6df187044d03c28c5ed5d1be2f0a6b53f59b51.tar.gz Doxygen-3d6df187044d03c28c5ed5d1be2f0a6b53f59b51.tar.bz2 |
issue_8362 Text of image repeated 4 times
In case we have in markdown image definition like:
```
!["Image 1"](img/structure.png)
```
This would result, besides the image in the text:
```
Image 1""Image 1""Image 1""Image 1""
```
due to the fact that besides the HTML image also the image code for other output formats (latex, rtf, docbook) was written and the double quote was not escaped properly.
Diffstat (limited to 'src')
-rw-r--r-- | src/markdown.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp index 2bc8206..b9fad70 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -213,6 +213,26 @@ inline int isNewline(const char *data) return 0; } +// escape double quotes in string +static QCString escapeDoubleQuotes(const QCString &s) +{ + TRACE(s.data()); + if (s.isEmpty()) return ""; + GrowBuf growBuf; + const char *p=s; + char c,pc='\0'; + while ((c=*p++)) + { + switch (c) + { + case '"': if (pc!='\\') { growBuf.addChar('\\'); } growBuf.addChar(c); break; + default: growBuf.addChar(c); break; + } + pc=c; + } + growBuf.addChar(0); + return growBuf.get(); +} // escape characters that have a special meaning later on. static QCString escapeSpecialChars(const QCString &s) { @@ -775,13 +795,13 @@ void Markdown::writeMarkdownImage(const char *fmt, bool explicitTitle, if (!explicitTitle && !content.isEmpty()) { m_out.addStr(" \""); - m_out.addStr(content); + m_out.addStr(escapeDoubleQuotes(content)); m_out.addStr("\""); } else if ((content.isEmpty() || explicitTitle) && !title.isEmpty()) { m_out.addStr(" \""); - m_out.addStr(title); + m_out.addStr(escapeDoubleQuotes(title)); m_out.addStr("\""); } else |