Re: How to escape a local path so fopen() doesn't consider it a URL?
| From: | Jesse Schalken | Date: | Wed, 21 Dec 2016 12:55:35 +0000 |
| Subject: | Re: How to escape a local path so fopen() doesn't consider it a URL? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325912@lists.php.net to get a copy of this message | ||
Whoops, the regex should include 0-9 in the character range (the test in
the C code is isalnum() not isalpha()):
function make_path_local(string $path): string {
if (\preg_match('/^([a-zA-Z0-9+\\-.]+:\\/\\/|data:|zlib:)/Ds', $path))
return '.' . \DIRECTORY_SEPARATOR . $path;
return $path;
}