From fe79fe390fadf023891fcee49b78715fe45f4cd2 Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 12 Apr 2021 10:31:17 -0600 Subject: [PATCH] Avoid caching when the url contains links, avoids problems with eg: /apps/InfoLog/Open/2021 --- api/src/Vfs/Base.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/api/src/Vfs/Base.php b/api/src/Vfs/Base.php index 00babfef63..22efd6b556 100644 --- a/api/src/Vfs/Base.php +++ b/api/src/Vfs/Base.php @@ -281,7 +281,7 @@ class Base } if (($relative = substr($parts['path'],strlen($mounted)))) { - $url = Vfs::concat($url,$relative); + $url = Vfs::concat($url, $relative); } // if url contains url parameter, eg. from filesystem streamwrapper, we need to append relative path here too $matches = null; @@ -307,7 +307,21 @@ class Base } $url = $replace; } - if ($replace_user_pass_host) self::$resolve_url_cache[$path] = ['url' => $url, 'mounted' => $mounted]; + + // Make sure we don't cache anything with a link anywhere in the url, since it fails with eg: /apps/InfoLog/Open$/2021$. + // is_link() is not always right here + $is_link = is_link($url) || (self::symlinkCache_resolve(Vfs::parse_url($url,PHP_URL_PATH)) !== $url); + if($is_link) + { + $old_url = $url; + $_url = self::symlinkCache_resolve(Vfs::parse_url($url,PHP_URL_PATH)); + $url = @readlink($url) ?: ($_url != $parts['path'] ? str_replace($parts['path'],$_url,$url) : null) ?:$url; + $is_link = $old_url == $url; + } + if ($replace_user_pass_host && !$is_link) + { + self::$resolve_url_cache[$path] = ['url' => $url, 'mounted' => $mounted]; + } return $url; }