--- a/WebBrowser/AdBlock/AdBlockSubscription.py Mon Mar 14 20:48:01 2016 +0100 +++ b/WebBrowser/AdBlock/AdBlockSubscription.py Tue Mar 15 19:47:54 2016 +0100 @@ -16,7 +16,7 @@ from PyQt5.QtCore import pyqtSignal, Qt, QObject, QByteArray, QDateTime, \ QUrl, QUrlQuery, QCryptographicHash, QFile, QIODevice, QTextStream, \ - QDate, QTime, qVersion + QDate, QTime from PyQt5.QtNetwork import QNetworkReply from E5Gui import E5MessageBox @@ -412,28 +412,31 @@ .file(fileName)) return - # ToDo:AdBlock debug this from WebBrowser.WebBrowserWindow import WebBrowserWindow if WebBrowserWindow.adBlockManager().useLimitedEasyList() and \ self.url().toString().startswith( WebBrowserWindow.adBlockManager().getDefaultSubscriptionUrl()): + limited = True # ignore Third-party advertisers rules for performance # whitelist rules at the end will be used - part1 = response.left(response.indexOf( + index = response.indexOf( "!---------------------------" "Third-party advertisers" - "---------------------------!")) - part2 = response.mid(response.indexOf( + "---------------------------!") + part1 = response.left(index) + index = response.indexOf( "!-----------------------" "Whitelists to fix broken sites" - "------------------------!")) + "------------------------!") + part2 = response.mid(index) f.write(part1) f.write(part2) else: + limited = False f.write(response) f.close() self.__lastUpdate = QDateTime.currentDateTime() - if self.__validateCheckSum(fileName): + if limited or self.__validateCheckSum(fileName): self.__loadRules() else: QFile.remove(fileName) @@ -446,8 +449,9 @@ @param fileName name of the file containing the subscription (string) @return flag indicating a valid file (boolean). A file is considered - valid, if the checksum is OK or the file does not contain a - checksum (i.e. cannot be checked). + valid, if the checksum is OK, the file does not contain a + checksum (i.e. cannot be checked) or we are using the limited + EasyList (because we fiddled with the original). """ try: f = open(fileName, "r", encoding="utf-8")