/**
- * Case sensitivity.
- */
- protected boolean caseSensitive = true;
-
-
- /**
* Allow linking.
*/
protected boolean allowLinking = false;
/**
- * Set case sensitivity.
- */
- public void setCaseSensitive(boolean caseSensitive) {
- this.caseSensitive = caseSensitive;
- }
-
-
- /**
- * Is case sensitive ?
- */
- public boolean isCaseSensitive() {
- return caseSensitive;
- }
-
-
- /**
* Set allow linking.
*/
public void setAllowLinking(boolean allowLinking) {
}
if (resources instanceof FileDirContext) {
filesystemBased = true;
- ((FileDirContext) resources).setCaseSensitive(isCaseSensitive());
((FileDirContext) resources).setAllowLinking(isAllowLinking());
}
this.webappResources = resources;
new ProxyDirContext(env, webappResources);
if (webappResources instanceof FileDirContext) {
filesystemBased = true;
- ((FileDirContext) webappResources).setCaseSensitive
- (isCaseSensitive());
((FileDirContext) webappResources).setAllowLinking
(isAllowLinking());
}
is="true"
type="boolean"/>
- <attribute name="caseSensitive"
- description="Should case sensitivity checks be performed"
- is="true"
- type="boolean"/>
-
<attribute name="children"
description="Object names of all children"
type="[Ljavax.management.ObjectName;"/>
/**
- * Case sensitivity.
- */
- protected boolean caseSensitive = true;
-
-
- /**
* Allow linking.
*/
protected boolean allowLinking = false;
/**
- * Set case sensitivity.
- */
- public void setCaseSensitive(boolean caseSensitive) {
- this.caseSensitive = caseSensitive;
- }
-
-
- /**
- * Is case sensitive ?
- */
- public boolean isCaseSensitive() {
- return caseSensitive;
- }
-
-
- /**
* Set allow linking.
*/
public void setAllowLinking(boolean allowLinking) {
FileDirContext tempContext = new FileDirContext(env);
tempContext.setDocBase(file.getPath());
tempContext.setAllowLinking(getAllowLinking());
- tempContext.setCaseSensitive(isCaseSensitive());
result = tempContext;
} else {
result = new FileResource(file);
return null;
}
- // Case sensitivity check
- if (caseSensitive) {
- String fileAbsPath = file.getAbsolutePath();
- if (fileAbsPath.endsWith("."))
- fileAbsPath = fileAbsPath + "/";
- String absPath = normalize(fileAbsPath);
- canPath = normalize(canPath);
- if ((absoluteBase.length() < absPath.length())
- && (absoluteBase.length() < canPath.length())) {
- absPath = absPath.substring(absoluteBase.length() + 1);
- if (absPath == null)
- return null;
- if (absPath.equals(""))
- absPath = "/";
- canPath = canPath.substring(absoluteBase.length() + 1);
- if (canPath.equals(""))
- canPath = "/";
- if (!canPath.equals(absPath))
- return null;
- }
+ // Case sensitivity check - this is now always done
+ String fileAbsPath = file.getAbsolutePath();
+ if (fileAbsPath.endsWith("."))
+ fileAbsPath = fileAbsPath + "/";
+ String absPath = normalize(fileAbsPath);
+ canPath = normalize(canPath);
+ if ((absoluteBase.length() < absPath.length())
+ && (absoluteBase.length() < canPath.length())) {
+ absPath = absPath.substring(absoluteBase.length() + 1);
+ if (absPath == null)
+ return null;
+ if (absPath.equals(""))
+ absPath = "/";
+ canPath = canPath.substring(absoluteBase.length() + 1);
+ if (canPath.equals(""))
+ canPath = "/";
+ if (!canPath.equals(absPath))
+ return null;
}
} else {
FileDirContext tempContext = new FileDirContext(env);
tempContext.setDocBase(file.getPath());
tempContext.setAllowLinking(getAllowLinking());
- tempContext.setCaseSensitive(isCaseSensitive());
object = tempContext;
} else {
object = new FileResource(currentFile);
// did we computed the hashcode ?
private boolean hasHashCode=false;
- // Is the represented object case sensitive ?
- private boolean caseSensitive=true;
-
// Internal objects to represent array + offset, and specific methods
private ByteChunk byteC=new ByteChunk();
private CharChunk charC=new CharChunk();
return factory.newInstance();
}
- /** Configure the case sensitivity
- */
- public void setCaseSenitive( boolean b ) {
- caseSensitive=b;
- }
-
public MessageBytes getClone() {
try {
return (MessageBytes)this.clone();
charC.recycle();
strValue=null;
- caseSensitive=true;
hasStrValue=false;
hasHashCode=false;
* @return true if the comparison succeeded, false otherwise
*/
public boolean equals(String s) {
- if( ! caseSensitive )
- return equalsIgnoreCase( s );
switch (type) {
case T_STR:
if( strValue==null && s!=null) return false;
// -------------------- Hash code --------------------
public int hashCode() {
- if( hasHashCode ) return hashCode;
- int code = 0;
+ if( hasHashCode ) return hashCode;
+ int code = 0;
- if( caseSensitive )
- code=hash();
- else
- code=hashIgnoreCase();
- hashCode=code;
- hasHashCode=true;
- return code;
+ code=hash();
+ hashCode=code;
+ hasHashCode=true;
+ return code;
}
// normal hash.
}
}
- // hash ignoring case
- private int hashIgnoreCase() {
- int code=0;
- switch (type) {
- case T_STR:
- for (int i = 0; i < strValue.length(); i++) {
- code = code * 37 + Ascii.toLower(strValue.charAt( i ));
- }
- return code;
- case T_CHARS:
- return charC.hashIgnoreCase();
- case T_BYTES:
- return byteC.hashIgnoreCase();
- default:
- return 0;
- }
- }
-
public int indexOf(char c) {
return indexOf( c, 0);
}
of the flag is <code>true</code>.</p>
</attribute>
- <attribute name="caseSensitive" required="false">
- <p>If the value of this flag is <code>false</code>, all case sensitivity
- checks will be disabled. If not
- specified, the default value of the flag is <code>true</code>.</p>
- <p><b>NOTE: This flag MUST NOT be set to false on the Windows platform
- (or any other OS which does not have a case sensitive filesystem),
- as it will disable case sensitivity checks, allowing JSP source code
- disclosure, among other security problems.</b></p>
- </attribute>
-
<attribute name="processTlds" required="false">
<p>Whether the context should process TLDs on startup. The default
is true. The false setting is intended for special cases