1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

fix: correct escaping of ui flags for plausible (#3907)

## About the changes
Stringified JSON still needs to be escaped before being placed in an
HTML attribute.
This commit is contained in:
Tymoteusz Czech 2023-07-07 17:40:37 +02:00 committed by GitHub
parent 82d855ea1f
commit 6f15eb9f4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -20,7 +20,7 @@ export const PlausibleProvider: FC = ({ children }) => {
'meta[name="uiFlags"]' 'meta[name="uiFlags"]'
) as HTMLMetaElement ) as HTMLMetaElement
)?.content || '{}'; )?.content || '{}';
return JSON.parse(uiFlagsStr); return JSON.parse(decodeURI(uiFlagsStr));
} catch (e) { } catch (e) {
return {}; return {};
} }

View File

@ -9,7 +9,7 @@ export async function loadIndexHTML(
publicFolder: string, publicFolder: string,
): Promise<string> { ): Promise<string> {
const { cdnPrefix, baseUriPath = '' } = config.server; const { cdnPrefix, baseUriPath = '' } = config.server;
const uiFlags = JSON.stringify(config.ui.flags); const uiFlags = encodeURI(JSON.stringify(config.ui.flags || '{}'));
let indexHTML: string; let indexHTML: string;
if (cdnPrefix) { if (cdnPrefix) {