summaryrefslogtreecommitdiffstats
path: root/src/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 24e8898..f9c2492 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -5914,7 +5914,7 @@ QCString convertToId(const char *s)
}
/*! Converts a string to an XML-encoded string */
-QCString convertToXML(const char *s)
+QCString convertToXML(const char *s, bool keepEntities)
{
static GrowBuf growBuf;
growBuf.clear();
@@ -5927,7 +5927,30 @@ QCString convertToXML(const char *s)
{
case '<': growBuf.addStr("&lt;"); break;
case '>': growBuf.addStr("&gt;"); break;
- case '&': growBuf.addStr("&amp;"); break;
+ case '&': if (keepEntities)
+ {
+ const char *e=p;
+ char ce;
+ while ((ce=*e++))
+ {
+ if (ce==';' || (!(isId(ce) || ce=='#'))) break;
+ }
+ if (ce==';') // found end of an entity
+ {
+ // copy entry verbatim
+ growBuf.addChar(c);
+ while (p<e) growBuf.addChar(*p++);
+ }
+ else
+ {
+ growBuf.addStr("&amp;");
+ }
+ }
+ else
+ {
+ growBuf.addStr("&amp;");
+ }
+ break;
case '\'': growBuf.addStr("&apos;"); break;
case '"': growBuf.addStr("&quot;"); break;
case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: