|
|
|
@ -99,13 +99,12 @@ public final class plasmaHTCache {
|
|
|
|
|
|
|
|
|
|
this.log = new serverLog("HTCACHE");
|
|
|
|
|
this.cachePath = htCachePath;
|
|
|
|
|
this.maxCacheSize = maxCacheSize;
|
|
|
|
|
|
|
|
|
|
// reset old HTCache ?
|
|
|
|
|
final String[] list = cachePath.list();
|
|
|
|
|
if (list != null) {
|
|
|
|
|
File object;
|
|
|
|
|
for (int i = list.length - 1; i >= 0 ; i--) {
|
|
|
|
|
for (int i = list.length - 1; i >= 0; i--) {
|
|
|
|
|
object = new File(cachePath, list[i]);
|
|
|
|
|
if (object.isDirectory()) {
|
|
|
|
|
if (!object.getName().equals("http") &&
|
|
|
|
@ -258,7 +257,7 @@ public final class plasmaHTCache {
|
|
|
|
|
return deleteURLfromCache(url, "FROM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean deleteURLfromCache (URL url, String msg) {
|
|
|
|
|
private boolean deleteURLfromCache(URL url, String msg) {
|
|
|
|
|
if (deleteFileandDirs(getCachePath(url), msg)) {
|
|
|
|
|
try {
|
|
|
|
|
// As the file is gone, the entry in responseHeader.db is not needed anymore
|
|
|
|
@ -534,6 +533,15 @@ public final class plasmaHTCache {
|
|
|
|
|
path = matcher.replaceAll("/!!/");
|
|
|
|
|
matcher.reset(path);
|
|
|
|
|
}
|
|
|
|
|
if (path != null) {
|
|
|
|
|
// yes this is not reversible, but that is not needed
|
|
|
|
|
searchPattern = Pattern.compile("(\"|\\\\|\\*|\\?|:|<|>|\\|)");
|
|
|
|
|
matcher = searchPattern.matcher(path);
|
|
|
|
|
while (matcher.find()) {
|
|
|
|
|
path = matcher.replaceAll("_");
|
|
|
|
|
matcher.reset(path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (query != null) {
|
|
|
|
|
// yes this is not reversible, but that is not needed
|
|
|
|
|
searchPattern = Pattern.compile("(\"|\\\\|\\*|\\?|/|:|<|>|\\|)");
|
|
|
|
@ -664,6 +672,8 @@ public final class plasmaHTCache {
|
|
|
|
|
|
|
|
|
|
public final class Entry {
|
|
|
|
|
|
|
|
|
|
public static final int MAXLENGTH = 255;
|
|
|
|
|
|
|
|
|
|
// the class objects
|
|
|
|
|
public Date initDate; // the date when the request happened; will be used as a key
|
|
|
|
|
public int depth; // the depth of prefetching
|
|
|
|
@ -724,7 +734,7 @@ public final class plasmaHTCache {
|
|
|
|
|
this.responseStatus = responseStatus;
|
|
|
|
|
this.responseHeader = responseHeader;
|
|
|
|
|
this.profile = profile;
|
|
|
|
|
this.initiator = (initiator == null) ? null : ((initiator.length() == 0) ? null: initiator);
|
|
|
|
|
this.initiator = (initiator == null) ? null : ((initiator.length() == 0) ? null : initiator);
|
|
|
|
|
|
|
|
|
|
// calculated:
|
|
|
|
|
if (responseHeader == null) {
|
|
|
|
@ -801,7 +811,7 @@ public final class plasmaHTCache {
|
|
|
|
|
// we cannot match that here in the cache file path and therefore omit writing into the cache
|
|
|
|
|
if (this.cacheFile.getParentFile().isFile() || this.cacheFile.isDirectory()) { return "path_ambiguous"; }
|
|
|
|
|
if (this.cacheFile.toString().indexOf("..") >= 0) { return "path_dangerous"; }
|
|
|
|
|
if (this.cacheFile.getAbsolutePath().length() > 250) { return "path too long"; }
|
|
|
|
|
if (this.cacheFile.getAbsolutePath().length() > MAXLENGTH) { return "path too long"; }
|
|
|
|
|
|
|
|
|
|
// -CGI access in request
|
|
|
|
|
// CGI access makes the page very individual, and therefore not usable in caches
|
|
|
|
|