Commits

Yu-Jie Lin committed 0ded5b0

fragment must be ASCII and the url has to return with text/html, or fragment isn't found.

Comments (0)

Files changed (2)

  * add `print_toplist` for a list of worse post/entry/etc
  * add HTML attribute `name` to search list of fragment and use regular expression to match
  * fix #1: url not checked when same url with fragment also being checked
+ * url with fragment has return text/html type or it will be `[###]`
+ * fragment now has to be valid ASCII or will not be found
 
 ## Version 0.1.1 (2013-02-15T12:07:09Z)
 

lnkckr/checkers/base.py

           method = 'GET'
         conn.request(method, p, headers=self.HEADERS)
         resp = conn.getresponse()
-        if resp.status == 200 and frags:
-          rbody = resp.read().decode('utf8')
+        if resp.status == 200 and frags != ('',):
+          # any non text/html result ### as such fragment isn't found
+          if not resp.getheader('Content-Type', '').startswith('text/html'):
+            status = '###'
+            break
+          # assume characters in fragment are valid ASCII
+          rbody = resp.read().decode('ascii', 'ignore')
           pairs = product(frags, (rbody,))
           statuses = tuple(map(self._check_url_frag, pairs))
           break