Node node = e.nextNode();
// a url is always in a Tag.
if (!(node instanceof Tag)) {
continue;
}
Tag tag = (Tag) node;
String tagname=tag.getTagName();
String binUrlStr = null;
// first we check to see if body tag has a
// background set
if (tag instanceof BodyTag) {
binUrlStr = tag.getAttribute(ATT_BACKGROUND);
} else if (tag instanceof BaseHrefTag) {
BaseHrefTag baseHref = (BaseHrefTag) tag;
String baseref = baseHref.getBaseUrl();
try {
if (!baseref.equals(""))// Bugzilla 30713
{
baseUrl.url = ConversionUtils.makeRelativeURL(baseUrl.url, baseref);
}
} catch (MalformedURLException e1) {
throw new HTMLParseException(e1);
}
} else if (tag instanceof ImageTag) {
ImageTag image = (ImageTag) tag;
binUrlStr = image.getImageURL();
} else if (tag instanceof AppletTag) {
// look for applets
// This will only work with an Applet .class file.
// Ideally, this should be upgraded to work with Objects (IE)
// and archives (.jar and .zip) files as well.
AppletTag applet = (AppletTag) tag;
binUrlStr = applet.getAppletClass();
} else if (tag instanceof ObjectTag) {
// look for Objects
ObjectTag applet = (ObjectTag) tag;
String data = applet.getAttribute(ATT_CODEBASE);
if(!StringUtils.isEmpty(data)) {
binUrlStr = data;
}
data = applet.getAttribute(ATT_DATA);
if(!StringUtils.isEmpty(data)) {
binUrlStr = data;
}
} else if (tag instanceof InputTag) {
// we check the input tag type for image
if (ATT_IS_IMAGE.equalsIgnoreCase(tag.getAttribute(ATT_TYPE))) {
// then we need to download the binary
binUrlStr = tag.getAttribute(ATT_SRC);
}
} else if (tag instanceof ScriptTag) {
binUrlStr = tag.getAttribute(ATT_SRC);
// Bug 51750
} else if (tag instanceof FrameTag || tagname.equalsIgnoreCase(TAG_IFRAME)) {
binUrlStr = tag.getAttribute(ATT_SRC);
} else if (tagname.equalsIgnoreCase(TAG_EMBED)
|| tagname.equalsIgnoreCase(TAG_BGSOUND)){
binUrlStr = tag.getAttribute(ATT_SRC);
} else if (tagname.equalsIgnoreCase(TAG_LINK)) {
// Putting the string first means it works even if the attribute is null
if (STYLESHEET.equalsIgnoreCase(tag.getAttribute(ATT_REL))) {
binUrlStr = tag.getAttribute(ATT_HREF);
}
} else {
binUrlStr = tag.getAttribute(ATT_BACKGROUND);
}
if (binUrlStr != null) {
urls.addURL(binUrlStr, baseUrl.url);
}
// Now look for URLs in the STYLE attribute
String styleTagStr = tag.getAttribute(ATT_STYLE);
if(styleTagStr != null) {
HtmlParsingUtils.extractStyleURLs(baseUrl.url, urls, styleTagStr);
}
// second, if the tag was a composite tag,