Bug 54629 - HTMLParser does not extract <object> tag urls

Bugzilla Id: 54629

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1451946 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: b8a912a15e
This commit is contained in:
Philippe Mouawad 2013-03-02 21:29:48 +00:00
parent 32b51d689e
commit 129abc4d59
5 changed files with 33 additions and 1 deletions

View File

@ -53,6 +53,7 @@ public abstract class HTMLParser {
protected static final String TAG_IMAGE = "img";// $NON-NLS-1$
protected static final String TAG_INPUT = "input";// $NON-NLS-1$
protected static final String TAG_LINK = "link";// $NON-NLS-1$
protected static final String TAG_OBJECT = "object";// $NON-NLS-1$
protected static final String TAG_SCRIPT = "script";// $NON-NLS-1$
protected static final String STYLESHEET = "stylesheet";// $NON-NLS-1$

View File

@ -22,6 +22,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.protocol.http.util.ConversionUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
@ -35,6 +36,7 @@ import org.htmlparser.tags.CompositeTag;
import org.htmlparser.tags.FrameTag;
import org.htmlparser.tags.ImageTag;
import org.htmlparser.tags.InputTag;
import org.htmlparser.tags.ObjectTag;
import org.htmlparser.tags.ScriptTag;
import org.htmlparser.util.NodeIterator;
import org.htmlparser.util.ParserException;
@ -146,6 +148,19 @@ class HtmlParserHTMLParser extends HTMLParser {
// 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("codebase");
if(!StringUtils.isEmpty(data)) {
binUrlStr = data;
}
data = applet.getAttribute("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))) {

View File

@ -23,6 +23,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.protocol.http.util.ConversionUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
@ -119,6 +120,20 @@ class JTidyHTMLParser extends HTMLParser {
urls.addURL(getValue(attrs, "code"), baseUrl);
break;
}
if (name.equalsIgnoreCase(TAG_OBJECT)) {
String data = getValue(attrs, "codebase");
if(!StringUtils.isEmpty(data)) {
urls.addURL(data, baseUrl);
}
data = getValue(attrs, "data");
if(!StringUtils.isEmpty(data)) {
urls.addURL(data, baseUrl);
}
break;
}
if (name.equalsIgnoreCase(TAG_INPUT)) {
String src = getValue(attrs, ATT_SRC);
String typ = getValue(attrs, ATT_TYPE);

View File

@ -98,7 +98,7 @@ class RegexpHTMLParser extends HTMLParser {
+ "|BASE" + SEP + "HREF" + VALUE
+ "|(?:IMG|SCRIPT|FRAME|IFRAME|BGSOUND)" + SEP + "SRC" + VALUE
+ "|APPLET" + SEP + "CODE(?:BASE)?" + VALUE
+ "|(?:EMBED|OBJECT)" + SEP + "(?:SRC|CODEBASE)" + VALUE
+ "|(?:EMBED|OBJECT)" + SEP + "(?:SRC|CODEBASE|DATA)" + VALUE
+ "|(?:BODY|TABLE|TR|TD)" + SEP + "BACKGROUND" + VALUE
+ "|[^<]+?STYLE\\s*=['\"].*?URL\\(\\s*['\"](.+?)['\"]\\s*\\)"
+ "|INPUT(?:" + SEP + "(?:SRC" + VALUE

View File

@ -94,6 +94,7 @@ This does not affect JMeter operation.
<li><bugzilla>54293</bugzilla> - JMeter rejects html tags '&lt;' in query params as invalid when they are accepted by the browser</li>
<li><bugzilla>54142</bugzilla> - HTTP Proxy Server throws an exception when path contains "|" character </li>
<li><bugzilla>54627</bugzilla> - JMeter Proxy GUI: Type of sampler settings takes the whole screen with when there are samplers with long name</li>
<li><bugzilla>54629</bugzilla> 54629 - HTMLParser does not extract &lt;object&gt; tag urls</li>
</ul>
<h3>Other Samplers</h3>