From 72a9b8d20829db481811d99b72115b50c71e2413 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Wed, 1 Nov 2023 23:23:17 -0400 Subject: [PATCH] add option to disable extension parsing and new shorter variable syntax --- app/lib/phast/System.inc.php | 74 ++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/app/lib/phast/System.inc.php b/app/lib/phast/System.inc.php index 5cd44bd..dca4d79 100644 --- a/app/lib/phast/System.inc.php +++ b/app/lib/phast/System.inc.php @@ -711,43 +711,46 @@ } $path = System::GetVirtualPath(); - // strip path extension if there is one - $pathLast = $path[count($path) - 1]; - $ix = strripos($pathLast, "."); - if ($ix !== false) + if (System::$Configuration["Runtime.DisableAutomaticExtensionParsing"] !== true) { - $pathExt = substr($pathLast, $ix + 1); - $path[count($path) - 1] = substr($pathLast, 0, $ix); - - switch ($pathExt) + // strip path extension if there is one + $pathLast = $path[count($path) - 1]; + $ix = strripos($pathLast, "."); + if ($ix !== false) { - case "json": + $pathExt = substr($pathLast, $ix + 1); + $path[count($path) - 1] = substr($pathLast, 0, $ix); + + switch ($pathExt) { - System::$WebPageFormat = WebPageFormat::JSON; - break; - } - case "xml": - { - System::$WebPageFormat = WebPageFormat::XML; - break; - } - case "html": - { - System::$WebPageFormat = WebPageFormat::HTML; - break; - } - case "js": - { - System::$WebPageFormat = WebPageFormat::JavaScript; - break; - } - default: - { - if ($path[count($path) - 1] != "") + case "json": { - $path[count($path) - 1] = $path[count($path) - 1]; - System::Redirect("~/" . implode("/", $path)); - return; + System::$WebPageFormat = WebPageFormat::JSON; + break; + } + case "xml": + { + System::$WebPageFormat = WebPageFormat::XML; + break; + } + case "html": + { + System::$WebPageFormat = WebPageFormat::HTML; + break; + } + case "js": + { + System::$WebPageFormat = WebPageFormat::JavaScript; + break; + } + default: + { + if ($path[count($path) - 1] != "") + { + $path[count($path) - 1] = $path[count($path) - 1]; + System::Redirect("~/" . implode("/", $path)); + return; + } } } } @@ -778,6 +781,11 @@ $pathVarName = substr($pathPart, 2, strlen($pathPart) - 3); $pathVars[$pathVarName] = $actualPathParts[$i]; } + else if (stripos($pathPart, "{") == 0 && stripos($pathPart, "}") == strlen($pathPart) - 1) + { + $pathVarName = substr($pathPart, 1, strlen($pathPart) - 2); + $pathVars[$pathVarName] = $actualPathParts[$i]; + } else { $app = "";