From 6faa4e2ca636627c12317edf0eb38f6c9a500a81 Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Wed, 24 Jul 2013 14:59:07 -0700 Subject: [PATCH] handle file:// includes Now that we can include urls, we shoudl handle `file://`. --- hphp/runtime/base/file_repository.cpp | 5 +++++ hphp/test/slow/include/file_include.php | 3 +++ hphp/test/slow/include/file_include.php.expectf | 1 + hphp/test/slow/include/file_include.php.norepo | 0 hphp/test/slow/include/hello.inc | 3 +++ 5 files changed, 12 insertions(+) create mode 100644 hphp/test/slow/include/file_include.php create mode 100644 hphp/test/slow/include/file_include.php.expectf create mode 100644 hphp/test/slow/include/file_include.php.norepo create mode 100644 hphp/test/slow/include/hello.inc diff --git a/hphp/runtime/base/file_repository.cpp b/hphp/runtime/base/file_repository.cpp index 7ef62d42f..adb60cd20 100644 --- a/hphp/runtime/base/file_repository.cpp +++ b/hphp/runtime/base/file_repository.cpp @@ -492,6 +492,11 @@ static bool findFileWrapper(CStrRef file, void* ctx) { } } + // handle file:// + if (file.substr(0, 7) == "file://") { + return findFileWrapper(file.substr(7), ctx); + } + // TranslatePath() will canonicalize the path and also check // whether the file is in an allowed directory. String translatedPath = File::TranslatePathKeepRelative(file); diff --git a/hphp/test/slow/include/file_include.php b/hphp/test/slow/include/file_include.php new file mode 100644 index 000000000..faef56f5f --- /dev/null +++ b/hphp/test/slow/include/file_include.php @@ -0,0 +1,3 @@ +