Fix regression when pasting into QTextEdit from Firefox.

Return the codec if one was found by QTextCodec::codecForUtfText,
instead of returning the default (UTF-8).

Task-number: QTBUG-31293

Change-Id: I95e3260376c00537006b7fbfdc3df5850e1ba657
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Mitch Curtis 2013-05-23 15:30:21 +02:00 committed by The Qt Project
parent 26ae24e20b
commit 964be00403
2 changed files with 14 additions and 1 deletions

View File

@ -1065,8 +1065,10 @@ QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba, QTextCodec *defaultCo
}
}
}
if (!c)
c = defaultCodec;
return defaultCodec;
return c;
}
/*!

View File

@ -1917,6 +1917,17 @@ void tst_QTextCodec::codecForHtml_data()
html = "<!DOCTYPE html><html><head><meta charset=\" utf' 8 /><title>Test</title></head>";
QTest::newRow("invalid charset, early terminator (')") << html << noDefault << fallback;
const char src[] = { char(0xff), char(0xfe), char(0x7a), char(0x03), 0, 0 };
html = src;
QTest::newRow("greek text UTF-16LE") << html << 106 << 1014;
html = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"><span style=\"color: rgb(0, 0, 0); font-family: "
"'Galatia SIL'; font-size: 27px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; "
"line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: "
"auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: "
"none;\">&#x37b</span>\000";
QTest::newRow("greek text UTF-8") << html << 106 << 106;
}
void tst_QTextCodec::codecForHtml()