From 76963e8ced2428e65a6679bc7fdd578fcb83164e Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 3 Dec 2024 14:36:42 -0800 Subject: [PATCH] Duh, we have a sanitizer Signed-off-by: Matt Friedman --- .github/workflows/tests.yml | 2 +- controller/manifest.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5a4ceba..c401ee8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -347,7 +347,7 @@ jobs: # START Other Tests Job (SQLite 3 and mssql) other-tests: - runs-on: ubuntu-20.04 # TODO: Change back to 'ubuntu-22.04' when https://github.com/microsoft/mssql-docker/issues/899 resolved. + runs-on: ubuntu-22.04 strategy: matrix: include: diff --git a/controller/manifest.php b/controller/manifest.php index dc775d6..a4e7d79 100644 --- a/controller/manifest.php +++ b/controller/manifest.php @@ -15,6 +15,7 @@ use phpbb\language\language; use phpbb\path_helper; use phpbb\user; +use phpbb\webpushnotifications\json\sanitizer as json_sanitizer; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; @@ -65,7 +66,7 @@ public function handle(): JsonResponse $manifest = [ 'name' => $this->config['sitename'], - 'short_name' => $this->config['pwa_short_name'] ?: utf8_substr(preg_replace('/[^\x20-\x7E]/', '', $this->config['sitename']), 0, 12), + 'short_name' => $this->config['pwa_short_name'] ?: utf8_substr($this->config['sitename'], 0, 12), 'display' => 'standalone', 'orientation' => 'portrait', 'dir' => $this->language->lang('DIRECTION'), @@ -89,6 +90,6 @@ public function handle(): JsonResponse ]; } - return new JsonResponse($manifest); + return new JsonResponse(json_sanitizer::sanitize($manifest)); } }