You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2016/11/01 16:13:32 UTC

svn commit: r1767516 - in /sling/trunk/bundles/scripting/sightly: compiler/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/ testing-content/src/main/resources/SLING-INF/ testing-content/src/main/resources/SLING-INF/apps/si...

Author: radu
Date: Tue Nov  1 16:13:32 2016
New Revision: 1767516

URL: http://svn.apache.org/viewvc?rev=1767516&view=rev
Log:
SLING-6224 - Expand the accepted & ignored whitespace characters for HTL scripts

* expanded whitespace characters list and added tests

Added:
    sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/whitespace/
    sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/whitespace/whitespace.html
Modified:
    sling/trunk/bundles/scripting/sightly/compiler/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyLexer.g4
    sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json
    sling/trunk/bundles/scripting/sightly/testing/pom.xml
    sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java

Modified: sling/trunk/bundles/scripting/sightly/compiler/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyLexer.g4
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/compiler/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyLexer.g4?rev=1767516&r1=1767515&r2=1767516&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/compiler/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyLexer.g4 (original)
+++ sling/trunk/bundles/scripting/sightly/compiler/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyLexer.g4 Tue Nov  1 16:13:32 2016
@@ -90,6 +90,9 @@ WS  :   ( ' '
         | '\t'
         | '\r'
         | '\n'
+        | '\f'
+        | '\u000B'
+        | '\u00A0'
         ) -> channel(HIDDEN)
     ;
 

Added: sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/whitespace/whitespace.html
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/whitespace/whitespace.html?rev=1767516&view=auto
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/whitespace/whitespace.html (added)
+++ sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/whitespace/whitespace.html Tue Nov  1 16:13:32 2016
@@ -0,0 +1,26 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<div>
+    <p>The following output is generated from expressions with different whitespace characters:</p>
+    <p><code>\${1 > 0}: <span id="nbsp">${1 > 0}</span></code></p>
+    <p><code>\${1	>	0}: <span id="tab">${1	>	0}</span></code></p>
+    <p><code>\${1
+                >
+                0}: <span id="newline">${1
+                                         >
+                                         0}</span></code></p>
+</div>

Modified: sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json?rev=1767516&r1=1767515&r2=1767516&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json (original)
+++ sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json Tue Nov  1 16:13:32 2016
@@ -60,5 +60,9 @@
     "i18n": {
         "jcr:primaryType": "nt:unstructured",
         "sling:resourceType" : "/apps/sightly/scripts/i18n"
+    },
+    "whitespace": {
+        "jcr:primaryType": "nt:unstructured",
+        "sling:resourceType": "/apps/sightly/scripts/whitespace"
     }
 }

Modified: sling/trunk/bundles/scripting/sightly/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing/pom.xml?rev=1767516&r1=1767515&r2=1767516&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing/pom.xml (original)
+++ sling/trunk/bundles/scripting/sightly/testing/pom.xml Tue Nov  1 16:13:32 2016
@@ -448,6 +448,11 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>compile</scope>
+        </dependency>
 
         <!-- Dependency for running Sling performance tests -->
         <dependency>
@@ -456,5 +461,11 @@
             <version>1.0.2</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.4</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>

Modified: sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java?rev=1767516&r1=1767515&r2=1767516&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java (original)
+++ sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java Tue Nov  1 16:13:32 2016
@@ -21,10 +21,12 @@ package org.apache.sling.scripting.sight
 import java.io.IOException;
 
 import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.EntityBuilder;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
 import org.apache.http.entity.mime.content.InputStreamBody;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -32,9 +34,7 @@ import org.junit.Test;
 import io.sightly.tck.html.HTMLExtractor;
 import io.sightly.tck.http.Client;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 public class SlingSpecificsSightlyIT {
 
@@ -62,6 +62,7 @@ public class SlingSpecificsSightlyIT {
     private static final String SLING_RESOURCE_USE = "/sightly/use.resource.html";
     private static final String SLING_I18N = "/sightly/i18n";
     private static final String TCK_XSS = "/sightlytck/exprlang/xss.html";
+    private static final String WHITESPACE = "/sightly/whitespace.html";
 
     @BeforeClass
     public static void init() {
@@ -300,6 +301,15 @@ public class SlingSpecificsSightlyIT {
         assertTrue(pageContent.contains("<p id=\"req-context-8\" onclick=\"console.log('red')\">Paragraph</p>"));
     }
 
+    @Test
+    public void testWhiteSpaceExpressions() {
+        String url = launchpadURL + WHITESPACE;
+        String pageContent = client.getStringContent(url, 200);
+        assertEquals("true", HTMLExtractor.innerHTML(url, pageContent, "#nbsp"));
+        assertEquals("true", HTMLExtractor.innerHTML(url, pageContent, "#tab"));
+        assertEquals("true", HTMLExtractor.innerHTML(url, pageContent, "#newline"));
+    }
+
     private void uploadFile(String fileName, String serverFileName, String url) throws IOException {
         HttpClient httpClient = HttpClientBuilder.create().build();
         HttpPost post = new HttpPost(launchpadURL + url);