jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1767068 - in /jmeter/trunk: ./ bin/ lib/ res/maven/ src/protocol/http/org/apache/jmeter/protocol/http/parser/ test/src/org/apache/jmeter/protocol/http/parser/ xdocs/ xdocs/usermanual/
Date Fri, 28 Oct 2016 19:48:44 GMT
Author: fschumacher
Date: Fri Oct 28 19:48:43 2016
New Revision: 1767068

URL: http://svn.apache.org/viewvc?rev=1767068&view=rev
Log:
Ignore CSS warnings when parsing with ph-css library.

Bugzilla Id: 60318

Added:
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java   (with
props)
Modified:
    jmeter/trunk/LICENSE
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/build.properties
    jmeter/trunk/eclipse.classpath
    jmeter/trunk/lib/aareadme.txt
    jmeter/trunk/res/maven/ApacheJMeter_parent.pom
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/CssParser.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml

Modified: jmeter/trunk/LICENSE
URL: http://svn.apache.org/viewvc/jmeter/trunk/LICENSE?rev=1767068&r1=1767067&r2=1767068&view=diff
==============================================================================
--- jmeter/trunk/LICENSE [utf-8] (original)
+++ jmeter/trunk/LICENSE [utf-8] Fri Oct 28 19:48:43 2016
@@ -247,7 +247,7 @@ The following software is provided under
 * json-smart-2.2.1.jar
 * mongo-java-driver-2.11.3.jar
 * ph-commons-6.2.4.jar
-* ph-css-4.1.5.jar
+* ph-css-4.1.6.jar
 
 - Software produced outside the ASF which is available under other licenses (not AL 2.0):
 For details, please see the files under: licenses/bin

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1767068&r1=1767067&r2=1767068&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Fri Oct 28 19:48:43 2016
@@ -738,6 +738,9 @@ cssParser.types=text/css
 # It can be disabled by setting its value to 0
 #css.parser.cache.size=400
 
+# Let the CSS Parser ingore all css errors
+#css.parser.ignore_all_css_errors=true
+
 #---------------------------------------------------------------------------
 # HTML Parser configuration
 #---------------------------------------------------------------------------

Modified: jmeter/trunk/build.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/build.properties?rev=1767068&r1=1767067&r2=1767068&view=diff
==============================================================================
--- jmeter/trunk/build.properties (original)
+++ jmeter/trunk/build.properties Fri Oct 28 19:48:43 2016
@@ -259,10 +259,10 @@ mongo-java-driver.jar       = mongo-java
 mongo-java-driver.loc       = ${maven2.repo}/org/mongodb/mongo-java-driver/${mongo-java-driver.version}
 mongo-java-driver.md5       = 90647a53231eb75715fda30759ff4ff7
 
-ph-css.version              = 4.1.5
+ph-css.version              = 4.1.6
 ph-css.jar                  = ph-css-${ph-css.version}.jar
 ph-css.loc                  = ${maven2.repo}/com/helger/ph-css/${ph-css.version}
-ph-css.md5                  = 6074b8d10596a3211a20075710abcbe2
+ph-css.md5                  = a6836c05d98defcac7d9aad246c25b5e
 
 ph-commons.version          = 6.2.4
 ph-commons.jar              = ph-commons-${ph-commons.version}.jar

Modified: jmeter/trunk/eclipse.classpath
URL: http://svn.apache.org/viewvc/jmeter/trunk/eclipse.classpath?rev=1767068&r1=1767067&r2=1767068&view=diff
==============================================================================
--- jmeter/trunk/eclipse.classpath (original)
+++ jmeter/trunk/eclipse.classpath Fri Oct 28 19:48:43 2016
@@ -83,7 +83,7 @@
 	<classpathentry kind="lib" path="lib/logkit-2.0.jar"/>
 	<classpathentry kind="lib" path="lib/mail-1.5.0-b01.jar"/>
 	<classpathentry kind="lib" path="lib/mongo-java-driver-2.11.3.jar"/>
-	<classpathentry kind="lib" path="lib/ph-css-4.1.5.jar"/>
+	<classpathentry kind="lib" path="lib/ph-css-4.1.6.jar"/>
 	<classpathentry kind="lib" path="lib/ph-commons-6.2.4.jar"/>
 	<classpathentry kind="lib" path="lib/oro-2.0.8.jar"/>
 	<classpathentry kind="lib" path="lib/rhino-1.7.7.1.jar"/>

Modified: jmeter/trunk/lib/aareadme.txt
URL: http://svn.apache.org/viewvc/jmeter/trunk/lib/aareadme.txt?rev=1767068&r1=1767067&r2=1767068&view=diff
==============================================================================
--- jmeter/trunk/lib/aareadme.txt (original)
+++ jmeter/trunk/lib/aareadme.txt Fri Oct 28 19:48:43 2016
@@ -163,7 +163,7 @@ jsoup-1.9.2
 http://www.jsoup.org/
 - CSS/JQuery like extractor
 
-ph-css-4.1.5
+ph-css-4.1.6
 --------
 https://github.com/phax/ph-css
 - CssParser

Modified: jmeter/trunk/res/maven/ApacheJMeter_parent.pom
URL: http://svn.apache.org/viewvc/jmeter/trunk/res/maven/ApacheJMeter_parent.pom?rev=1767068&r1=1767067&r2=1767068&view=diff
==============================================================================
--- jmeter/trunk/res/maven/ApacheJMeter_parent.pom (original)
+++ jmeter/trunk/res/maven/ApacheJMeter_parent.pom Fri Oct 28 19:48:43 2016
@@ -92,7 +92,7 @@ under the License.
       <junit.version>4.12</junit.version>
       <logkit.version>2.0</logkit.version>
       <mongo-java-driver.version>2.11.3</mongo-java-driver.version>
-      <ph-css.version>4.1.5</ph-css.version>
+      <ph-css.version>4.1.6</ph-css.version>
       <ph-commons.version>6.2.4</ph-commons.version>
       <rsyntaxtextarea.version>2.6.0</rsyntaxtextarea.version>
       <slf4j-api.version>1.7.21</slf4j-api.version>

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/CssParser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/CssParser.java?rev=1767068&r1=1767067&r2=1767068&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/CssParser.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/CssParser.java Fri
Oct 28 19:48:43 2016
@@ -45,6 +45,8 @@ import com.helger.css.handler.LoggingCSS
 import com.helger.css.parser.ParseException;
 import com.helger.css.reader.CSSReader;
 import com.helger.css.reader.CSSReaderSettings;
+import com.helger.css.reader.errorhandler.DoNothingCSSInterpretErrorHandler;
+import com.helger.css.reader.errorhandler.ICSSInterpretErrorHandler;
 import com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler;
 
 /**
@@ -59,6 +61,7 @@ public class CssParser implements LinkEx
      * 
      */
     private static final int CSS_URL_CACHE_MAX_SIZE = JMeterUtils.getPropDefault("css.parser.cache.size",
400);
+    private static final boolean IGNORE_ALL_CSS_ERRORS = JMeterUtils.getPropDefault("css.parser.ignore_all_css_errors",
true);
     
     /**
      * 
@@ -121,13 +124,21 @@ public class CssParser implements LinkEx
             
             if(urlCollection == null) {
                 String cssContent = new String(data, encoding);
-                final CascadingStyleSheet aCSS = CSSReader.readFromStringStream(cssContent,
-                            new CSSReaderSettings()
-                                .setBrowserCompliantMode(true)
-                                .setFallbackCharset(Charset.forName(encoding))
-                                .setCSSVersion (ECSSVersion.CSS30)
-                                .setCustomErrorHandler(new LoggingCSSParseErrorHandler())
-                                .setCustomExceptionHandler (new CustomLoggingCSSParseExceptionCallback(baseUrl)));
+                final CSSReaderSettings cssSettings = new CSSReaderSettings()
+                        .setBrowserCompliantMode(true)
+                        .setFallbackCharset(Charset.forName(encoding))
+                        .setCSSVersion(ECSSVersion.CSS30)
+                        .setCustomErrorHandler(
+                                new LoggingCSSParseErrorHandler())
+                        .setCustomExceptionHandler(
+                                new CustomLoggingCSSParseExceptionCallback(
+                                        baseUrl));
+                if (IGNORE_ALL_CSS_ERRORS) {
+                    cssSettings
+                            .setInterpretErrorHandler(new DoNothingCSSInterpretErrorHandler());
+                }
+                final CascadingStyleSheet aCSS = CSSReader
+                        .readFromStringStream(cssContent, cssSettings);
                 final List<URLString> list = new ArrayList<>();
                 urlCollection = new URLCollection(list);
                 final URLCollection localCollection = urlCollection;

Added: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java?rev=1767068&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java Fri Oct
28 19:48:43 2016
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.parser;
+
+import static org.junit.Assert.assertThat;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
+import org.apache.commons.collections.IteratorUtils;
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+
+public class TestCssParser extends JMeterTestCase {
+
+    private final CssParser parser = new CssParser();
+
+    @Test
+    public void testGetEmbeddedResourceURLsNoUrls() throws Exception {
+        CssParser nonIgnoreParser = new CssParser();
+        List<?> result = extractUrls(nonIgnoreParser, "..");
+        assertThat(result.isEmpty(), CoreMatchers.is(true));
+    }
+
+    @Test
+    public void testGetEmbeddedResourceURLsnOneUrl() throws Exception {
+        List<?> result;
+        result = extractUrls("@import url(http://example.com/abc.css);");
+        assertThat(result.isEmpty(), CoreMatchers.is(false));
+    }
+
+    @Test
+    public void testIsReusable() {
+        assertThat(parser.isReusable(), CoreMatchers.is(true));
+    }
+
+    private List<?> extractUrls(String css) throws LinkExtractorParseException,
+            MalformedURLException {
+        return extractUrls(parser, css);
+    }
+
+    private List<?> extractUrls(CssParser parser, String css)
+            throws LinkExtractorParseException, MalformedURLException {
+        List<?> result = IteratorUtils.toList(parser.getEmbeddedResourceURLs(
+                "Mozilla", css.getBytes(StandardCharsets.UTF_8), new URL(
+                        "http://example.org/"), StandardCharsets.UTF_8
+                        .displayName()));
+        return result;
+    }
+}
+

Propchange: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestCssParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1767068&r1=1767067&r2=1767068&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Oct 28 19:48:43 2016
@@ -104,6 +104,7 @@ Summary
     <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>
     <li><bug>53039</bug>HTTP Request : Be able to handle responses which
size exceeds <code>2147483647</code> bytes</li>
     <li><bug>60265</bug>HTTP Request : In Files Upload Tab you cannot resize
columns</li>
+    <li><bug>60318</bug>Ignore CSS warnings when parsing with ph-css library.</li>
 </ul>
 
 <h3>Other samplers</h3>
@@ -197,7 +198,7 @@ Summary
 <ch_section>Non-functional changes</ch_section>
 <ul>
     <li>Updated to jsoup-1.9.2 (from 1.8.3)</li>
-    <li>Updated to ph-css 4.1.5 (from 4.1.4)</li>
+    <li>Updated to ph-css 4.1.6 (from 4.1.4)</li>
     <li>Updated to tika-core and tika-parsers 1.13 (from 1.12)</li>
     <li>Updated to commons-io 2.5 (from 2.4)</li>
     <li>Updated to commons-net 3.5 (from 3.4)</li>

Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1767068&r1=1767067&r2=1767068&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Fri Oct 28 19:48:43 2016
@@ -899,6 +899,10 @@ log_level.org.apache.http.client=DEBUG
     parsing the CSS. By default the cache size is 400. It can be disabled by setting its
value to 0.<br/>
     Defaults to: <code>400</code>
 </property>
+<property name="css.parser.ignore_all_css_errors">
+    Let the CSS Parser ignore all CSS errors.<br/>
+    Defaults to: <code>true</code>
+</property>
 <property name="htmlParser.className" required="Yes">
     Define the HTML parser to be used.<br/>
     Do not comment this property.<br/>



Mime
View raw message