diff --git a/hphp/runtime/base/builtin-functions.cpp b/hphp/runtime/base/builtin-functions.cpp index 2ffd026edaefda..585f5ba8221ca4 100644 --- a/hphp/runtime/base/builtin-functions.cpp +++ b/hphp/runtime/base/builtin-functions.cpp @@ -818,8 +818,9 @@ String resolve_include(const String& file, const char* currentDir, for (int i = 0; i < (int)path_count; i++) { String path(""); String includePath(includePaths[i]); + bool is_stream_wrapper = (includePath.find("://") > 0); - if (includePath[0] != '/') { + if (!is_stream_wrapper && includePath[0] != '/') { path += (g_context->getCwd() + "/"); } @@ -830,7 +831,13 @@ String resolve_include(const String& file, const char* currentDir, } path += file; - String can_path = FileUtil::canonicalize(path); + + String can_path; + if (!is_stream_wrapper) { + can_path = FileUtil::canonicalize(path); + } else { + can_path = String(path.c_str()); + } if (tryFile(can_path, ctx)) { return can_path; diff --git a/hphp/runtime/base/request-injection-data.cpp b/hphp/runtime/base/request-injection-data.cpp index 50cba232912bec..0d3234304271c0 100644 --- a/hphp/runtime/base/request-injection-data.cpp +++ b/hphp/runtime/base/request-injection-data.cpp @@ -102,11 +102,35 @@ void RequestInjectionData::threadInit() { "include_path", getDefaultIncludePath().c_str(), IniSetting::SetAndGet( [this](const std::string& value) { - auto paths = HHVM_FN(explode)(":", value); m_include_paths.clear(); - for (ArrayIter iter(paths); iter; ++iter) { - m_include_paths.push_back( - iter.second().toString().toCppString()); + int pos = value.find(':'); + if (pos < 0) { + m_include_paths.push_back(value); + } else { + int pos0 = 0; + do { + // Check for stream wrapper + if (value.length() > pos + 2 && + value[pos + 1] == '/' && + value[pos + 2] == '/') { + // .:// or ..:// is not stream wrapper + if (((pos - pos0) >= 1 && value[pos - 1] != '.') || + ((pos - pos0) >= 2 && value[pos - 2] != '.') || + (pos - pos0) > 2) { + pos += 3; + continue; + } + } + m_include_paths.push_back( + value.substr(pos0, pos - pos0)); + pos++; + pos0 = pos; + } while ((pos = value.find(':', pos)) >= 0); + + if (pos0 <= value.length()) { + m_include_paths.push_back( + value.substr(pos0)); + } } return true; }, diff --git a/hphp/test/frameworks/results/vfsstream.expect b/hphp/test/frameworks/results/vfsstream.expect index d892341ceefd60..6bd3debef334d8 100644 --- a/hphp/test/frameworks/results/vfsstream.expect +++ b/hphp/test/frameworks/results/vfsstream.expect @@ -259,7 +259,7 @@ org\bovigo\vfs\vfsStreamFileTestCase::writeEmptyFile org\bovigo\vfs\vfsStreamGlobTestCase::globDoesNotWorkWithVfsStreamUrls . org\bovigo\vfs\vfsStreamResolveIncludePathTestCase::knownFileCanBeResolved -F +. org\bovigo\vfs\vfsStreamResolveIncludePathTestCase::unknownFileCanNotBeResolvedYieldsFalse . org\bovigo\vfs\vfsStreamTestCase::copyFromEmptyFolder