Skip to content

Commit

Permalink
In HTML the @image title did not appear as tooltip and quotes were no…
Browse files Browse the repository at this point in the history
…t properly escaped
  • Loading branch information
doxygen committed Dec 27, 2021
1 parent 618c596 commit 8df4e9f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
21 changes: 15 additions & 6 deletions src/htmldocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ static QCString htmlAttribsToString(const HtmlAttribList &attribs, QCString *pAl

HtmlDocVisitor::HtmlDocVisitor(TextStream &t,CodeOutputInterface &ci,
const Definition *ctx)
: DocVisitor(DocVisitor_Html), m_t(t), m_ci(ci), m_insidePre(FALSE),
m_hide(FALSE), m_ctx(ctx)
: DocVisitor(DocVisitor_Html), m_t(t), m_ci(ci), m_ctx(ctx)
{
if (ctx) m_langExt=ctx->getDefFileExtension();
}
Expand Down Expand Up @@ -319,14 +318,22 @@ void HtmlDocVisitor::visit(DocWhiteSpace *w)
void HtmlDocVisitor::visit(DocSymbol *s)
{
if (m_hide) return;
const char *res = HtmlEntityMapper::instance()->html(s->symbol());
if (res)
if (m_insideTitle &&
(s->symbol()==DocSymbol::Sym_Quot || s->symbol()==DocSymbol::Sym_quot)) // escape "'s inside title="..."
{
m_t << res;
m_t << "&quot;";
}
else
{
err("HTML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
const char *res = HtmlEntityMapper::instance()->html(s->symbol());
if (res)
{
m_t << res;
}
else
{
err("HTML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
}
}
}

Expand Down Expand Up @@ -1784,6 +1791,7 @@ void HtmlDocVisitor::visitPre(DocImage *img)
if (inlineImage)
{
m_t << " title=\"";
m_insideTitle=true;
}
else
{
Expand Down Expand Up @@ -1813,6 +1821,7 @@ void HtmlDocVisitor::visitPost(DocImage *img)
if (inlineImage)
{
m_t << "\"/>";
m_insideTitle=false;
}
else // end <div class="caption">
{
Expand Down
5 changes: 3 additions & 2 deletions src/htmldocvisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ class HtmlDocVisitor : public DocVisitor

TextStream &m_t;
CodeOutputInterface &m_ci;
bool m_insidePre;
bool m_hide;
bool m_insidePre = false;
bool m_hide = false;
bool m_insideTitle = false;
const Definition *m_ctx;
QCString m_langExt;
};
Expand Down
6 changes: 3 additions & 3 deletions src/markdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,11 +1291,11 @@ int Markdown::processLink(const char *data,int offset,int size)
}
else if (data[i]=='\\') // escaped char in string
{
i++;
i++;
}
else if (data[i]==c)
{
i++;
i++;
break;
}
i++;
Expand All @@ -1311,7 +1311,7 @@ int Markdown::processLink(const char *data,int offset,int size)
if (data[titleEnd]==c) // found it
{
convertStringFragment(title,data+titleStart,titleEnd-titleStart);
//printf("processLink: title={%s}\n",qPrint(title));
explicitTitle=TRUE;
while (i<size)
{
if (data[i]==' ')i++; // remove space after the closing quote and the closing bracket
Expand Down

2 comments on commit 8df4e9f

@doxygen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albert-github I found this while testing the fix for #8690

@albert-github
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would indeed make some sense to have the quoted part in the round brackets as tooltip, also seen what we see in https://spec.commonmark.org/0.30/#images

Please sign in to comment.