[system] Serialize InitColorSchemeScript configuration values - #49091
Draft
Janpot wants to merge 1 commit into
Draft
[system] Serialize InitColorSchemeScript configuration values#49091Janpot wants to merge 1 commit into
Janpot wants to merge 1 commit into
Conversation
buildInitColorSchemeScript embedded its string props (storage keys, default mode/scheme names, attribute, and colorSchemeNode) straight into the inline SSR script. An app that derives any of these from tenant-controlled config could break out of the string or the <script> element, so serialize every value with JSON.stringify (escaping <, U+2028, U+2029) before embedding it. Also constrain the two props that can carry executable payloads: colorSchemeNode is parsed as a document property path or document.querySelector() string rather than evaluated as raw source, and attribute is restricted to the documented class/data forms so an event-handler name like onclick can't be generated.
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
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.
buildInitColorSchemeScriptinterpolated its string configuration (storage keys, default mode/scheme names,attribute, andcolorSchemeNode) directly into the inline SSR script. This treats every value as data instead: strings are serialized withJSON.stringifyand</line-separator-escaped before embedding,colorSchemeNodeis parsed into a document property-path ordocument.querySelector()form rather than evaluated as raw source, andattributeis constrained to the documented class /data-*forms.No change for apps using the static defaults or any documented value. The only behavioral narrowing is that an undocumented raw-expression
colorSchemeNodenow falls back todocument.documentElement.