From 859f388ee33735d8287c5a7d2ff8b2afc9cdc2c5 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Wed, 5 Sep 2012 09:58:29 -0400 Subject: [PATCH] Fix bug when page contains unicode. --- toolserver/copyvios/checker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolserver/copyvios/checker.py b/toolserver/copyvios/checker.py index ca05651..63b891c 100644 --- a/toolserver/copyvios/checker.py +++ b/toolserver/copyvios/checker.py @@ -34,7 +34,7 @@ def get_results(bot, site, query): def _get_cached_results(page, conn): query1 = "DELETE FROM cache WHERE cache_time < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 DAY)" query2 = "SELECT cache_url, cache_time, cache_queries, cache_process_time FROM cache WHERE cache_id = ? AND cache_hash = ?" - shahash = sha256(page.get()).hexdigest() + shahash = sha256(page.get().encode("utf8")).hexdigest() with conn.cursor() as cursor: cursor.execute(query1) @@ -62,7 +62,7 @@ def _format_date(cache_time): def _cache_result(page, result, conn): pageid = page.pageid - shahash = sha256(page.get()).hexdigest() + shahash = sha256(page.get().encode("utf8")).hexdigest() query1 = "SELECT 1 FROM cache WHERE cache_id = ?" query2 = "DELETE FROM cache WHERE cache_id = ?" query3 = "INSERT INTO cache VALUES (?, ?, ?, CURRENT_TIMESTAMP, ?, ?)"