Handle IDNs in API
This commit is contained in:
parent
8c8fd9c597
commit
2305220bc9
3
api.py
3
api.py
@ -38,7 +38,8 @@ def blocked(domain: str = None, reason: str = None):
|
|||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
if domain != None:
|
if domain != None:
|
||||||
wildchar = "*." + ".".join(domain.split(".")[-domain.count("."):])
|
wildchar = "*." + ".".join(domain.split(".")[-domain.count("."):])
|
||||||
c.execute("select blocker, block_level, reason from blocks where blocked = ? or blocked = ? or blocked = ? or blocked = ?", (domain, "*." + domain, wildchar, get_hash(domain)))
|
c.execute("select blocker, block_level, reason from blocks where blocked = ? or blocked = ? or blocked = ? or blocked = ? or blocked = ? or blocked = ?",
|
||||||
|
(domain, "*." + domain, wildchar, get_hash(domain), domain.encode('idna'), "*." + domain.encode('idna')))
|
||||||
else:
|
else:
|
||||||
c.execute("select * from blocks where reason like ? and reason != ''", ("%"+reason+"%",))
|
c.execute("select * from blocks where reason like ? and reason != ''", ("%"+reason+"%",))
|
||||||
blocks = c.fetchall()
|
blocks = c.fetchall()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user