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

(-)java/org/apache/jasper/compiler/Generator.java (-1 / +1 lines)
Lines 1839-1845 Link Here
1839
                        out.print(" + \"\\\"");
1839
                        out.print(" + \"\\\"");
1840
                    } else {
1840
                    } else {
1841
                        out.print(DOUBLE_QUOTE);
1841
                        out.print(DOUBLE_QUOTE);
1842
                        out.print(attrs.getValue(i).replace("\"", """));
1842
                        out.print(jspAttrs[i].getValue().replace("\"", """));
1843
                        out.print(DOUBLE_QUOTE);
1843
                        out.print(DOUBLE_QUOTE);
1844
                    }
1844
                    }
1845
                }
1845
                }
(-)java/org/apache/jasper/compiler/Validator.java (-1 / +1 lines)
Lines 1402-1408 Link Here
1402
1402
1403
                    } else {
1403
                    } else {
1404
                        result = new Node.JspAttribute(tai, qName, uri,
1404
                        result = new Node.JspAttribute(tai, qName, uri,
1405
                                localName, value, false, null, dynamic);
1405
                                localName, xmlEscape(value), false, null, dynamic);
1406
                    }
1406
                    }
1407
                }
1407
                }
1408
            } else {
1408
            } else {
(-)test/org/apache/jasper/compiler/TestParser.java (-11 / +53 lines)
Lines 14-20 Link Here
14
 * See the License for the specific language governing permissions and
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
15
 * limitations under the License.
16
 */
16
 */
17
18
package org.apache.jasper.compiler;
17
package org.apache.jasper.compiler;
19
18
20
import java.io.File;
19
import java.io.File;
Lines 27-34 Link Here
27
import org.junit.Assert;
26
import org.junit.Assert;
28
import org.junit.Test;
27
import org.junit.Test;
29
28
29
import org.apache.catalina.WebResourceRoot;
30
import org.apache.catalina.core.StandardContext;
30
import org.apache.catalina.startup.Tomcat;
31
import org.apache.catalina.startup.Tomcat;
31
import org.apache.catalina.startup.TomcatBaseTest;
32
import org.apache.catalina.startup.TomcatBaseTest;
33
import org.apache.catalina.webresources.StandardRoot;
32
import org.apache.tomcat.util.buf.ByteChunk;
34
import org.apache.tomcat.util.buf.ByteChunk;
33
35
34
/**
36
/**
Lines 328-345 Link Here
328
330
329
        String result = res.toString();
331
        String result = res.toString();
330
332
331
        Assert.assertTrue(result.contains(""1foo1"") ||
333
        Assert.assertTrue(result,
332
                result.contains(""1foo1""));
334
                result.contains(""1foo1<&>"")
333
        Assert.assertTrue(result.contains(""2bar2"") ||
335
             || result.contains(""1foo1<&>""));
334
                result.contains(""2bar2""));
336
        Assert.assertTrue(result,
335
        Assert.assertTrue(result.contains(""3a&b3"") ||
337
                result.contains(""2bar2<&>"")
336
                result.contains(""3a&b3""));
338
             || result.contains(""2bar2<&>""));
337
        Assert.assertTrue(result.contains(""4&4"") ||
339
        Assert.assertTrue(result,
338
                result.contains(""4&4""));
340
                result.contains(""3a&b3"")
339
        Assert.assertTrue(result.contains(""5'5"") ||
341
             || result.contains(""3a&b3""));
340
                result.contains(""5'5""));
342
        Assert.assertTrue(result,
343
                result.contains(""4&4"")
344
             || result.contains(""4&4""));
345
        Assert.assertTrue(result,
346
                result.contains(""5'5"")
347
             || result.contains(""5'5""));
341
    }
348
    }
342
349
350
    @Test
351
    public void testBug56265() throws Exception {
352
        Tomcat tomcat = getTomcatInstance();
353
354
        File appDir = new File("test/webapp");
355
        // app dir is relative to server home
356
        StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
357
                "/test", appDir.getAbsolutePath());
358
359
        // This test needs the JSTL libraries
360
        File lib = new File("webapps/examples/WEB-INF/lib");
361
        ctxt.setResources(new StandardRoot(ctxt));
362
        ctxt.getResources().createWebResourceSet(
363
                WebResourceRoot.ResourceSetType.POST, "/WEB-INF/lib",
364
                lib.getAbsolutePath(), null, "/");
365
366
        tomcat.start();
367
368
        ByteChunk res = getUrl("http://localhost:" + getPort() +
369
                "/test/bug5nnnn/bug56265.jsp");
370
371
        String result = res.toString();
372
373
        Assert.assertTrue(result,
374
                result.contains("[1: [data-test]: [window.alert('Hello World <&>!')]]") ||
375
                result.contains("[1: [data-test]: [window.alert('Hello World <&>!')]]"));
376
        Assert.assertTrue(result,
377
                result.contains("[2: [data-test]: [window.alert('Hello World <&>!')]]"));
378
        Assert.assertTrue(result,
379
                result.contains("[3: [data-test]: [window.alert('Hello 'World &lt;&amp;&gt;'!')]]") ||
380
                result.contains("[3: [data-test]: [window.alert(&#039;Hello &#039;World &lt;&amp;&gt;&#039;!&#039;)]]"));
381
        Assert.assertTrue(result,
382
                result.contains("[4: [data-test]: [window.alert('Hello 'World <&>'!')]]"));
383
    }
384
343
    /** Assertion for text printed by tags:echo */
385
    /** Assertion for text printed by tags:echo */
344
    private static void assertEcho(String result, String expected) {
386
    private static void assertEcho(String result, String expected) {
345
        assertTrue(result.indexOf("<p>" + expected + "</p>") > 0);
387
        assertTrue(result.indexOf("<p>" + expected + "</p>") > 0);
(-)test/webapp/WEB-INF/tags/bug55198.tagx (-2 / +2 lines)
Lines 17-24 Link Here
17
-->
17
-->
18
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
18
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
19
<jsp:directive.tag body-content="scriptless" />
19
<jsp:directive.tag body-content="scriptless" />
20
<a href="#" onclick="window.alert(&quot;1${'foo'}1&quot;)">foo</a>
20
<a href="#" onclick="window.alert(&quot;1${'foo'}1&lt;&amp;&gt;&quot;)">foo</a>
21
<a href="#" onclick="window.alert(&quot;2bar2&quot;)">bar</a>
21
<a href="#" onclick="window.alert(&quot;2bar2&lt;&amp;&gt;&quot;)">bar</a>
22
<a href="#" onclick="window.alert(&quot;3${text}3&quot;)">foo</a>
22
<a href="#" onclick="window.alert(&quot;3${text}3&quot;)">foo</a>
23
<a href="#" onclick="window.alert(&quot;4${'&amp;'}4&quot;)">foo</a>
23
<a href="#" onclick="window.alert(&quot;4${'&amp;'}4&quot;)">foo</a>
24
<a href="#" onclick="window.alert(&quot;5${'&amp;apos;'}5&quot;)">foo</a>
24
<a href="#" onclick="window.alert(&quot;5${'&amp;apos;'}5&quot;)">foo</a>
(-)test/webapp/WEB-INF/tags/bug56265.tagx (+24 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!--
3
  Licensed to the Apache Software Foundation (ASF) under one or more
4
  contributor license agreements.  See the NOTICE file distributed with
5
  this work for additional information regarding copyright ownership.
6
  The ASF licenses this file to You under the Apache License, Version 2.0
7
  (the "License"); you may not use this file except in compliance with
8
  the License.  You may obtain a copy of the License at
9
10
      http://www.apache.org/licenses/LICENSE-2.0
11
12
  Unless required by applicable law or agreed to in writing, software
13
  distributed under the License is distributed on an "AS IS" BASIS,
14
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
  See the License for the specific language governing permissions and
16
  limitations under the License.
17
-->
18
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
19
 xmlns:c="http://java.sun.com/jsp/jstl/core">
20
  <jsp:directive.tag body-content="empty" dynamic-attributes="attMap" />
21
  <c:forEach var="e" items="${attMap}">
22
    <jsp:text>[${e.key}]: [${e.value}]</jsp:text>
23
  </c:forEach>
24
</jsp:root>
(-)test/webapp/bug5nnnn/bug56265.jsp (+30 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
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
18
<%
19
request.setAttribute("text", "World <&>");
20
request.setAttribute("textQuote", "'World <&>'");
21
%>
22
<html>
23
  <head><title>Bug 56265 test case</title></head>
24
  <body>
25
    <p>[1: <tags:bug56265 data-test="window.alert('Hello World <&>!')"/>]</p>
26
    <p>[2: <tags:bug56265 data-test="window.alert('Hello ${text}!')"/>]</p>
27
    <p>[3: <tags:bug56265 data-test="window.alert('Hello &apos;World <&>&apos;!')"/>]</p>
28
    <p>[4: <tags:bug56265 data-test="window.alert('Hello ${textQuote}!')"/>]</p>
29
  </body>
30
</html>

Return to bug 56265