Permalink
Browse files

fix(cache): ElggFileCache now handles arbitrary cache keys

  • Loading branch information...
mrclay committed Sep 8, 2016
1 parent ff276c1 commit e60b83683a2acfb61e4e66ce901d4b02e3ce54fa
Showing with 16 additions and 11 deletions.
  1. +16 −11 engine/classes/ElggFileCache.php
@@ -60,30 +60,35 @@ protected function createFile($filename, $rw = "rb") {
/**
* Create a sanitised filename for the file.
*
* @deprecated 1.8 Use \ElggFileCache::sanitizeFilename()
*
* @param string $filename The filename
* @param string $key The filename
*
* @return string
* @deprecated 1.8 Use \ElggFileCache::sanitizeFilename()
*/
protected function sanitise_filename($filename) {
// @todo : Writeme
return $filename;
protected function sanitise_filename($key) {
return $this->sanitizeFilename($key);
}
// @codingStandardsIgnoreEnd
/**
* Create a sanitised filename for the file.
*
* @param string $filename The filename
* @param string $key The filename
*
* @return string
*/
protected function sanitizeFilename($filename) {
// @todo : Writeme
protected function sanitizeFilename($key) {
// handles all keys in use by core
if (preg_match('~^[a-zA-Z0-9\-_\.]{1,250}$~', $key)) {
return $key;
}
$key = md5($key);
// prevent collision with un-hashed keys
$key = "=" . $key;
return $filename;
return $key;
}
/**

0 comments on commit e60b836

Please sign in to comment.