Add defensive null checks and improve security in postMessage calls#376
Closed
bryancasler wants to merge 3 commits into
Closed
Add defensive null checks and improve security in postMessage calls#376bryancasler wants to merge 3 commits into
bryancasler wants to merge 3 commits into
Conversation
BUG-1: onLoad.bind() never invoked pre-existing handler (app.ts) BUG-2/3: Null crash in DonationAmount.clearOther()/load() when "other" field missing BUG-4: splice() during forEach skips consecutive elements (ShowHideRadioCheckboxes) BUG-5: _dispatch flag not protected by try/finally in DonationAmount/DonationFrequency BUG-6: Exit intent fires open() twice, duplicating analytics event BUG-7: JSON.parse without try/catch in RememberMe.updateFieldData() BUG-8: postMessage with wildcard "*" origin in RememberMe and iFrame BUG-9: sessionStorage access not wrapped in try/catch in DonationFrequency MOD-1: Replace Function() constructor with safe arithmetic evaluator in UpsellLightbox MOD-3: Add retry limit (50) to EN framework detection loop in App.run() https://claude.ai/code/session_012mdWCSZqsc9D7iBiV4dur9
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.
Summary
This PR adds comprehensive null/undefined checks throughout the codebase to prevent runtime errors, improves security by replacing wildcard postMessage origins with specific domain origins, and refactors unsafe code evaluation to use a safe arithmetic parser.
Key Changes
Null Safety Improvements
otherField,otherWrapper) to prevent errors when elements don't existsessionStorageaccess in try-catch blocks to handle cases where storage is unavailable or disabledforEachwithsplicewith a saferfilter+pushpatternSecurity Enhancements
"*"postMessage origins withthis.parentOriginderived fromdocument.referrerto enforce same-origin policygetRemoteOrigin()method to extract origin fromremoteUrlinstead of using wildcard, with fallback to"*"if parsing failsFunction()constructor evaluation with a safeevaluateSuggestion()method that:/^[\d\s.+\-*/()]+$/)Error Handling
setAmount()logic in try-finally to ensure_dispatchflag is always resetsetRecurrency()andsetFrequency()in try-finally blocks for consistent state management_runRetries) with a 50-retry limit to prevent infinite loops when Engaging Networks framework is unavailableImplementation Details
Function()constructor for better securityhttps://claude.ai/code/session_012mdWCSZqsc9D7iBiV4dur9