fix Framework::includeJS("", "app", "filemanager") failed on client-side, due to a double slash "//" in path

also fixed various warnings
This commit is contained in:
ralf 2024-09-17 08:46:59 +02:00
parent cc72c6ff60
commit e184d5bdcd
2 changed files with 5 additions and 5 deletions

View File

@ -1510,7 +1510,7 @@ abstract class Framework extends Framework\Extra
static function includeJS($package, $file=null, $app='api', $append=true)
{
// prefer app.min.js over old, pre RollupJS app.js
if ($package[0] === '/' && substr($package, -7) === '/app.js' &&
if ($package && $package[0] === '/' && substr($package, -7) === '/app.js' &&
self::$js_include_mgr->include_js_file(substr($package, 0, -3).'.min.js', $file, $app, $append) ||
$file === 'app' && self::$js_include_mgr->include_js_file($package, 'app.min', $app, $append))
{

View File

@ -314,10 +314,10 @@ class IncludeMgr
*/
private function translate_params($package, $file=null, $app='api')
{
if ($package[0] == '/' && is_readable(EGW_SERVER_ROOT.parse_url($path = $package, PHP_URL_PATH)) ||
if ($package && $package[0] == '/' && is_readable(EGW_SERVER_ROOT.parse_url($path = $package, PHP_URL_PATH)) ||
// fix old /phpgwapi/js/ path by replacing it with /api/js/
substr($package, 0, 13) == '/phpgwapi/js/' && is_readable(EGW_SERVER_ROOT.parse_url($path = str_replace('/phpgwapi/js/', '/api/js/', $package), PHP_URL_PATH)) ||
$package[0] == '/' && is_readable(EGW_SERVER_ROOT.($path = $package)) ||
$package && $package[0] == '/' && is_readable(EGW_SERVER_ROOT.($path = $package)) ||
$package == '.' && is_readable(EGW_SERVER_ROOT.($path="/$app/js/$file.js")) ||
is_readable(EGW_SERVER_ROOT.($path="/$app/js/$package/$file.js")) ||
// fix not found by using app='api'
@ -325,7 +325,7 @@ class IncludeMgr
$app != 'phpgwapi' && is_readable(EGW_SERVER_ROOT.($path="/phpgwapi/js/$package/$file.js")))
{
// normalise /./ to /
$path = str_replace('/./', '/', $path);
$path = str_replace(['/./', '//'], '/', $path);
// Handle the special case, that the file is an url - in this case
// we will do no further processing but just include the file
@ -481,4 +481,4 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE_
}
}
echo "</body>\n</html>\n";
}
}