aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Girish Ramakrishnan <mail@girish.in> 2018-06-01 14:19:24 -0700
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-06-01 23:19:23 +0200
commitfa3532dc8eec13edaff0a9c9fe145236a0eccde3 (patch)
treee2fb55feb46e40bcfcafc2024ddb23c8ce28d529
parent4c8f1472382e9bf4f5d0cea0d9fe886c7bbe971b (diff)
Use realpath of EXTENSIONS_PATH (#1911)
This handles the case where the extensions directory might be a symlink
-rw-r--r--p/ext.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/p/ext.php b/p/ext.php
index bb16d02d3..427bdc253 100644
--- a/p/ext.php
+++ b/p/ext.php
@@ -19,13 +19,14 @@ require(__DIR__ . '/../constants.php');
*/
function is_valid_path($path) {
// It must be under the extension path.
- $in_ext_path = (substr($path, 0, strlen(EXTENSIONS_PATH)) === EXTENSIONS_PATH);
+ $real_ext_path = realpath(EXTENSIONS_PATH);
+ $in_ext_path = (substr($path, 0, strlen($real_ext_path)) === $real_ext_path);
if (!$in_ext_path) {
return false;
}
// File to serve must be under a `ext_dir/static/` directory.
- $path_relative_to_ext = substr($path, strlen(EXTENSIONS_PATH) + 1);
+ $path_relative_to_ext = substr($path, strlen($real_ext_path) + 1);
$path_splitted = explode('/', $path_relative_to_ext);
if (count($path_splitted) < 3 || $path_splitted[1] !== 'static') {
return false;