diff --git a/public/themes/material-blue/views/_layouts/main.inc b/public/themes/material-blue/views/_layouts/main.inc index b56c5bbea..4935db70c 100644 --- a/public/themes/material-blue/views/_layouts/main.inc +++ b/public/themes/material-blue/views/_layouts/main.inc @@ -14,7 +14,7 @@ use function SP\__; echo $_e($_getvar('lang')); ?>"> <?php - printf('%s :: %s', $_getvar('app_name'), $_getvar('app_desc')); ?> + printf('%s :: %s', $_e($_getvar('app_name')), $_e($_getvar('app_desc'))); ?> account_circle + class="mdl-tooltip mdl-tooltip--top"> + class="mdl-tooltip mdl-tooltip--top"> diff --git a/public/themes/material-blue/views/account/files-list.inc b/public/themes/material-blue/views/account/files-list.inc index e69b6da75..fdd1dea09 100644 --- a/public/themes/material-blue/views/account/files-list.inc +++ b/public/themes/material-blue/views/account/files-list.inc @@ -48,7 +48,7 @@ use function SP\__; echo $_e($file->getName()); ?>"> attachment getName() ?? '', 50), ($file->getSize() ?? 0) / 1024); ?> + printf('%s (%d KB)', $_e(Html::truncate($file->getName() ?? '', 50)), (int)(($file->getSize() ?? 0) / 1024)); ?> diff --git a/public/themes/material-blue/views/configManager/info.inc b/public/themes/material-blue/views/configManager/info.inc index 1cb9988a4..9663fb627 100644 --- a/public/themes/material-blue/views/configManager/info.inc +++ b/public/themes/material-blue/views/configManager/info.inc @@ -116,7 +116,7 @@ use function SP\__; - + diff --git a/public/themes/material-blue/views/install/index.inc b/public/themes/material-blue/views/install/index.inc index c163177f3..8592cf6fd 100644 --- a/public/themes/material-blue/views/install/index.inc +++ b/public/themes/material-blue/views/install/index.inc @@ -50,7 +50,7 @@ use function SP\__;

+ printf('%s %s — %s', $_e($_getvar('app_name')), $_e($_getvar('app_version')), __('Installation')); ?>
    diff --git a/public/themes/material-blue/views/itemshow/item_preset-session_timeout.inc b/public/themes/material-blue/views/itemshow/item_preset-session_timeout.inc index 068db4250..92a28459d 100644 --- a/public/themes/material-blue/views/itemshow/item_preset-session_timeout.inc +++ b/public/themes/material-blue/views/itemshow/item_preset-session_timeout.inc @@ -51,7 +51,7 @@ $sessionTimeout = $_getvar('sessionTimeout'); class="mdl-textfield__input mdl-color-text--indigo-400" maxlength="33" value="getAddress(), $sessionTimeout->getMask()); ?>"> + printf('%s/%s', $_e($sessionTimeout->getAddress()), $_e($sessionTimeout->getMask())); ?>"> diff --git a/public/themes/material-blue/views/wiki/wikipage.inc b/public/themes/material-blue/views/wiki/wikipage.inc index e397816ad..3253a09bc 100644 --- a/public/themes/material-blue/views/wiki/wikipage.inc +++ b/public/themes/material-blue/views/wiki/wikipage.inc @@ -64,8 +64,8 @@ $pageInfo = $_getvar('pageInfo'); printf( '%s: %s', __('Page'), - $_getvar('wikiUrlBase') . '/' . $result['id'], - $result['id'] + $_e($_getvar('wikiUrlBase') . '/' . $result['id']), + $_e($result['id']) ); ?> @@ -85,8 +85,8 @@ $pageInfo = $_getvar('pageInfo'); printf( '%s: %s', __('Page'), - $_getvar('wikiUrlBase') . $pageInfo['name'], - $pageInfo['name'] + $_e($_getvar('wikiUrlBase') . $pageInfo['name']), + $_e($pageInfo['name']) ); ?>
  1. diff --git a/tests/Unit/Infrastructure/Adapter/In/Web/View/ThemeEscapesWhatItRendersTest.php b/tests/Unit/Infrastructure/Adapter/In/Web/View/ThemeEscapesWhatItRendersTest.php index 2bd7ffb3b..9962665e2 100644 --- a/tests/Unit/Infrastructure/Adapter/In/Web/View/ThemeEscapesWhatItRendersTest.php +++ b/tests/Unit/Infrastructure/Adapter/In/Web/View/ThemeEscapesWhatItRendersTest.php @@ -56,9 +56,16 @@ class ThemeEscapesWhatItRendersTest extends TestCase private const THEME = REAL_APP_ROOT . '/public/themes/material-blue/views'; /** - * Every `|<\?=\s*(.*?)(?:;\s*)?\?>/s'; + private const ECHO = '/<\?(?:php\s+)?(?:echo|print)\s+(.*?)(?:;\s*)?\?>' + . '|<\?(?:php\s+)?v?printf\s*\((.*?)\)\s*(?:;\s*)?\?>' + . '|<\?=\s*(.*?)(?:;\s*)?\?>/s'; /** * Reads that return text a user or an administrator typed. Deliberately by name: these are the @@ -183,7 +190,7 @@ private static function echoesIn(string $template): array $echoes = []; foreach ($matches as $match) { - $expression = trim($match[1][0] ?? '') !== '' ? $match[1][0] : ($match[2][0] ?? ''); + $expression = self::expressionFrom($match); $expression = implode(' ', preg_split('/\s+/', trim($expression)) ?: []); if ($expression !== '') { @@ -210,7 +217,7 @@ private static function interpolationsInScripts(string $template): array preg_match_all(self::ECHO, $script[1][0], $echoes, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); foreach ($echoes as $echo) { - $expression = trim($echo[1][0] ?? '') !== '' ? $echo[1][0] : ($echo[2][0] ?? ''); + $expression = self::expressionFrom($echo); $expression = implode(' ', preg_split('/\s+/', trim($expression)) ?: []); if ($expression !== '') { @@ -269,4 +276,20 @@ private static function picksBetweenLiterals(string $expression): bool $expression ); } + + /** + * The expression a match emitted, whichever of ECHO's three branches matched it. + * + * @param array $match + */ + private static function expressionFrom(array $match): string + { + foreach ([1, 2, 3] as $group) { + if (trim($match[$group][0] ?? '') !== '') { + return $match[$group][0]; + } + } + + return ''; + } }