mirror of
https://github.com/standardebooks/web.git
synced 2025-07-17 20:06:39 -04:00
Handle exception for a possible attack vector
This commit is contained in:
parent
042816cf45
commit
65c4578a4e
1 changed files with 8 additions and 1 deletions
|
@ -73,8 +73,15 @@ class Ebook{
|
||||||
$this->RepoFilesystemPath = SITE_ROOT . '/ebooks/' . str_replace('/', '_', $this->RepoFilesystemPath) . '.git';
|
$this->RepoFilesystemPath = SITE_ROOT . '/ebooks/' . str_replace('/', '_', $this->RepoFilesystemPath) . '.git';
|
||||||
|
|
||||||
if(!is_dir($this->RepoFilesystemPath)){ // On dev systems we might not have the bare repos, so make an adjustment
|
if(!is_dir($this->RepoFilesystemPath)){ // On dev systems we might not have the bare repos, so make an adjustment
|
||||||
|
try{
|
||||||
$this->RepoFilesystemPath = preg_replace('/\.git$/ius', '', $this->RepoFilesystemPath);
|
$this->RepoFilesystemPath = preg_replace('/\.git$/ius', '', $this->RepoFilesystemPath);
|
||||||
}
|
}
|
||||||
|
catch(Exception){
|
||||||
|
// We may get an exception from preg_replace if the passed repo wwwFilesystemPath contains invalid UTF8 characters,
|
||||||
|
// which a common injection attack vector
|
||||||
|
throw new Exceptions\InvalidEbookException('Invalid repo filesystem path: ' . $this->RepoFilesystemPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!is_dir($wwwFilesystemPath)){
|
if(!is_dir($wwwFilesystemPath)){
|
||||||
throw new Exceptions\InvalidEbookException('Invalid www filesystem path: ' . $wwwFilesystemPath);
|
throw new Exceptions\InvalidEbookException('Invalid www filesystem path: ' . $wwwFilesystemPath);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue