[tor-commits] [ooni-probe/master] Update HTTP URL list test to start comparison once it encounters an HTML tag

art at torproject.org art at torproject.org
Thu Nov 22 14:49:56 UTC 2012


commit 057cd86af90815696b115d93a96a8b720c49e4bf
Author: Arturo Filastò <art at fuffa.org>
Date:   Thu Nov 22 15:49:27 2012 +0100

    Update HTTP URL list test to start comparison once it encounters an HTML tag
---
 nettests/core/http_url_list.py |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/nettests/core/http_url_list.py b/nettests/core/http_url_list.py
index 358ab20..eeaaa35 100644
--- a/nettests/core/http_url_list.py
+++ b/nettests/core/http_url_list.py
@@ -53,10 +53,21 @@ class HTTPURLList(httpt.HTTPTest):
         """
         self.report['censored'] = True
 
-        censorship_page = open(self.localOptions['content'])
+        censorship_page = open(self.localOptions['content']).xreadlines()
         response_page = iter(body.split("\n"))
 
-        for censorship_line in censorship_page.xreadlines():
+        # We first allign the two pages to the first HTML tag (something
+        # starting with <). This is useful so that we can give as input to this
+        # test something that comes from the output of curl -kis
+        # http://the_page/
+        for line in censorship_page:
+            if line.strip().startswith("<"):
+                break
+        for line in response_page:
+            if line.strip().startswith("<"):
+                break
+
+        for censorship_line in censorship_page:
             try:
                 response_line = response_page.next()
             except StopIteration:



More information about the tor-commits mailing list