summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-04-10 09:35:41 +0200
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-04-10 14:58:42 +0300
commit4fb458c9e739283c5d77bff67d08dcba935d6984 (patch)
treeecc7050595ef9439e037ec381c6a0b7f9c2c5a23
parent97a8806417af7ed048d7dd0f2ea07098d64bd99f (diff)
downloadqt-creator-4fb458c9e739283c5d77bff67d08dcba935d6984.tar.gz
Fix parsing of encoded xml attributes
If an xml attribute contains an entity parsing it failed due to missing decoding. This patch decodes entities holding (hexa-)decimal entities. This is especially necessary for files (or paths) containing some special characters that might end up encoded inside the output that would be generated by running the tests. Change-Id: I4f3b9f9edc59ff1433b92ed4ce1933eaf29ffe74 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
-rw-r--r--plugins/autotest/testxmloutputreader.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/plugins/autotest/testxmloutputreader.cpp b/plugins/autotest/testxmloutputreader.cpp
index d8b3400d6b..8d0fa72235 100644
--- a/plugins/autotest/testxmloutputreader.cpp
+++ b/plugins/autotest/testxmloutputreader.cpp
@@ -20,7 +20,7 @@
#include "testxmloutputreader.h"
#include "testresult.h"
-#include <QXmlStreamReader>
+#include <QRegExp>
#include <QProcess>
#include <QFileInfo>
#include <QDir>
@@ -28,6 +28,25 @@
namespace Autotest {
namespace Internal {
+static QString decode(const QString& original)
+{
+ QString result(original);
+ static QRegExp regex(QLatin1String("&#((x[0-9A-F]+)|([0-9]+));"), Qt::CaseInsensitive);
+ regex.setMinimal(true);
+
+ int pos = 0;
+ while ((pos = regex.indexIn(original, pos)) != -1) {
+ const QString value = regex.cap(1);
+ if (value.startsWith(QLatin1Char('x')))
+ result.replace(regex.cap(0), QChar(value.mid(1).toInt(0, 16)));
+ else
+ result.replace(regex.cap(0), QChar(value.toInt(0, 10)));
+ pos += regex.matchedLength();
+ }
+
+ return result;
+}
+
static bool xmlStartsWith(const QString &code, const QString &start, QString &result)
{
if (code.startsWith(start)) {
@@ -57,7 +76,7 @@ static bool xmlExtractTypeFileLine(const QString &code, const QString &tagStart,
result = TestResult::resultFromString(
code.mid(start, code.indexOf(QLatin1Char('"'), start) - start));
start = code.indexOf(QLatin1String(" file=\"")) + 7;
- file = code.mid(start, code.indexOf(QLatin1Char('"'), start) - start);
+ file = decode(code.mid(start, code.indexOf(QLatin1Char('"'), start) - start));
start = code.indexOf(QLatin1String(" line=\"")) + 7;
line = code.mid(start, code.indexOf(QLatin1Char('"'), start) - start).toInt();
return true;