fix: preserve raw option values with secure text - #482
Open
oiahoon wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an encoding bug when enableSecureText is enabled by preserving raw option values for selection/API/form submission while escaping values only at HTML attribute interpolation time (preventing attribute-breakout injection).
Changes:
- Store option
valuein its original (raw) form during option preparation and when creating/updating “new” options. - Escape
data-valueonly when generating option HTML, keeping attribute-injection protection while avoiding double-encoding in state/dataset updates. - Add Cypress regression coverage for existing unsafe-character values and dynamically added (new) values; update dist/docs bundles accordingly.
Reviewed changes
Copilot reviewed 3 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/virtual-select.js | Keeps raw values in option data, escapes only when interpolating data-value into HTML. |
| dist/virtual-select.js | Built bundle update reflecting the raw-value + attribute-escape behavior. |
| dist/virtual-select.min.js | Minified bundle update reflecting the same behavior. |
| docs/assets/virtual-select.js | Docs bundle update reflecting the raw-value + attribute-escape behavior. |
| docs/assets/virtual-select.min.js | Minified docs bundle update reflecting the same behavior. |
| cypress/e2e/secure-option-values.cy.ts | Cypress regression tests for raw hidden-input values and XSS-safe rendering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,58 @@ | |||
| describe('Secure option values', () => { | |||
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.
Issue number: resolves #455
What is the current behavior?
When
enableSecureTextis enabled, option values are converted to HTML entities while options are prepared. A laterdatasetupdate preserves that entity string, so selecting a value such as<writes["<"]to the hidden form input.What is the new behavior?
Does this introduce a breaking change?
Other information
npm run buildnpm run validatenpm pack --dry-run["<"], label renders as text, no injected image, no horizontal overflow, and no console errors