Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| RegexUnixFilename | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @author: Doug Wilbourne (dougwilbourne@gmail.com) |
| 5 | */ |
| 6 | declare(strict_types=1); |
| 7 | |
| 8 | namespace pvc\regex\filename; |
| 9 | |
| 10 | use pvc\regex\Regex; |
| 11 | |
| 12 | /** |
| 13 | * Class RegexUnixFilename |
| 14 | */ |
| 15 | class RegexUnixFilename extends Regex |
| 16 | { |
| 17 | public function __construct() |
| 18 | { |
| 19 | $label = 'valid Unix filename'; |
| 20 | /** |
| 21 | * I think a technically correct answer to this is any set of characters at all, including Unicode. As a |
| 22 | * practical matter, we will not allow '/' (\x{005C}) and NUL (\x{0000}) in the pattern below). |
| 23 | * |
| 24 | * Note that this regex checks for illegitimate characters in a filename but is not checking the length of |
| 25 | * the filename. Length checking should be done elsewhere and should be done on byte length, not number of |
| 26 | * characters (which is what pcre quantifiers calculate). |
| 27 | */ |
| 28 | $pattern = '/^[^\x{0000}\x{0005C}]*$/u'; |
| 29 | $this->setPattern($pattern); |
| 30 | $this->setLabel($label); |
| 31 | } |
| 32 | } |