Re: How to escape a local path so fopen() doesn't consider it a URL?

[email protected] (Jesse Schalken)
Newsgroups php.general
Message-ID <CAF1yvAT5ge-V0ZpE9XhSgYVhxp6XaYTrqwW27=+-Hb-WDVwzpA@mail.gmail.com>
Whoops again, the test should be for a scheme of 2 or more characters, not
1 or more (so it doesn't match C://foo):

function make_path_local(string $path): string {
  if (\preg_match('/^([a-zA-Z0-9+\\-.]{2,}:\\/\\/|data:|zlib:)/Ds', $path))
    return '.' . \DIRECTORY_SEPARATOR . $path;
  return $path;
}

​
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.