REFACTOR: Extract SearchBox subcomponents & sanitize image URLs against XSS (#2320, #2323) - #2330
Open
Talha12Shiekh wants to merge 1 commit into
Open
Conversation
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.
Proposed Changes
This PR resolves issue #2323 (SearchBox subcomponents refactoring) and issue #2320 (Image URL XSS protocol sanitation) across
packages/web:Image URL XSS Protocol Sanitation (Fixes bug: image src attributes not validated for javascript: protocol URLs #2320):
sanitizeImageUrl(url)helper inpackages/web/src/utils/index.jsto strictly validate image URL protocol schemes (http:,https:, anddata:).srcattributes across all 3 affected files:SearchBox.js(props.iconURL)SelectedFilters.js(imageValue)AIAnswer/Chat.js(props.iconURL)Extract SearchBox Subcomponents (Fixes refactor: SearchBox.js is 2692 lines — extract subcomponents for maintainability #2323):
Refactored
SearchBox.jsby extracting additive, non-breaking subcomponents:AISection.js: Extracted the AI answer screen template, typing animations (TypingEffect), loading placeholders, andAIFeedbackUI.SuggestionsSection.js: Extracted rendering logic for all 8 suggestion types (popular, recent, FAQ, featured, document, index, endpoint, predictive).SearchInput.js: Unified input rendering wrapping<InputGroup>,<TextArea>, voice/mic addons, camera input, and autofill icons.SearchBox.js: Integrated the extracted subcomponents cleanly.Linked Issues
bug: image src attributes not validated for javascript: protocol URLs)refactor: SearchBox.js is 2692 lines — extract subcomponents for maintainability)Checklist
Improvements to the Library Experience
javascript:protocol XSS injection vectors on image URL inputs acrossSearchBox.js,SelectedFilters.js, andChat.js.SearchBox.jsfrom a 2,692-line file into modular, reusable subcomponents.Side Effects
Testing
AISection.js,SuggestionsSection.js,SearchInput.js,SearchBox.js,SelectedFilters.js,Chat.js, andutils/index.js.sanitizeImageUrlwith valid (http:,https:,data:, relative/logo.png) and invalid (javascript:alert(1)) URL schemes.