summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-10-27 19:37:27 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-28 09:24:50 (GMT)
commit1f3218e086778a0e324542a00937cd44e8e10c79 (patch)
treed1d3813e330f8e0144ee003a7e6b68079ff6ea29 /src/gui/text/qtextdocument.cpp
parentde7de35082ec21d506a90e68cb30888540ec64cc (diff)
downloadQt-1f3218e086778a0e324542a00937cd44e8e10c79.zip
Qt-1f3218e086778a0e324542a00937cd44e8e10c79.tar.gz
Qt-1f3218e086778a0e324542a00937cd44e8e10c79.tar.bz2
Qt::escape(): also escape the quote (&quot;)
This amend previous commit by removing the duplicate function. The quote need to be escaped in attributes. Reviewed-by: Thomas Zander
Diffstat (limited to 'src/gui/text/qtextdocument.cpp')
-rw-r--r--src/gui/text/qtextdocument.cpp27
1 files changed, 5 insertions, 22 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 17981e3..6978b6c 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -140,7 +140,7 @@ bool Qt::mightBeRichText(const QString& text)
/*!
Converts the plain text string \a plain to a HTML string with
- HTML metacharacters \c{<}, \c{>}, and \c{&} replaced by HTML
+ HTML metacharacters \c{<}, \c{>}, \c{&}, and \c{"} replaced by HTML
entities.
Example:
@@ -162,23 +162,6 @@ QString Qt::escape(const QString& plain)
rich += QLatin1String("&gt;");
else if (plain.at(i) == QLatin1Char('&'))
rich += QLatin1String("&amp;");
- else
- rich += plain.at(i);
- }
- return rich;
-}
-
-static QString escapeXml(const QString &plain)
-{
- QString rich;
- rich.reserve(int(plain.length() * 1.1));
- for (int i = 0; i < plain.length(); ++i) {
- if (plain.at(i) == QLatin1Char('<'))
- rich += QLatin1String("&lt;");
- else if (plain.at(i) == QLatin1Char('>'))
- rich += QLatin1String("&gt;");
- else if (plain.at(i) == QLatin1Char('&'))
- rich += QLatin1String("&amp;");
else if (plain.at(i) == QLatin1Char('"'))
rich += QLatin1String("&quot;");
else
@@ -2057,7 +2040,7 @@ void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &valu
html += QLatin1Char(' ');
html += QLatin1String(attribute);
html += QLatin1String("=\"");
- html += escapeXml(value);
+ html += Qt::escape(value);
html += QLatin1Char('"');
}
@@ -2326,7 +2309,7 @@ void QTextHtmlExporter::emitFontFamily(const QString &family)
quote = QLatin1String("&quot;");
html += quote;
- html += escapeXml(family);
+ html += Qt::escape(family);
html += quote;
html += QLatin1Char(';');
}
@@ -2360,13 +2343,13 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment)
const QString name = format.anchorName();
if (!name.isEmpty()) {
html += QLatin1String("<a name=\"");
- html += escapeXml(name);
+ html += Qt::escape(name);
html += QLatin1String("\"></a>");
}
const QString href = format.anchorHref();
if (!href.isEmpty()) {
html += QLatin1String("<a href=\"");
- html += escapeXml(href);
+ html += Qt::escape(href);
html += QLatin1String("\">");
closeAnchor = true;
}