You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by we...@apache.org on 2009/09/21 17:07:03 UTC

svn commit: r817282 - in /struts/struts2/trunk/core/src: main/resources/template/simple/optgroup.ftl test/java/org/apache/struts2/views/jsp/ui/OptGroupTest.java test/resources/org/apache/struts2/views/jsp/ui/OptGroup-5.txt

Author: wesw
Date: Mon Sep 21 15:07:03 2009
New Revision: 817282

URL: http://svn.apache.org/viewvc?rev=817282&view=rev
Log:
ww-3246
fixing OptGroup so that it escapes html entities the way the select tag does

Added:
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/OptGroup-5.txt
      - copied, changed from r817250, struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/OptGroup-3.txt
Modified:
    struts/struts2/trunk/core/src/main/resources/template/simple/optgroup.ftl
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/OptGroupTest.java

Modified: struts/struts2/trunk/core/src/main/resources/template/simple/optgroup.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/simple/optgroup.ftl?rev=817282&r1=817281&r2=817282&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/template/simple/optgroup.ftl (original)
+++ struts/struts2/trunk/core/src/main/resources/template/simple/optgroup.ftl Mon Sep 21 15:07:03 2009
@@ -38,11 +38,11 @@
 	<#assign tmpKey=stack.findValue(optGroupInternalListUiBean.parameters.listKey) />
 	<#assign tmpValue=stack.findValue(optGroupInternalListUiBean.parameters.listValue) />
 	<#assign tmpKeyStr = tmpKey.toString() />
-	<option value="${tmpKeyStr}"
+	<option value="${tmpKeyStr?html}"
 	<#if tag.contains(parameters.nameValue, tmpKeyStr) == true>
 	selected="selected"
 	</#if>
-	>${tmpValue}
+	>${tmpValue?html}
 	</option>
 <#assign trash=stack.pop() />
 </#list>

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/OptGroupTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/OptGroupTest.java?rev=817282&r1=817281&r2=817282&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/OptGroupTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/OptGroupTest.java Mon Sep 21 15:07:03 2009
@@ -159,4 +159,35 @@
         //System.out.println(writer.toString());
         verify(SelectTag.class.getResource("OptGroup-4.txt"));
     }
+
+    public void testOptGroupForHtmlEncoding() throws Exception {
+        SelectTag selectTag = new SelectTag();
+        selectTag.setMultiple("true");
+        selectTag.setName("mySelection");
+        selectTag.setLabel("My Selection");
+        selectTag.setList("%{#{'ONE':'one','TWO':'two','THREE':'three'}}");
+        selectTag.setValue("%{{'EEE','TWO'}}");
+
+        OptGroupTag optGroupTag1 = new OptGroupTag();
+        optGroupTag1.setLabel("My Label 1");
+        optGroupTag1.setList("%{#{'&':'aaa','<':'bbb','CCC':'<script'}}");
+
+        OptGroupTag optGroupTag2 = new OptGroupTag();
+        optGroupTag2.setLabel("My Label 2");
+        optGroupTag2.setList("%{#{'<cat>':'ddd','EEE':'eee','FFF':'fff'}}");
+
+        selectTag.setPageContext(pageContext);
+        selectTag.doStartTag();
+        optGroupTag1.setPageContext(pageContext);
+        optGroupTag1.doStartTag();
+        optGroupTag1.doEndTag();
+        optGroupTag2.setPageContext(pageContext);
+        optGroupTag2.doStartTag();
+        optGroupTag2.doEndTag();
+        selectTag.doEndTag();
+
+
+        //System.out.println(writer.toString());
+        verify(SelectTag.class.getResource("OptGroup-5.txt"));
+    }
 }

Copied: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/OptGroup-5.txt (from r817250, struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/OptGroup-3.txt)
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/OptGroup-5.txt?p2=struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/OptGroup-5.txt&p1=struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/OptGroup-3.txt&r1=817250&r2=817282&rev=817282&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/OptGroup-3.txt (original)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/OptGroup-5.txt Mon Sep 21 15:07:03 2009
@@ -10,22 +10,21 @@
 	label="My Label 1"
 >
 
-	<option value="AAA"
+	<option value="&amp;"
 	>aaa
 	</option>
-	<option value="BBB"
-	selected="selected"
+	<option value="&lt;"
 	>bbb
 	</option>
 	<option value="CCC"
-	>ccc
+	>&lt;script
 	</option>
 </optgroup>
 <optgroup 
 	label="My Label 2"
 >
 
-	<option value="DDD"
+	<option value="&lt;cat&gt;"
 	>ddd
 	</option>
 	<option value="EEE"