Conversation
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.
…cs-script-values # Conflicts: # src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.cs # src/Tests/Grand.Modules.Tests/Grand.Modules.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
FixIllegalJavaScriptCharsencodes the value withJavaScriptEncoder.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\uXXXXescapes, which the browser reads back as the same text.Breaking changes
None.
Testing
GoogleAnalyticsScriptValueTests(new;Grand.Modules.Testsnow 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 ofGrand.Modules.Tests.csproj: whichever merges second needs a trivial conflict fix.