Skip to content

Commit 7296b95

Browse files
committed
Refined the test crawler a bit, to avoid extracting URLs to follow
from html outside the datatracker's control, such as uploaded WG agendas. Also excempted some pages with known-bad character issues from html validation, and refined the error reporting for html validation failures. - Legacy-Id: 13027
1 parent 53481ee commit 7296b95

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

bin/test-crawl

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def check_html_valid(url, response, args):
155155
if not key in validated_urls:
156156
note('Validate: %-32s: %s' % (url[:32], key))
157157
# These URLs have known issues, skip them until those are fixed
158-
if re.search('(/secr|admin/)|/doc/.*/edit/info/', url):
158+
if re.search('(/secr|admin/|/doc/.*/edit/info/|rfc542$|rfc776$|draft-leroux-pce-pcecp-interarea-reqs)', url):
159159
log("%s blacklisted; skipping HTML validation" % url)
160160
validated_urls[key] = True
161161
return
@@ -183,14 +183,21 @@ def check_html_valid(url, response, args):
183183
else:
184184
try:
185185
parser.parse(content)
186-
except Exception:
187-
e = SyntaxWarning("ParseError")
186+
except Exception as e:
188187
for err in parser.errors:
189188
pos, code, data = err
190-
tags.append(u"WARN invalid html: Position %s: %s" %
191-
(pos, code))
189+
tags.append(u"WARN invalid html at line, pos %s: %s" % (pos, e))
192190
warnings += 1
193191

192+
def skip_extract_from(url):
193+
for pattern in (
194+
r'^/doc/html/[a-z0-9-]+',
195+
r'^/meeting/[a-z0-9-]+/agenda/[a-z0-9-]+',
196+
):
197+
if re.search(pattern, url):
198+
return True
199+
return False
200+
194201
def skip_url(url):
195202
for pattern in (
196203
"^/community/[0-9]+/remove_document/",
@@ -201,11 +208,14 @@ def skip_url(url):
201208
# This bad url occurs in an uploaded html agenda:
202209
r"/site/ietfdhcwg/_/rsrc/1311005436000/system/app/css/overlay.css\?cb=simple100%250150goog-ws-left",
203210
r"/dir/tsvdir/reviews/",
211+
r"draft-touch-msword-template-v2\.0",
204212
):
205213
if re.search(pattern, url):
206214
return True
207215
return False
208216

217+
218+
209219
def log(s):
210220
print(s)
211221
if logfile:
@@ -350,10 +360,11 @@ if __name__ == "__main__":
350360

351361
if ctype == "text/html":
352362
try:
353-
for u in extract_html_urls(r.content):
354-
if u not in visited and u not in urls:
355-
urls[u] = url
356-
referrers[u] = url
363+
if not skip_extract_from(url):
364+
for u in extract_html_urls(r.content):
365+
if u not in visited and u not in urls:
366+
urls[u] = url
367+
referrers[u] = url
357368

358369
check_html_valid(url, r, args)
359370

0 commit comments

Comments
 (0)