rpms/kdelibs/devel kdelibs-4.3.3-adFilteredBy.patch, NONE, 1.1 kdelibs.spec, 1.525, 1.526
Kevin Kofler
kkofler at fedoraproject.org
Thu Nov 5 23:36:45 UTC 2009
Author: kkofler
Update of /cvs/pkgs/rpms/kdelibs/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv1430/devel
Modified Files:
kdelibs.spec
Added Files:
kdelibs-4.3.3-adFilteredBy.patch
Log Message:
* Thu Nov 05 2009 Kevin Kofler <Kevin at tigcc.ticalc.org> - 4.3.3-2
- backport adFilteredBy API from trunk, required to build konq-plugins-4.3.3
kdelibs-4.3.3-adFilteredBy.patch:
khtml_filter.cpp | 30 +++++++++++++++++++++++++++++-
khtml_filter_p.h | 10 ++++++----
khtml_settings.cpp | 21 +++++++++++++++++++++
khtml_settings.h | 16 ++++++++++++++++
4 files changed, 72 insertions(+), 5 deletions(-)
--- NEW FILE kdelibs-4.3.3-adFilteredBy.patch ---
Index: khtml/khtml_settings.h
===================================================================
--- khtml/khtml_settings.h (revision 1027233)
+++ khtml/khtml_settings.h (revision 1027234)
@@ -186,7 +186,23 @@
bool isPluginsEnabled( const QString& hostname = QString() ) const;
// AdBlocK Filtering
+
+ /** tests whether @p url is filtered.
+ * @param url the URL to test.
+ * @return @c true if the URL is blacklisted and is not whitelisted.
+ */
bool isAdFiltered( const QString &url ) const;
+
+ /** identify the filter which matches @p url.
+ * @param url the URL to test.
+ * @param isWhiteListed if not @c NULL, set to @c true if the URL matched
+ * a whitelist filter; set to @c false if it matched a blacklist filter.
+ * @return the filter string that matched,
+ * or @c QString() if no filter matched.
+ * @since 4.4
+ */
+ QString adFilteredBy( const QString &url, bool *isWhiteListed = 0 ) const;
+
bool isAdFilterEnabled() const;
bool isHideAdsEnabled() const;
void addAdFilter( const QString &url );
Index: khtml/khtml_filter_p.h
===================================================================
--- khtml/khtml_filter_p.h (revision 1027233)
+++ khtml/khtml_filter_p.h (revision 1027234)
@@ -35,8 +35,9 @@
// add filter to matching set
void addString(const QString& pattern);
- // check if string match at least one string from matching set
- bool isMatched(const QString& str) const;
+ // check if string matches at least one string from matching set,
+ // optionally return the matching string or filter
+ bool isMatched(const QString& str, QString *by = 0) const;
// add filter to matching set with wildcards (*,?) in it
void addWildedString(const QString& prefix, const QRegExp& rx);
@@ -60,9 +61,10 @@
// Parses and registers a filter. This will also strip @@ for exclusion rules, skip comments, etc.
// The user does have to split black and white lists into separate sets, however
void addFilter(const QString& filter);
-
+
bool isUrlMatched(const QString& url);
-
+ QString urlMatchedBy(const QString& url);
+
void clear();
private:
Index: khtml/khtml_settings.cpp
===================================================================
--- khtml/khtml_settings.cpp (revision 1027233)
+++ khtml/khtml_settings.cpp (revision 1027234)
@@ -743,6 +743,27 @@
return false;
}
+QString KHTMLSettings::adFilteredBy( const QString &url, bool *isWhiteListed ) const
+{
+ QString m = d->adWhiteList.urlMatchedBy(url);
+ if (!m.isEmpty())
+ {
+ if (isWhiteListed != 0)
+ *isWhiteListed = true;
+ return (m);
+ }
+
+ m = d->adBlackList.urlMatchedBy(url);
+ if (!m.isEmpty())
+ {
+ if (isWhiteListed != 0)
+ *isWhiteListed = false;
+ return (m);
+ }
+
+ return (QString());
+}
+
void KHTMLSettings::addAdFilter( const QString &url )
{
KConfigGroup config = KSharedConfig::openConfig( "khtmlrc", KConfig::NoGlobals )->group( "Filter Settings" );
Index: khtml/khtml_filter.cpp
===================================================================
--- khtml/khtml_filter.cpp (revision 1027233)
+++ khtml/khtml_filter.cpp (revision 1027234)
@@ -133,6 +133,25 @@
return false;
}
+QString FilterSet::urlMatchedBy(const QString& url)
+{
+ QString by;
+
+ if (stringFiltersMatcher.isMatched(url, &by))
+ return by;
+
+ for (int c = 0; c < reFilters.size(); ++c)
+ {
+ if (url.contains(reFilters[c]))
+ {
+ by = reFilters[c].pattern();
+ break;
+ }
+ }
+
+ return by;
+}
+
void FilterSet::clear()
{
reFilters.clear();
@@ -196,12 +215,15 @@
}
}
-bool StringsMatcher::isMatched(const QString& str) const
+bool StringsMatcher::isMatched(const QString& str, QString *by) const
{
// check short strings first
for (int i = 0; i < shortStringFilters.size(); ++i) {
if (str.contains(shortStringFilters[i]))
+ {
+ if (by != 0) *by = shortStringFilters[i];
return true;
+ }
}
int len = str.length();
@@ -235,13 +257,19 @@
if (index >= 0) {
int flen = stringFilters[index].length();
if (k - flen + 1 >= 0 && stringFilters[index] == str.midRef(k - flen + 1 , flen))
+ {
+ if (by != 0) *by = stringFilters[index];
return true;
+ }
} else {
index = -index - 1;
int flen = rePrefixes[index].length();
if (k - 8 + flen < len && rePrefixes[index] == str.midRef(k - 7, flen) &&
str.indexOf(reFilters[index], k - 7 + flen) == k - 7 + flen)
+ {
+ if (by != 0) *by = rePrefixes[index]+reFilters[index].pattern();
return true;
+ }
}
}
}
Index: kdelibs.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kdelibs/devel/kdelibs.spec,v
retrieving revision 1.525
retrieving revision 1.526
diff -u -p -r1.525 -r1.526
--- kdelibs.spec 31 Oct 2009 13:10:43 -0000 1.525
+++ kdelibs.spec 5 Nov 2009 23:36:43 -0000 1.526
@@ -4,7 +4,7 @@
Summary: K Desktop Environment 4 - Libraries
Version: 4.3.3
-Release: 1%{?dist}
+Release: 2%{?dist}
Name: kdelibs
Epoch: 6
@@ -78,7 +78,10 @@ Patch22: kdelibs-4.3.0-bookmarks.patch
Patch24: kdelibs-4.3.1-drkonq.patch
# upstream
-# 4.3 branch
+# 4.4 trunk
+# http://websvn.kde.org/?view=revision&revision=1027234
+# add adFilteredBy API required for konq-plugins-4.3.3 to build
+Patch100: kdelibs-4.3.3-adFilteredBy.patch
# security fix
Patch200: kdelibs-4.3.1-CVE-2009-2702.patch
@@ -198,7 +201,8 @@ format for easy browsing.
%endif
# upstream patches
-# 4.3
+# 4.4
+%patch100 -p0 -b .adFilteredBy
# security fix
%patch200 -p1 -b .CVE-2009-2702
@@ -391,6 +395,9 @@ rm -rf %{buildroot}
%changelog
+* Thu Nov 05 2009 Kevin Kofler <Kevin at tigcc.ticalc.org> - 4.3.3-2
+- backport adFilteredBy API from trunk, required to build konq-plugins-4.3.3
+
* Fri Oct 30 2009 Rex Dieter <rdieter at fedoraproject.org> - 4.3.3-1
- 4.3.3
More information about the fedora-extras-commits
mailing list