ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/ssi/TestRegExpCapture.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/ssi/TestRegExpCapture.java
Status
scanned
Type
file
Name
TestRegExpCapture.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3549 (3.5 KB)
MD5
580b4f0aa7c8fb9655fa7ccfa7160c33
SHA1
340a4b3436dbeaeb133ad11ac8b6ce1285be15b3
SHA256
72ec4ba24114e51f5249678cd11be9ccd4c0b00c6fb5d44dbf511188a0c3eefd
SHA512

      
    
SHA1_git
3092330f286c3c8a5e86c5dbcf79768c7e3fb9d0
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestRegExpCapture.java | 3.5 KB |

/* * 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. */ package org.apache.catalina.ssi; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.apache.catalina.Context; import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.TomcatBaseTest; import org.apache.tomcat.util.buf.ByteChunk; import org.apache.tomcat.util.descriptor.web.FilterDef; import org.apache.tomcat.util.descriptor.web.FilterMap; @RunWith(Parameterized.class) public class TestRegExpCapture extends TomcatBaseTest { @Parameters(name = "{index}: [{0}]") public static Collection<Object[]> parameters() { List<Object[]> parameterSets = new ArrayList<>(); // d is always the empty string // Neither a nor b are set, c is empty parameterSets.add(new Object[] { "", "<p>a(none)b(none)cd</p>" }); // a is set, b is not, c is empty parameterSets.add(new Object[] { "?a=1", "<p>a1b(none)cd</p>" }); // a is not set, b is set, c is the same as b parameterSets.add(new Object[] { "?b=1", "<p>a(none)b1c1d</p>" }); return parameterSets; } private final String queryString; private final String expectedInBody; public TestRegExpCapture(String queryString, String expectedInBody) { this.queryString = queryString; this.expectedInBody = expectedInBody; } @Test public void testBug53387() throws Exception { Tomcat tomcat = getTomcatInstance(); File appDir = new File("test/webapp"); Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); // SSI requires a privileged Context ctx.setPrivileged(true); FilterDef ssiFilter = new FilterDef(); ssiFilter.setFilterName("ssiFilter"); ssiFilter.setFilterClass(SSIFilter.class.getName()); FilterMap ssiFilterMap = new FilterMap(); ssiFilterMap.setFilterName("ssiFilter"); ssiFilterMap.addURLPatternDecoded("*.shtml"); ctx.addFilterDef(ssiFilter); ctx.addFilterMap(ssiFilterMap); ctx.addMimeMapping("shtml", "text/x-server-parsed-html"); tomcat.start(); ByteChunk body = new ByteChunk(); int rc = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug53387.shtml" + queryString, body, null); Assert.assertEquals(200, rc); String text = body.toString(); Assert.assertTrue(text, text.contains(expectedInBody)); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
29.82
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9