View | Details | Raw Unified | Return to bug 60318
Collapse All | Expand All

(-)a/LICENSE (-1 / +1 lines)
Lines 247-253 The following software is provided under the Apache License V 2.0 (as above): Link Here
247
* json-smart-2.2.1.jar
247
* json-smart-2.2.1.jar
248
* mongo-java-driver-2.11.3.jar
248
* mongo-java-driver-2.11.3.jar
249
* ph-commons-6.2.4.jar
249
* ph-commons-6.2.4.jar
250
* ph-css-4.1.5.jar
250
* ph-css-4.1.6.jar
251
251
252
- Software produced outside the ASF which is available under other licenses (not AL 2.0):
252
- Software produced outside the ASF which is available under other licenses (not AL 2.0):
253
For details, please see the files under: licenses/bin
253
For details, please see the files under: licenses/bin
(-)a/bin/jmeter.properties (+3 lines)
Lines 738-743 cssParser.types=text/css Link Here
738
# It can be disabled by setting its value to 0
738
# It can be disabled by setting its value to 0
739
#css.parser.cache.size=400
739
#css.parser.cache.size=400
740
740
741
# Let the CSS Parser ingore all css errors
742
#css.parser.ignore_all_css_errors=true
743
741
#---------------------------------------------------------------------------
744
#---------------------------------------------------------------------------
742
# HTML Parser configuration
745
# HTML Parser configuration
743
#---------------------------------------------------------------------------
746
#---------------------------------------------------------------------------
(-)a/build.properties (-2 / +2 lines)
Lines 259-268 mongo-java-driver.jar = mongo-java-driver-${mongo-java-driver.version}.jar Link Here
259
mongo-java-driver.loc       = ${maven2.repo}/org/mongodb/mongo-java-driver/${mongo-java-driver.version}
259
mongo-java-driver.loc       = ${maven2.repo}/org/mongodb/mongo-java-driver/${mongo-java-driver.version}
260
mongo-java-driver.md5       = 90647a53231eb75715fda30759ff4ff7
260
mongo-java-driver.md5       = 90647a53231eb75715fda30759ff4ff7
261
261
262
ph-css.version              = 4.1.5
262
ph-css.version              = 4.1.6
263
ph-css.jar                  = ph-css-${ph-css.version}.jar
263
ph-css.jar                  = ph-css-${ph-css.version}.jar
264
ph-css.loc                  = ${maven2.repo}/com/helger/ph-css/${ph-css.version}
264
ph-css.loc                  = ${maven2.repo}/com/helger/ph-css/${ph-css.version}
265
ph-css.md5                  = 6074b8d10596a3211a20075710abcbe2
265
ph-css.md5                  = a6836c05d98defcac7d9aad246c25b5e
266
266
267
ph-commons.version          = 6.2.4
267
ph-commons.version          = 6.2.4
268
ph-commons.jar              = ph-commons-${ph-commons.version}.jar
268
ph-commons.jar              = ph-commons-${ph-commons.version}.jar
(-)a/eclipse.classpath (-1 / +1 lines)
Lines 83-89 Link Here
83
	<classpathentry kind="lib" path="lib/logkit-2.0.jar"/>
83
	<classpathentry kind="lib" path="lib/logkit-2.0.jar"/>
84
	<classpathentry kind="lib" path="lib/mail-1.5.0-b01.jar"/>
84
	<classpathentry kind="lib" path="lib/mail-1.5.0-b01.jar"/>
85
	<classpathentry kind="lib" path="lib/mongo-java-driver-2.11.3.jar"/>
85
	<classpathentry kind="lib" path="lib/mongo-java-driver-2.11.3.jar"/>
86
	<classpathentry kind="lib" path="lib/ph-css-4.1.5.jar"/>
86
	<classpathentry kind="lib" path="lib/ph-css-4.1.6.jar"/>
87
	<classpathentry kind="lib" path="lib/ph-commons-6.2.4.jar"/>
87
	<classpathentry kind="lib" path="lib/ph-commons-6.2.4.jar"/>
88
	<classpathentry kind="lib" path="lib/oro-2.0.8.jar"/>
88
	<classpathentry kind="lib" path="lib/oro-2.0.8.jar"/>
89
	<classpathentry kind="lib" path="lib/rhino-1.7.7.1.jar"/>
89
	<classpathentry kind="lib" path="lib/rhino-1.7.7.1.jar"/>
(-)a/lib/aareadme.txt (-1 / +1 lines)
Lines 163-169 jsoup-1.9.2 Link Here
163
http://www.jsoup.org/
163
http://www.jsoup.org/
164
- CSS/JQuery like extractor
164
- CSS/JQuery like extractor
165
165
166
ph-css-4.1.5
166
ph-css-4.1.6
167
--------
167
--------
168
https://github.com/phax/ph-css
168
https://github.com/phax/ph-css
169
- CssParser
169
- CssParser
(-)a/res/maven/ApacheJMeter_parent.pom (-1 / +1 lines)
Lines 92-98 under the License. Link Here
92
      <junit.version>4.12</junit.version>
92
      <junit.version>4.12</junit.version>
93
      <logkit.version>2.0</logkit.version>
93
      <logkit.version>2.0</logkit.version>
94
      <mongo-java-driver.version>2.11.3</mongo-java-driver.version>
94
      <mongo-java-driver.version>2.11.3</mongo-java-driver.version>
95
      <ph-css.version>4.1.5</ph-css.version>
95
      <ph-css.version>4.1.6</ph-css.version>
96
      <ph-commons.version>6.2.4</ph-commons.version>
96
      <ph-commons.version>6.2.4</ph-commons.version>
97
      <rsyntaxtextarea.version>2.6.0</rsyntaxtextarea.version>
97
      <rsyntaxtextarea.version>2.6.0</rsyntaxtextarea.version>
98
      <slf4j-api.version>1.7.21</slf4j-api.version>
98
      <slf4j-api.version>1.7.21</slf4j-api.version>
(-)a/src/protocol/http/org/apache/jmeter/protocol/http/parser/CssParser.java (-7 / +18 lines)
Lines 45-50 import com.helger.css.handler.LoggingCSSParseExceptionCallback; Link Here
45
import com.helger.css.parser.ParseException;
45
import com.helger.css.parser.ParseException;
46
import com.helger.css.reader.CSSReader;
46
import com.helger.css.reader.CSSReader;
47
import com.helger.css.reader.CSSReaderSettings;
47
import com.helger.css.reader.CSSReaderSettings;
48
import com.helger.css.reader.errorhandler.DoNothingCSSInterpretErrorHandler;
49
import com.helger.css.reader.errorhandler.ICSSInterpretErrorHandler;
48
import com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler;
50
import com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler;
49
51
50
/**
52
/**
Lines 59-64 public class CssParser implements LinkExtractorParser { Link Here
59
     * 
61
     * 
60
     */
62
     */
61
    private static final int CSS_URL_CACHE_MAX_SIZE = JMeterUtils.getPropDefault("css.parser.cache.size", 400);
63
    private static final int CSS_URL_CACHE_MAX_SIZE = JMeterUtils.getPropDefault("css.parser.cache.size", 400);
64
    private static final boolean IGNORE_ALL_CSS_ERRORS = JMeterUtils.getPropDefault("css.parser.ignore_all_css_errors", true);
62
    
65
    
63
    /**
66
    /**
64
     * 
67
     * 
Lines 121-133 public class CssParser implements LinkExtractorParser { Link Here
121
            
124
            
122
            if(urlCollection == null) {
125
            if(urlCollection == null) {
123
                String cssContent = new String(data, encoding);
126
                String cssContent = new String(data, encoding);
124
                final CascadingStyleSheet aCSS = CSSReader.readFromStringStream(cssContent,
127
                final CSSReaderSettings cssSettings = new CSSReaderSettings()
125
                            new CSSReaderSettings()
128
                        .setBrowserCompliantMode(true)
126
                                .setBrowserCompliantMode(true)
129
                        .setFallbackCharset(Charset.forName(encoding))
127
                                .setFallbackCharset(Charset.forName(encoding))
130
                        .setCSSVersion(ECSSVersion.CSS30)
128
                                .setCSSVersion (ECSSVersion.CSS30)
131
                        .setCustomErrorHandler(
129
                                .setCustomErrorHandler(new LoggingCSSParseErrorHandler())
132
                                new LoggingCSSParseErrorHandler())
130
                                .setCustomExceptionHandler (new CustomLoggingCSSParseExceptionCallback(baseUrl)));
133
                        .setCustomExceptionHandler(
134
                                new CustomLoggingCSSParseExceptionCallback(
135
                                        baseUrl));
136
                if (IGNORE_ALL_CSS_ERRORS) {
137
                    cssSettings
138
                            .setInterpretErrorHandler(new DoNothingCSSInterpretErrorHandler());
139
                }
140
                final CascadingStyleSheet aCSS = CSSReader
141
                        .readFromStringStream(cssContent, cssSettings);
131
                final List<URLString> list = new ArrayList<>();
142
                final List<URLString> list = new ArrayList<>();
132
                urlCollection = new URLCollection(list);
143
                urlCollection = new URLCollection(list);
133
                final URLCollection localCollection = urlCollection;
144
                final URLCollection localCollection = urlCollection;
(-)a/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java (+69 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
19
package org.apache.jmeter.protocol.http.parser;
20
21
import static org.junit.Assert.assertThat;
22
23
import java.net.MalformedURLException;
24
import java.net.URL;
25
import java.nio.charset.StandardCharsets;
26
import java.util.List;
27
28
import org.apache.commons.collections.IteratorUtils;
29
import org.apache.jmeter.junit.JMeterTestCase;
30
import org.hamcrest.CoreMatchers;
31
import org.junit.Test;
32
33
public class TestCssParser extends JMeterTestCase {
34
35
    private final CssParser parser = new CssParser();
36
37
    @Test
38
    public void testGetEmbeddedResourceURLsNoUrls() throws Exception {
39
        CssParser nonIgnoreParser = new CssParser();
40
        List<?> result = extractUrls(nonIgnoreParser, "..");
41
        assertThat(result.isEmpty(), CoreMatchers.is(true));
42
    }
43
44
    @Test
45
    public void testGetEmbeddedResourceURLsnOneUrl() throws Exception {
46
        List<?> result;
47
        result = extractUrls("@import url(http://example.com/abc.css);");
48
        assertThat(result.isEmpty(), CoreMatchers.is(false));
49
    }
50
51
    @Test
52
    public void testIsReusable() {
53
        assertThat(parser.isReusable(), CoreMatchers.is(true));
54
    }
55
56
    private List<?> extractUrls(String css) throws LinkExtractorParseException,
57
            MalformedURLException {
58
        return extractUrls(parser, css);
59
    }
60
61
    private List<?> extractUrls(CssParser parser, String css)
62
            throws LinkExtractorParseException, MalformedURLException {
63
        List<?> result = IteratorUtils.toList(parser.getEmbeddedResourceURLs(
64
                "Mozilla", css.getBytes(StandardCharsets.UTF_8), new URL(
65
                        "http://example.org/"), StandardCharsets.UTF_8
66
                        .displayName()));
67
        return result;
68
    }
69
}
(-)a/xdocs/changes.xml (-1 / +2 lines)
Lines 104-109 Summary Link Here
104
    <li><bug>60229</bug>Add a new metric : sent_bytes. Implemented by Philippe Mouawad (p.mouawad at ubik-ingenierie.com) and contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
104
    <li><bug>60229</bug>Add a new metric : sent_bytes. Implemented by Philippe Mouawad (p.mouawad at ubik-ingenierie.com) and contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
105
    <li><bug>53039</bug>HTTP Request : Be able to handle responses which size exceeds <code>2147483647</code> bytes</li>
105
    <li><bug>53039</bug>HTTP Request : Be able to handle responses which size exceeds <code>2147483647</code> bytes</li>
106
    <li><bug>60265</bug>HTTP Request : In Files Upload Tab you cannot resize columns</li>
106
    <li><bug>60265</bug>HTTP Request : In Files Upload Tab you cannot resize columns</li>
107
    <li>Ignore CSS warnings when parsing with ph-css library.</li>
107
</ul>
108
</ul>
108
109
109
<h3>Other samplers</h3>
110
<h3>Other samplers</h3>
Lines 196-202 Summary Link Here
196
<ch_section>Non-functional changes</ch_section>
197
<ch_section>Non-functional changes</ch_section>
197
<ul>
198
<ul>
198
    <li>Updated to jsoup-1.9.2 (from 1.8.3)</li>
199
    <li>Updated to jsoup-1.9.2 (from 1.8.3)</li>
199
    <li>Updated to ph-css 4.1.5 (from 4.1.4)</li>
200
    <li>Updated to ph-css 4.1.6 (from 4.1.4)</li>
200
    <li>Updated to tika-core and tika-parsers 1.13 (from 1.12)</li>
201
    <li>Updated to tika-core and tika-parsers 1.13 (from 1.12)</li>
201
    <li>Updated to commons-io 2.5 (from 2.4)</li>
202
    <li>Updated to commons-io 2.5 (from 2.4)</li>
202
    <li>Updated to commons-net 3.5 (from 3.4)</li>
203
    <li>Updated to commons-net 3.5 (from 3.4)</li>
(-)a/xdocs/usermanual/properties_reference.xml (-1 / +4 lines)
Lines 899-904 log_level.org.apache.http.client=DEBUG Link Here
899
    parsing the CSS. By default the cache size is 400. It can be disabled by setting its value to 0.<br/>
899
    parsing the CSS. By default the cache size is 400. It can be disabled by setting its value to 0.<br/>
900
    Defaults to: <code>400</code>
900
    Defaults to: <code>400</code>
901
</property>
901
</property>
902
<property name="css.parser.ignore_all_css_errors">
903
    Let the CSS Parser ignore all CSS errors.<br/>
904
    Defaults to: <code>true</code>
905
</property>
902
<property name="htmlParser.className" required="Yes">
906
<property name="htmlParser.className" required="Yes">
903
    Define the HTML parser to be used.<br/>
907
    Define the HTML parser to be used.<br/>
904
    Do not comment this property.<br/>
908
    Do not comment this property.<br/>
905
- 

Return to bug 60318