Registry Mirror
Skip to content

Conversation

@grandnode-dev

Copy link
Copy Markdown
Member

Type: bugfix

Issue

On the order completed page the Google Analytics widget builds the purchase event from the order: billing city, state and country, item SKU, product and category names. Each goes inside a quoted string of an inline script, and only the apostrophe was escaped. A value with a backslash, a double quote, a line break or markup did not stay a plain string inside the script.

Solution

FixIllegalJavaScriptChars encodes the value with JavaScriptEncoder.Default, the encoder the plugin's configuration view already uses for its default scripts. The value reaches Google Analytics unchanged; non-ASCII characters are written as \uXXXX escapes, which the browser reads back as the same text.

Breaking changes

None.

Testing

  • GoogleAnalyticsScriptValueTests (new; Grand.Modules.Tests now references the plugin): values with an apostrophe, a backslash, markup, a line break and non-ASCII letters leave no raw quote, tag or line break, and read back as the original string; plain text is unchanged.
  • Grand.Modules.Tests: 480 passed.

Notes

#1150 changes the same file (the end of GetEcommerceScript) and #1146, #1149, #1151 add a plugin reference next to the same lines of Grand.Modules.Tests.csproj: whichever merges second needs a trivial conflict fix.

The purchase script puts the billing city, state, country, SKU, product and category names inside quoted strings of an inline script. Only the apostrophe was escaped, so a value with a backslash, a quote or markup did not stay a plain string. The values are now encoded with JavaScriptEncoder, as the plugin's configuration view already does for the default scripts.
Copilot AI balanced review requested due to automatic review settings November 28, 2026 15:04

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.

…cs-script-values

# Conflicts:
#	src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.cs
#	src/Tests/Grand.Modules.Tests/Grand.Modules.Tests.csproj
@grandnode-dev
grandnode-dev merged commit 11d691d into develop Nov 29, 2026
8 of 9 checks passed
@grandnode-dev
grandnode-dev deleted the fix/google-analytics-script-values branch November 29, 2026 10:28
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