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

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

      
    
Rootfs path

      
    
Size
3126 (3.1 KB)
MD5
231aec88dc0e8b8071f2bc93abab17a3
SHA1
4c119abe0ebafa0698d7d4d737d1215e9e003fed
SHA256
f2dbaf6f86666598ed201337de385b4a9d3b532c88921da205d564f81e53bdca
SHA512

      
    
SHA1_git
df732dac8c5c8ae364ce3971dbd93ae1bd40a466
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
SSIEcho.java | 3.1 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.PrintWriter; import org.apache.tomcat.util.res.StringManager; /** * Return the result associated with the supplied Server Variable. */ public class SSIEcho implements SSICommand { private static final StringManager sm = StringManager.getManager(SSIEcho.class); protected static final String DEFAULT_ENCODING = SSIMediator.ENCODING_ENTITY; protected static final String MISSING_VARIABLE_VALUE = "(none)"; @Override public long process(SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues, PrintWriter writer) { String encoding = DEFAULT_ENCODING; String originalValue = null; String errorMessage = ssiMediator.getConfigErrMsg(); for (int i = 0; i < paramNames.length; i++) { String paramName = paramNames[i]; String paramValue = paramValues[i]; if (paramName.equalsIgnoreCase("var")) { originalValue = paramValue; } else if (paramName.equalsIgnoreCase("encoding")) { if (isValidEncoding(paramValue)) { encoding = paramValue; } else { ssiMediator.log(sm.getString("ssiEcho.invalidEncoding", paramValue)); writer.write(ssiMediator.encode(errorMessage, SSIMediator.ENCODING_ENTITY)); } } else { ssiMediator.log(sm.getString("ssiCommand.invalidAttribute", paramName)); writer.write(ssiMediator.encode(errorMessage, SSIMediator.ENCODING_ENTITY)); } } String variableValue = (originalValue == null) ? MISSING_VARIABLE_VALUE : ssiMediator.getVariableValue(originalValue, encoding); if (variableValue == null) { variableValue = MISSING_VARIABLE_VALUE; } writer.write(variableValue); return System.currentTimeMillis(); } protected boolean isValidEncoding(String encoding) { return encoding.equalsIgnoreCase(SSIMediator.ENCODING_URL) || encoding.equalsIgnoreCase(SSIMediator.ENCODING_ENTITY) || encoding.equalsIgnoreCase(SSIMediator.ENCODING_NONE); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
38.76
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