diff --git a/src/bom-thirdparty/build.gradle.kts b/src/bom-thirdparty/build.gradle.kts index 77232e8bf6a..4d54c9168c7 100644 --- a/src/bom-thirdparty/build.gradle.kts +++ b/src/bom-thirdparty/build.gradle.kts @@ -129,10 +129,10 @@ dependencies { api("org.jetbrains.lets-plot:lets-plot-batik:4.1.0") api("org.jetbrains.lets-plot:lets-plot-kotlin-jvm:4.5.0") api("org.jetbrains:annotations:24.1.0") - api("org.jodd:jodd-core:5.0.13") - api("org.jodd:jodd-lagarto:5.0.13") - api("org.jodd:jodd-log:5.0.13") - api("org.jodd:jodd-props:5.0.13") + api("org.jodd:jodd-core:5.3.0") + api("org.jodd:jodd-lagarto:6.0.6") + api("org.jodd:jodd-log:5.1.6") + api("org.jodd:jodd-props:6.0.2") api("org.jsoup:jsoup:1.17.1") api("org.mongodb:mongo-java-driver:2.14.3") api("org.mozilla:rhino:1.7.14") diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/parser/LagartoBasedHtmlParser.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/parser/LagartoBasedHtmlParser.java index 9c30ee8d8f1..2338e83f295 100644 --- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/parser/LagartoBasedHtmlParser.java +++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/parser/LagartoBasedHtmlParser.java @@ -19,9 +19,7 @@ import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayDeque; import java.util.Collections; -import java.util.Deque; import java.util.Iterator; import org.apache.jmeter.protocol.http.util.ConversionUtils; @@ -34,7 +32,6 @@ import jodd.lagarto.Tag; import jodd.lagarto.TagType; import jodd.lagarto.dom.HtmlCCommentExpressionMatcher; -import jodd.lagarto.dom.LagartoDomBuilderConfig; import jodd.log.LoggerFactory; import jodd.log.impl.Slf4jLogger; import jodd.util.CharSequenceUtil; @@ -60,21 +57,16 @@ private URLPointer(URL newUrl) { } private static final class JMeterTagVisitor extends EmptyTagVisitor { - private HtmlCCommentExpressionMatcher htmlCCommentExpressionMatcher; private final URLCollection urls; private final URLPointer baseUrl; - private final Float ieVersion; - private final Deque enabled = new ArrayDeque<>(); /** * @param baseUrl base url to add possibly missing information to urls found in urls * @param urls collection of urls to consider - * @param ieVersion version number of IE to emulate */ - public JMeterTagVisitor(final URLPointer baseUrl, URLCollection urls, Float ieVersion) { + public JMeterTagVisitor(final URLPointer baseUrl, URLCollection urls) { this.urls = urls; this.baseUrl = baseUrl; - this.ieVersion = ieVersion; } private void extractAttribute(Tag tag, String attributeName) { @@ -93,9 +85,6 @@ private void extractAttribute(Tag tag, String attributeName) { */ @Override public void script(Tag tag, CharSequence body) { - if (!enabled.peek()) { - return; - } extractAttribute(tag, ATT_SRC); } @@ -106,9 +95,6 @@ public void script(Tag tag, CharSequence body) { */ @Override public void tag(Tag tag) { - if (!enabled.peek()) { - return; - } TagType tagType = tag.getType(); switch (tagType) { case START: @@ -184,54 +170,16 @@ public void tag(Tag tag) { break; } } - - /* (non-Javadoc) - * @see jodd.lagarto.EmptyTagVisitor#condComment(java.lang.CharSequence, boolean, boolean, boolean) - */ - @Override - public void condComment(CharSequence expression, boolean isStartingTag, - boolean isHidden, boolean isHiddenEndTag) { - // See http://css-tricks.com/how-to-create-an-ie-only-stylesheet/ - if(!isStartingTag) { - enabled.pop(); - } else { - if (htmlCCommentExpressionMatcher == null) { - htmlCCommentExpressionMatcher = new HtmlCCommentExpressionMatcher(); - } - String expressionString = expression.toString().trim(); - enabled.push(htmlCCommentExpressionMatcher.match(ieVersion, - expressionString)); - } - } - - /* (non-Javadoc) - * @see jodd.lagarto.EmptyTagVisitor#start() - */ - @Override - public void start() { - super.start(); - enabled.clear(); - enabled.push(Boolean.TRUE); - } } @Override public Iterator getEmbeddedResourceURLs(String userAgent, byte[] html, URL baseUrl, URLCollection coll, String encoding) throws HTMLParseException { try { - Float ieVersion = extractIEVersion(userAgent); - String contents = new String(html,encoding); LagartoParser lagartoParser = new LagartoParser(contents.toCharArray()); - LagartoDomBuilderConfig config = new LagartoDomBuilderConfig(); - config.setCaseSensitive(false); - // Conditional comments only apply for IE < 10 - config.setEnableConditionalComments(isEnableConditionalComments(ieVersion)); - if(ieVersion != null) { - config.setCondCommentIEVersion(ieVersion); - } - lagartoParser.setConfig(config); - JMeterTagVisitor tagVisitor = new JMeterTagVisitor(new URLPointer(baseUrl), coll, ieVersion); + lagartoParser.getConfig().setCaseSensitive(false); + JMeterTagVisitor tagVisitor = new JMeterTagVisitor(new URLPointer(baseUrl), coll); lagartoParser.parse(tagVisitor); return coll.iterator(); } catch (LagartoException e) { diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java index 9f94e49eb6c..9f61d454c99 100644 --- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java +++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java @@ -30,6 +30,7 @@ import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -61,12 +62,6 @@ public class TestHTMLParser extends JMeterTestCase { private static final String DEFAULT_UA = "Apache-HttpClient/4.2.6"; private static final String UA_FF = "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"; - private static final String UA_IE55 = "Mozilla/4.0 (compatible;MSIE 5.5; Windows 98)"; - private static final String UA_IE6 = "Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"; - private static final String UA_IE7 = "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)"; - private static final String UA_IE8 = "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; " - + "GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)"; - private static final String UA_IE9 = "Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))"; private static final String UA_IE10 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"; private static class StaticTestClass // Can't instantiate @@ -119,6 +114,10 @@ private TestData(String htmlFileName, String baseUrl, String expectedSet, String this.userAgent = userAgent; } + @Override + public String toString() { + return "TestData [userAgent=" + userAgent + ", htmlFileName=" + fileName + ", expectedList=" + expectedList + "]"; + } } private static final String DEFAULT_JMETER_PARSER = @@ -183,26 +182,6 @@ static String[] getParsers() { null, "testfiles/HTMLParserTestCaseWithConditional1_FF.all", UA_FF), - new TestData("testfiles/HTMLParserTestCaseWithConditional1.html", - "http://localhost/mydir/myfile.html", - null, - "testfiles/HTMLParserTestCaseWithConditional1_IE6.all", - UA_IE6), - new TestData("testfiles/HTMLParserTestCaseWithConditional1.html", - "http://localhost/mydir/myfile.html", - null, - "testfiles/HTMLParserTestCaseWithConditional1_IE7.all", - UA_IE7), - new TestData("testfiles/HTMLParserTestCaseWithConditional1.html", - "http://localhost/mydir/myfile.html", - null, - "testfiles/HTMLParserTestCaseWithConditional1_IE8.all", - UA_IE8), - new TestData("testfiles/HTMLParserTestCaseWithConditional1.html", - "http://localhost/mydir/myfile.html", - null, - "testfiles/HTMLParserTestCaseWithConditional1_IE8.all", - UA_IE8), // FF gets mixed up by nested comments new TestData("testfiles/HTMLParserTestCaseWithConditional2.html", @@ -211,41 +190,17 @@ static String[] getParsers() { "testfiles/HTMLParserTestCaseWithConditional2_FF.all", UA_FF), - new TestData("testfiles/HTMLParserTestCaseWithConditional2.html", - "http://localhost/mydir/myfile.html", - null, - "testfiles/HTMLParserTestCaseWithConditional2_IE7.all", - UA_IE7), - new TestData("testfiles/HTMLParserTestCaseWithConditional2.html", - "http://localhost/mydir/myfile.html", - null, - "testfiles/HTMLParserTestCaseWithConditional2_IE8.all", - UA_IE8), - new TestData("testfiles/HTMLParserTestCaseWithConditional2.html", - "http://localhost/mydir/myfile.html", - null, - "testfiles/HTMLParserTestCaseWithConditional2_IE9.all", - UA_IE9), new TestData("testfiles/HTMLParserTestCaseWithConditional3.html", "http://localhost/mydir/myfile.html", null, "testfiles/HTMLParserTestCaseWithConditional3_FF.all", UA_FF), + new TestData("testfiles/HTMLParserTestCaseWithConditional3.html", "http://localhost/mydir/myfile.html", null, "testfiles/HTMLParserTestCaseWithConditional3_IE10.all", UA_IE10), - new TestData("testfiles/HTMLParserTestCaseWithConditional3.html", - "http://localhost/mydir/myfile.html", - null, - "testfiles/HTMLParserTestCaseWithConditional3_IE55.all", - UA_IE55), - new TestData("testfiles/HTMLParserTestCaseWithConditional3.html", - "http://localhost/mydir/myfile.html", - null, - "testfiles/HTMLParserTestCaseWithConditional3_IE6.all", - UA_IE6) }; static Stream parsersAndTestNumbers() { @@ -255,8 +210,8 @@ static Stream parsersAndTestNumbers() { } static Stream specificParserTests() { - return IntStream.range(0, SPECIFIC_PARSER_TESTS.length) - .mapToObj(testNumber -> arguments(DEFAULT_JMETER_PARSER, testNumber)); + return Arrays.stream(SPECIFIC_PARSER_TESTS) + .map(testData -> arguments(DEFAULT_JMETER_PARSER, testData)); } // Test if can instantiate parser using property name @@ -354,13 +309,13 @@ public void testParserList(String parserName, int testNumber) throws Exception { @ParameterizedTest @MethodSource("specificParserTests") - public void testSpecificParserList(String parserName, int testNumber) throws Exception { + public void testSpecificParserList(String parserName, TestData testData) throws Exception { HTMLParser p = (HTMLParser) BaseParser.getParser(parserName); - filetest(p, SPECIFIC_PARSER_TESTS[testNumber].fileName, - SPECIFIC_PARSER_TESTS[testNumber].baseUrl, - SPECIFIC_PARSER_TESTS[testNumber].expectedList, + filetest(p, testData.fileName, + testData.baseUrl, + testData.expectedList, new ArrayList<>(), true, - SPECIFIC_PARSER_TESTS[testNumber].userAgent); + testData.userAgent); } diff --git a/xdocs/changes.xml b/xdocs/changes.xml index f50ac08b508..eea3c92ab07 100644 --- a/xdocs/changes.xml +++ b/xdocs/changes.xml @@ -70,6 +70,11 @@ Summary
  • 63576358 Ensure writable directories when copying template files while report generation.
  • +

    HTTP Samplers and Test Script Recorder

    +
      +
    • 5891Skip Internet Explorer 6-9 conditional comment processing when fetching resource links
    • +
    + Thanks