Skip to content

Write the push notification settings into the service worker as escaped strings - #1127

Open
KrzysztofPajak wants to merge 1 commit into
developfrom
fix/push-settings-script-escaping
Open

KrzysztofPajak wants to merge 1 commit into
developfrom
fix/push-settings-script-escaping

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: bugfix

Issue

Settings > Push notifications writes its values into firebase-messaging-sw.js between plain quotes. A quote, a backslash or a line break typed in a field broke the service worker script, and push notifications with it.

Each line was also found with Contains(key), so a value that mentioned another key (an API key containing appId, say) took over that key's line on the next save.

Solution

Values are written as JSON string literals (JsonSerializer.Serialize), which escape quotes, backslashes, line breaks and </>. A line is matched by the key it starts with.

Breaking changes

None. Plain values are written exactly as before.

Testing

  1. In Settings > Push notifications, enter an API key containing a ", save.
  2. wwwroot/firebase-messaging-sw.js holds apiKey: "...\u0022...", and the script parses.

SettingControllerPushNotificationsTests covers the escaping and a value that names another key.

…ed strings

The settings went into firebase-messaging-sw.js between plain quotes, so a quote, a backslash or
a line break typed in one of them broke the script and with it the push notifications. Each line
was also found by a Contains check, so a value that mentioned another key took over that key's
line on the next save. Values are now written as JSON string literals, and a line is matched by
the key it starts with.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants