-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for invalid characters in paths
- Loading branch information
1 parent
b822af8
commit 4ca3c3d
Showing
5 changed files
with
151 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2015 Robin Appelman <icewind@owncloud.com> | ||
* This file is licensed under the Licensed under the MIT license: | ||
* http://opensource.org/licenses/MIT | ||
*/ | ||
|
||
namespace Icewind\SMB; | ||
|
||
use Icewind\SMB\Exception\InvalidPathException; | ||
|
||
abstract class AbstractShare implements IShare { | ||
private $forbiddenCharacters; | ||
|
||
public function __construct() { | ||
$this->forbiddenCharacters = array('?', '<', '>', ':', '*', '|', '"', chr(0), "\n"); | ||
} | ||
|
||
protected function verifyPath($path) { | ||
foreach ($this->forbiddenCharacters as $char) { | ||
if (strpos($path, $char) !== false) { | ||
throw new InvalidPathException('Invalid path, "' . $char . '" is not allowed'); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> | ||
* This file is licensed under the Licensed under the MIT license: | ||
* http://opensource.org/licenses/MIT | ||
*/ | ||
|
||
namespace Icewind\SMB\Exception; | ||
|
||
class InvalidPathException extends InvalidRequestException {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters