1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 18:26:34 +01:00

OpenSearchReader: Fixed parsing files with XML declaration

This commit is contained in:
nowrep 2013-11-10 12:27:05 +01:00
parent d1f0b1776a
commit 605ce133e1
2 changed files with 18 additions and 4 deletions

View File

@ -26,6 +26,7 @@ Version 1.5.0
* fixed: loading plugins with relative paths in portable build
* fixed: displaying a lot of RSS feeds in RSS widget in locationbar
* fixed: enabling disabled rules in AdBlock now works everytime
* fixed: parsing OpenSearch files with XML declaration
Version 1.4.4
* released 1 September 2013

View File

@ -99,16 +99,29 @@ OpenSearchEngine* OpenSearchReader::read()
OpenSearchEngine* engine = new OpenSearchEngine();
m_searchXml = device()->peek(1024 * 5);
while (!isStartElement() && !atEnd()) {
readNext();
}
if (!m_searchXml.contains(QLatin1String("http://a9.com/-/spec/opensearch/1.1/")) &&
!m_searchXml.contains(QLatin1String("http://www.mozilla.org/2006/browser/search/"))) {
raiseError(QObject::tr("The file is not an OpenSearch 1.1 file."));
return engine;
}
// It just skips the XML declaration
// The parsing code bellow for some reason doesn't like it -,-
int index = m_searchXml.indexOf(QLatin1String("<?xml"));
if (index > 0) {
int end = m_searchXml.indexOf(QLatin1String("?>"), index);
if (end > 0) {
device()->read(end + 2);
}
}
while (!isStartElement() && !atEnd()) {
readNext();
}
while (!atEnd()) {
readNext();