private boolean parseSource ( HttpMessage message , Source source , int depth , String baseURL ) { log . debug ( "Parsing an HTML message..." ) ; boolean resourcesfound = false ; // Process A elements List < Element > elements = source . getAllElements ( HTMLElementName . A ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "href" ) ; } // Process AREA elements elements = source . getAllElements ( HTMLElementName . AREA ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "href" ) ; } // Process Frame Elements elements = source . getAllElements ( HTMLElementName . FRAME ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "src" ) ; } // Process IFrame Elements elements = source . getAllElements ( HTMLElementName . IFRAME ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "src" ) ; } // Process Link elements elements = source . getAllElements ( HTMLElementName . LINK ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "href" ) ; } // Process Script elements with src elements = source . getAllElements ( HTMLElementName . SCRIPT ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "src" ) ; } // Process Img elements elements = source . getAllElements ( HTMLElementName . IMG ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "src" ) ; } // Process META elements elements = source . getAllElements ( HTMLElementName . META ) ; for ( Element el : elements ) { // If we have http-equiv attribute, then urls can be found. String equiv = el . getAttributeValue ( "http-equiv" ) ; String content = el . getAttributeValue ( "content" ) ; if ( equiv != null && content != null ) { // For the following cases: // http-equiv="refresh" content="0;URL=http://foo.bar/..." // http-equiv="location" content="url=http://foo.bar/..." if ( equiv . equalsIgnoreCase ( "refresh" ) || equiv . equalsIgnoreCase ( "location" ) ) { Matcher matcher = urlPattern . matcher ( content ) ; if ( matcher . find ( ) ) { String url = matcher . group ( 1 ) ; processURL ( message , depth , url , baseURL ) ; resourcesfound = true ; } } } } return resourcesfound ; }
Parses the HTML Jericho source for the elements that contain references to other resources .