Re: How to escape a local path so fopen() doesn't consider it a URL?
[email protected] (Jesse Schalken)
| Newsgroups | php.general |
|---|---|
| Message-ID | <CAF1yvAQWJtOZBx9_9uyYq=OyUbo_sNaQtU_HxwLe6QGFuQO+9A@mail.gmail.com> |
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;
}