bz#1305739, Unescaped percent sign in doxygen

This commit is contained in:
Than Ngo 2016-03-06 11:17:24 +01:00
parent 505fc881f4
commit ef93c1ed7e
2 changed files with 18 additions and 189 deletions

View File

@ -1,187 +1,13 @@
diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp
index c748162..526ed49 100644
--- a/src/docbookvisitor.cpp
+++ b/src/docbookvisitor.cpp
@@ -81,7 +81,7 @@ void DocbookDocVisitor::visit(DocSymbol *s)
}
else
{
- err("DocBook: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
+ err("DocBook: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
}
}
diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp
index 647007b..f6878b9 100644
--- a/src/htmldocvisitor.cpp
+++ b/src/htmldocvisitor.cpp
@@ -190,7 +190,7 @@ void HtmlDocVisitor::visit(DocSymbol *s)
}
else
{
- err("HTML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
+ err("HTML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
}
}
diff --git a/src/htmlentity.cpp b/src/htmlentity.cpp
index 7f07b57..c7ff1da 100644
--- a/src/htmlentity.cpp
+++ b/src/htmlentity.cpp
@@ -354,23 +354,41 @@ void HtmlEntityMapper::deleteInstance()
/*! @brief Access routine to the UTF8 code of the HTML entity
*
* @param symb Code of the requested HTML entity
+ * @param useInPrintf If TRUE the result will be escaped such that it can be
+ * used in a printf string pattern
* @return the UTF8 code of the HTML entity,
* in case the UTF code is unknown \c NULL is returned.
*/
-const char *HtmlEntityMapper::utf8(DocSymbol::SymType symb) const
+const char *HtmlEntityMapper::utf8(DocSymbol::SymType symb,bool useInPrintf) const
{
- return g_htmlEntities[symb].UTF8;
+ if (useInPrintf && symb==DocSymbol::Sym_Percent)
+ {
+ return "%%"; // escape for printf
+ }
+ else
+ {
+ return g_htmlEntities[symb].UTF8;
+ }
}
/*! @brief Access routine to the html code of the HTML entity
*
- * @param symb Code of the requested HTML entity
- * @return the html of the HTML entity,
+ * @param symb Code of the requested HTML entity
+ * @param useInPrintf If TRUE the result will be escaped such that it can be
+ * used in a printf string pattern
+ * @return the html representation of the HTML entity,
* in case the html code is unknown \c NULL is returned.
*/
-const char *HtmlEntityMapper::html(DocSymbol::SymType symb) const
+const char *HtmlEntityMapper::html(DocSymbol::SymType symb,bool useInPrintf) const
{
- return g_htmlEntities[symb].html;
+ if (useInPrintf && symb==DocSymbol::Sym_Percent)
+ {
+ return "%%"; // escape for printf
+ }
+ else
+ {
+ return g_htmlEntities[symb].html;
+ }
}
/*! @brief Access routine to the XML code of the HTML entity
diff --git a/src/htmlentity.h b/src/htmlentity.h
index b92eb1d..9cebeb3 100644
--- a/src/htmlentity.h
+++ b/src/htmlentity.h
@@ -27,8 +27,8 @@ class HtmlEntityMapper
static HtmlEntityMapper *instance();
static void deleteInstance();
DocSymbol::SymType name2sym(const QCString &symName) const;
- const char *utf8(DocSymbol::SymType symb) const;
- const char *html(DocSymbol::SymType symb) const;
+ const char *utf8(DocSymbol::SymType symb,bool useInPrintf=FALSE) const;
+ const char *html(DocSymbol::SymType symb,bool useInPrintf=FALSE) const;
const char *xml(DocSymbol::SymType symb) const;
const char *docbook(DocSymbol::SymType symb) const;
const char *latex(DocSymbol::SymType symb) const;
diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp
index c2c884b..aefcac3 100644
--- a/src/latexdocvisitor.cpp
+++ b/src/latexdocvisitor.cpp
@@ -154,7 +154,7 @@ void LatexDocVisitor::visit(DocSymbol *s)
}
else
{
- err("LaTeX: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
+ err("LaTeX: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
}
}
diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp
index 276313c..7fa0153 100644
--- a/src/perlmodgen.cpp
+++ b/src/perlmodgen.cpp
@@ -606,7 +606,7 @@ void PerlModDocVisitor::visit(DocSymbol *sy)
}
else
{
- err("perl: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(sy->symbol()));
+ err("perl: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(sy->symbol(),TRUE));
}
}
diff --git a/src/printdocvisitor.h b/src/printdocvisitor.h
index 7a077e9..ee4104e 100644
--- a/src/printdocvisitor.h
+++ b/src/printdocvisitor.h
@@ -57,21 +57,14 @@ class PrintDocVisitor : public DocVisitor
void visit(DocSymbol *s)
{
indent_leaf();
- const char *res = HtmlEntityMapper::instance()->utf8(s->symbol());
+ const char *res = HtmlEntityMapper::instance()->utf8(s->symbol(),TRUE);
if (res)
{
- if (qstrcmp(res,"%")==0)
- {
- printf("%%");
- }
- else
- {
- printf("%s",res);
- }
+ printf("%s",res);
}
else
{
- printf("print: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
+ printf("print: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
}
}
void visit(DocURL *u)
diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp
index 2b60d5b..05c8247 100644
--- a/src/rtfdocvisitor.cpp
+++ b/src/rtfdocvisitor.cpp
@@ -129,7 +129,7 @@ void RTFDocVisitor::visit(DocSymbol *s)
}
else
{
- err("RTF: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
+ err("RTF: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
}
m_lastIsPara=FALSE;
}
diff --git a/src/textdocvisitor.cpp b/src/textdocvisitor.cpp
index a313b0a..6f3151f 100644
--- a/src/textdocvisitor.cpp
+++ b/src/textdocvisitor.cpp
@@ -33,7 +33,7 @@ void TextDocVisitor::visit(DocSymbol *s)
}
else
{
- err("text: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
+ err("text: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
}
}
diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp
index 27c8bb9..b906fc1 100644
--- a/src/xmldocvisitor.cpp
+++ b/src/xmldocvisitor.cpp
@@ -78,7 +78,7 @@ void XmlDocVisitor::visit(DocSymbol *s)
}
else
{
- err("XML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
+ err("XML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
}
}
diff -up doxygen-1.8.11/src/util.cpp.than doxygen-1.8.11/src/util.cpp
--- doxygen-1.8.11/src/util.cpp.than 2016-03-06 11:13:21.831912181 +0100
+++ doxygen-1.8.11/src/util.cpp 2016-03-06 11:15:20.359280738 +0100
@@ -6732,6 +6732,9 @@ QCString latexEscapePDFString(const char
case '\\': t << "\\textbackslash{}"; break;
case '{': t << "\\{"; break;
case '}': t << "\\}"; break;
+ case '_': t << "\\_"; break;
+ case '%': t << "\\%"; break;
+ case '&': t << "\\&"; break;
default:
t << c;
break;

View File

@ -2,7 +2,7 @@ Summary: A documentation system for C/C++
Name: doxygen
Epoch: 1
Version: 1.8.11
Release: 3%{?dist}
Release: 4%{?dist}
# No version is specified.
License: GPL+
@ -64,7 +64,7 @@ Requires: texlive-epstopdf-bin
%prep
%setup -q
%patch1 -p1 -R
patch1 -p1
# convert into utf-8
iconv --from=ISO-8859-1 --to=UTF-8 LANGUAGE.HOWTO > LANGUAGE.HOWTO.new
@ -120,6 +120,9 @@ desktop-file-install \
%changelog
* Sun Mar 06 2016 Than Ngo <than@redhat.com> - 1:1.8.11-4
- bz#1305739, Unescaped percent sign in doxygen
* Mon Feb 22 2016 Than Ngo <than@redhat.com> - 1:1.8.11-3
- fix bz#1305739, Unescaped percent sign in doxygen