[nanny] Custom black/white urls are regexps now
- From: Roberto Majadas <telemaco src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nanny] Custom black/white urls are regexps now
- Date: Sun, 6 Mar 2011 18:30:35 +0000 (UTC)
commit 668632e6dae271dcc7c3827419ff563507b2dcd7
Author: Roberto Majadas <roberto majadas openshine com>
Date: Sun Mar 6 19:30:13 2011 +0100
Custom black/white urls are regexps now
daemon/src/FilterManager.py | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/daemon/src/FilterManager.py b/daemon/src/FilterManager.py
index d168b0e..1933746 100644
--- a/daemon/src/FilterManager.py
+++ b/daemon/src/FilterManager.py
@@ -680,7 +680,12 @@ class FilterManager (gobject.GObject) :
custom_black=False
#Search in customfilters
- sql_query = 'select distinct is_black from customfilters where uid="%s" and gregexp( "(.+\.|)" || regexp || ".*" , "%s")' % (uid, domain)
+ sub_query = '('
+ sub_query += ' gregexp( "(.+\.|)" || regexp || ".*" , "%s") ' % (domain)
+ sub_query += ' or gregexp( "(.+\.|)" || regexp || ".*" , "%s") ' % ('http://' + domain)
+ sub_query += ')'
+
+ sql_query = 'select distinct is_black from customfilters where uid="%s" and %s ' % (uid, sub_query)
query = self.custom_filters_db.runQuery(sql_query)
block_d = BlockingDeferred(query)
try:
@@ -793,6 +798,30 @@ class FilterManager (gobject.GObject) :
print 'Uri Validation stopped because domain is blocked, %s' % (host + request.uri)
return False, request, rest, host, port
+ #Search in customfilters
+ sub_query = '('
+ sub_query += ' gregexp( "(.+\.|)" || regexp || ".*" , "%s") ' % (host + request.uri)
+ sub_query += ' or gregexp( "(.+\.|)" || regexp || ".*" , "%s") ' % ('http://' + host + request.uri)
+ sub_query += ')'
+
+ sql_query = 'select distinct is_black from customfilters where uid="%s" and %s ' % (uid, sub_query)
+ query = self.custom_filters_db.runQuery(sql_query)
+ block_d = BlockingDeferred(query)
+ try:
+ qr = block_d.blockOn()
+ if len(qr) > 0 :
+ for x in qr :
+ if x[0] == 0:
+ print 'Uri Custom filter Whitelist %s' % (host + request.uri)
+ return True, request, rest, host, port
+ if x[0] == 1:
+ print 'Uri Custom filter Blacklist %s' % (host + request.uri)
+ return False, request, rest, host, port
+
+ except:
+ print "Something goes wrong checking Custom Filters (check_url)"
+ return True, request, rest, host, port
+
if pre_check[1] == False :
print 'Uri validation verified in pre-check %s' % (host + request.uri)
return True, request, rest, host, port
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]