QMimeDatabase: Fix magic rules with \t

\t was not interpreted as a tab character.

Task-number: QTBUG-44884
Change-Id: I3c733e227fba7e5fd5153df0ae4d0431903bb104
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
Reviewed-by: David Faure <david.faure@kdab.com>
bb10
Eike Ziller 2015-03-09 17:04:20 +01:00 committed by Shawn Rutledge
parent ed0c0070f9
commit 416438c2f3
2 changed files with 3 additions and 0 deletions

View File

@ -215,6 +215,8 @@ static inline QByteArray makePattern(const QByteArray &value)
*data++ = '\n';
} else if (*p == 'r') {
*data++ = '\r';
} else if (*p == 't') {
*data++ = '\t';
} else { // escaped
*data++ = *p;
}

View File

@ -460,6 +460,7 @@ void tst_QMimeDatabase::mimeTypeForData_data()
QTest::newRow("tnef data, needs smi >= 0.20") << QByteArray("\x78\x9f\x3e\x22") << "application/vnd.ms-tnef";
QTest::newRow("PDF magic") << QByteArray("%PDF-") << "application/pdf";
QTest::newRow("PHP, High-priority rule") << QByteArray("<?php") << "application/x-php";
QTest::newRow("diff\\t") << QByteArray("diff\t") << "text/x-patch";
QTest::newRow("unknown") << QByteArray("\001abc?}") << "application/octet-stream";
}