Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f3186e8

Browse files
committed
A number of improvements based on a discussion with Chris McCafferty
<[email protected]>: Add javascript: and telnet: to the types of URLs we ignore. Add support for several additional URL-valued attributes on the BODY, FRAME, IFRAME, LINK, OBJECT, and SCRIPT elements.
1 parent 33d2b84 commit f3186e8

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

Tools/webchecker/webchecker.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,9 @@ def getpage(self, url_pair):
481481
if self.name_table.has_key(url):
482482
return self.name_table[url]
483483

484-
if url[:7] == 'mailto:' or url[:5] == 'news:':
485-
self.note(1, " Not checking mailto/news URL")
484+
scheme = urllib.splittype(url)
485+
if scheme in ('mailto', 'news', 'javascript', 'telnet'):
486+
self.note(1, " Not checking %s URL" % scheme)
486487
return None
487488
isint = self.inroots(url)
488489

@@ -792,10 +793,31 @@ def end_a(self): pass
792793
def do_area(self, attributes):
793794
self.link_attr(attributes, 'href')
794795

796+
def do_body(self, attributes):
797+
self.link_attr(attributes, 'background')
798+
795799
def do_img(self, attributes):
796800
self.link_attr(attributes, 'src', 'lowsrc')
797801

798802
def do_frame(self, attributes):
803+
self.link_attr(attributes, 'src', 'longdesc')
804+
805+
def do_iframe(self, attributes):
806+
self.link_attr(attributes, 'src', 'longdesc')
807+
808+
def do_link(self, attributes):
809+
for name, value in attributes:
810+
if name == "rel":
811+
parts = string.split(string.lower(value))
812+
if ( parts == ["stylesheet"]
813+
or parts == ["alternate", "stylesheet"]):
814+
self.link_attr(attributes, "href")
815+
break
816+
817+
def do_object(self, attributes):
818+
self.link_attr(attributes, 'data', 'usemap')
819+
820+
def do_script(self, attributes):
799821
self.link_attr(attributes, 'src')
800822

801823
def link_attr(self, attributes, *args):

0 commit comments

Comments
 (0)