Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Handle more special characters in parseSearchFragment (#4521)

Karl-Aksel Puulmann3eee780557b2
diff --git a/assets/js/dashboard/util/url-search-params.test.ts b/assets/js/dashboard/util/url-search-params.test.ts
index ddf61eba38..fb47ab15a9 100644
--- a/assets/js/dashboard/util/url-search-params.test.ts
+++ b/assets/js/dashboard/util/url-search-params.test.ts
@@ -118,7 +118,9 @@ describe(`${parseSearchFragment.name}`, () => {
// Non-JSON strings that should return as string
['undefined', 'undefined'],
['not_json', 'not_json'],
- ['plainstring', 'plainstring']
+ ['plainstring', 'plainstring'],
+ ['a|b', 'a|b'],
+ ['foo bar#', 'foo bar#']
])(
'when searchStringFragment is %p, returns %p',
(searchStringFragment, expected) => {
diff --git a/assets/js/dashboard/util/url.ts b/assets/js/dashboard/util/url.ts
index 1fd45210e5..7d7168b0ae 100644
--- a/assets/js/dashboard/util/url.ts
+++ b/assets/js/dashboard/util/url.ts
@@ -131,6 +131,9 @@ export function parseSearchFragment(
/* @ts-expect-error API supposedly not present in compilation target */
.replaceAll('=', encodeURIComponent('='))
.replaceAll('#', encodeURIComponent('#'))
+ .replaceAll('|', encodeURIComponent('|'))
+ .replaceAll(' ', encodeURIComponent(' '))
+
try {
return JsonURL.parse(fragmentWithReEncodedSymbols)
} catch (error) {