From ca09caa15dd34e0cb3e6c3419dd2db8d90c9c2ad Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Mon, 14 Jul 2014 01:44:50 -0400 Subject: [PATCH] Give an error when no text could be found inside a URL. --- copyvios/checker.py | 6 +++++- templates/index.mako | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/copyvios/checker.py b/copyvios/checker.py index fe27f86..5f8c169 100644 --- a/copyvios/checker.py +++ b/copyvios/checker.py @@ -41,7 +41,11 @@ def _get_results(query): if urlparse(query.url).scheme not in ["http", "https"]: query.error = "bad URI" return - query.result = page.copyvio_compare(query.url) + result = page.copyvio_compare(query.url) + if result.source_chain is page.EMPTY: + query.error = "no data" + return + query.result = result query.result.cached = False else: conn = get_cache_db() diff --git a/templates/index.mako b/templates/index.mako index 150d839..bd7d2fe 100644 --- a/templates/index.mako +++ b/templates/index.mako @@ -7,6 +7,10 @@

Unsupported URI scheme: ${query.url | h}.

+ % elif query.error == "no data": +
+

Couldn't find any text in ${query.url | h}. Note: only HTML and plain text pages are supported, and content generated by JavaScript or found inside iframes is ignored.

+
% elif not query.site:

The given site (project=${query.project | h}, language=${query.lang | h}) doesn't seem to exist. It may also be closed or private. Confirm its URL.