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 |
Assert.assertTrue(result, |
376 |
result.contains("[2: [data-test]: [window.alert('Hello World <&>!')]]")); |
377 |
Assert.assertTrue(result, |
378 |
result.contains("[3: [data-test]: [window.alert('Hello 'World <&>'!')]]")); |
379 |
Assert.assertTrue(result, |
380 |
result.contains("[4: [data-test]: [window.alert('Hello 'World <&>'!')]]")); |
381 |
} |
382 |
|
343 |
/** Assertion for text printed by tags:echo */ |
383 |
/** Assertion for text printed by tags:echo */ |
344 |
private static void assertEcho(String result, String expected) { |
384 |
private static void assertEcho(String result, String expected) { |
345 |
assertTrue(result.indexOf("<p>" + expected + "</p>") > 0); |
385 |
assertTrue(result.indexOf("<p>" + expected + "</p>") > 0); |