From 0d8b8a51dd0472cf82e90e1036521405d66faa53 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 30 Aug 2023 01:53:55 +0900 Subject: [PATCH] Improve parser logic for action attributes --- .../framework/parsers/ModuleActionParser.php | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/common/framework/parsers/ModuleActionParser.php b/common/framework/parsers/ModuleActionParser.php index 2fa91fb23..a0e1c153f 100644 --- a/common/framework/parsers/ModuleActionParser.php +++ b/common/framework/parsers/ModuleActionParser.php @@ -188,11 +188,25 @@ class ModuleActionParser extends BaseParser $action_info->method = implode('|', $methods); $action_info->route = $route_arg; $action_info->standalone = $standalone; - $action_info->check_csrf = self::_getAttributeString($action, 'check-csrf') === 'false' ? 'false' : 'true'; - $action_info->meta_noindex = self::_getAttributeString($action, 'meta-noindex') === 'true' ? 'true' : 'false'; - $action_info->session = self::_getAttributeString($action, 'session') === 'false' ? 'false' : 'true'; - $action_info->cache_control = self::_getAttributeString($action, 'cache-control') === 'false' ? 'false' : 'true'; $action_info->global_route = $global_route; + + // check-csrf (default true) + $check_csrf = self::_getAttributeString($action, 'check-csrf'); + $action_info->check_csrf = ($check_csrf !== '' && !toBool($check_csrf)) ? 'false' : 'true'; + + // meta-noindex (default false) + $meta_noindex = self::_getAttributeString($action, 'meta-noindex'); + $action_info->meta_noindex = ($meta_noindex !== '' && toBool($meta_noindex)) ? 'true' : 'false'; + + // session (default true) + $session = self::_getAttributeString($action, 'session'); + $action_info->session = ($session !== '' && !toBool($session)) ? 'false' : 'true'; + + // cache-control (default false) + $cache_control = self::_getAttributeString($action, 'cache-control'); + $action_info->cache_control = ($cache_control !== '' && !toBool($cache_control)) ? 'false' : 'true'; + + // Add the action to the list. $info->action->{$action_name} = $action_info; // Set the menu name and index settings.