portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msnickl...@apache.org
Subject [37/38] portals-pluto git commit: Added some tests to the header portlet to make sure that the characters & and < are processed correctly within the script tag when a script tag is written to the output stream in the header phase. Modified Pluto implemen
Date Fri, 27 Nov 2015 12:38:18 GMT
Added some tests to the header portlet to make sure that the characters &
and < are processed correctly within the script tag when a script tag is
written to the output stream in the header phase. Modified Pluto
implementation to accommodate these characters.


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/d4424802
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/d4424802
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/d4424802

Branch: refs/heads/V3Prototype
Commit: d4424802772bec6e88f2d12f9a59df26ccd8aca7
Parents: 6dd6b87
Author: Scott Nicklous <msnicklous@apache.org>
Authored: Fri Nov 27 12:59:11 2015 +0100
Committer: Scott Nicklous <msnicklous@apache.org>
Committed: Fri Nov 27 12:59:11 2015 +0100

----------------------------------------------------------------------
 PortletV3Demo/pom.xml                           |  1 +
 .../main/java/basic/portlet/HeaderPortlet.java  |  2 +-
 .../webapp/WEB-INF/jsp/headSectionMarkup.jsp    |  3 +-
 PortletV3Demo/src/main/webapp/WEB-INF/web.xml   |  4 ---
 .../org/apache/pluto/container/HeaderData.java  | 29 ++++++++++++--------
 5 files changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4424802/PortletV3Demo/pom.xml
----------------------------------------------------------------------
diff --git a/PortletV3Demo/pom.xml b/PortletV3Demo/pom.xml
index 3c23fdc..4f60abf 100644
--- a/PortletV3Demo/pom.xml
+++ b/PortletV3Demo/pom.xml
@@ -68,6 +68,7 @@
             <artifactId>maven-war-plugin</artifactId>
             <configuration>
                <archiveClasses>false</archiveClasses>
+               <failOnMissingWebXml>false</failOnMissingWebXml>
             </configuration>
          </plugin>
       </plugins>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4424802/PortletV3Demo/src/main/java/basic/portlet/HeaderPortlet.java
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/java/basic/portlet/HeaderPortlet.java b/PortletV3Demo/src/main/java/basic/portlet/HeaderPortlet.java
index 95df1af..1310b48 100644
--- a/PortletV3Demo/src/main/java/basic/portlet/HeaderPortlet.java
+++ b/PortletV3Demo/src/main/java/basic/portlet/HeaderPortlet.java
@@ -82,7 +82,7 @@ public class HeaderPortlet extends GenericPortlet {
       resp.addProperty(c);
 
       // Set header
-      resp.setProperty("Portlet", this.getPortletName());
+      resp.addProperty("Portlet", this.getPortletName());
       resp.setProperty("Portal", "Pluto");
 
       PrintWriter writer = resp.getWriter();

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4424802/PortletV3Demo/src/main/webapp/WEB-INF/jsp/headSectionMarkup.jsp
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/headSectionMarkup.jsp b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/headSectionMarkup.jsp
index d15ad53..b3c4084 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/headSectionMarkup.jsp
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/headSectionMarkup.jsp
@@ -27,7 +27,7 @@ limitations under the License.
 <meta name="description" content="Portlet Hub Demo Portlet">
 <style>
 <!--
-.markupSection {
+.markupSection {                 /* special chars & < */
    padding: 5px;
    background-color: #DDFFDD;
    border: thin solid #22EE88;
@@ -44,6 +44,7 @@ bootstrap = function () {
    var cookies = document.cookie.split(';'), ii, markup;
    markup = '<p>Current Cookies:</p>';
    for (ii = 0; ii < cookies.length; ii++) {
+      /* make sure parser eats & character */
       markup += cookies[ii] + '<br/>';
    }
    document.getElementById(cdiv).innerHTML=markup;

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4424802/PortletV3Demo/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/web.xml b/PortletV3Demo/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 10055f0..0000000
--- a/PortletV3Demo/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
-	<display-name>Portlet Version 3.0 Demo</display-name>
-</web-app>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4424802/pluto-container-api/src/main/java/org/apache/pluto/container/HeaderData.java
----------------------------------------------------------------------
diff --git a/pluto-container-api/src/main/java/org/apache/pluto/container/HeaderData.java
b/pluto-container-api/src/main/java/org/apache/pluto/container/HeaderData.java
index 6209f5d..86f08cc 100644
--- a/pluto-container-api/src/main/java/org/apache/pluto/container/HeaderData.java
+++ b/pluto-container-api/src/main/java/org/apache/pluto/container/HeaderData.java
@@ -167,24 +167,26 @@ public class HeaderData {
          
          // convert < brackets within script tags to corresponding entities
          
-         Pattern pat = Pattern.compile("(?s)" +             // multiline mode 
-                                       "(?<=<script)" +     // 0-width lookbehind;
script start tag
-                                       "(.*?)" +            // non-greedy content of tag
-                                       "(?=</script)");     // 0-width lookahead: script
end tag
+         Pattern pat = Pattern.compile("(?s)" +                      // multiline mode 
+                                       "(?<=<(script|style))" +      // 0-width lookbehind;
start tag
+                                       "(.*?)" +                     // non-greedy content
of tag
+                                       "(?=</(script|style))");      // 0-width lookahead;
end tag
          Matcher mat = pat.matcher(src);
          while (mat.find()) {
-            mat.appendReplacement(sb, mat.group().replaceAll("<", "&lt;"));
+            mat.appendReplacement(sb, mat.group().replaceAll("&", "&amp;").replaceAll("<",
"&lt;"));
          }
          mat.appendTail(sb);
 
          sb.append(ROOT_ELEMENT_END);
-         LOG.debug(sb.toString());
 
          StringReader sr = new StringReader(sb.toString());
          InputSource is = new InputSource(sr);
          Document adoc;
 
          try {
+            if (docBuilder == null) {
+               setupDoc();
+            }
             adoc = docBuilder.parse(is);
 
             // verify that all tags are allowed
@@ -292,15 +294,20 @@ public class HeaderData {
          LOG.warn(txt.toString());
       }
    }
+   
+   public void setupDoc() throws ParserConfigurationException {
+      DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
+      dbfac.setExpandEntityReferences(true);
+      docBuilder = dbfac.newDocumentBuilder();
+      doc = docBuilder.newDocument();
+      root = doc.createElement(ROOT_ELEMENT);
+      doc.appendChild(root);
+   }
 
    public Element createElement(String tagName) {
       try {
          if (doc == null) {
-            DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
-            docBuilder = dbfac.newDocumentBuilder();
-            doc = docBuilder.newDocument();
-            root = doc.createElement(ROOT_ELEMENT);
-            doc.appendChild(root);
+            setupDoc();
          }
          return doc.createElement(tagName);
       } catch (ParserConfigurationException e) {


Mime
View raw message