Commit 4fb458c9 authored by Christian Stenger's avatar Christian Stenger
Browse files

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: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 97a88064
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment