fix(email-utils): guard against invalid URL in List-Unsubscribe parsing#2084
Closed
devteamaegis wants to merge 1 commit into
Closed
fix(email-utils): guard against invalid URL in List-Unsubscribe parsing#2084devteamaegis wants to merge 1 commit into
devteamaegis wants to merge 1 commit into
Conversation
…ashing getListUnsubscribeAction threw "TypeError: Invalid URL" when the first angle-bracketed value in a List-Unsubscribe header was not a valid URL (e.g. a leftover placeholder like <here> or human-readable text). The fallback branch already guarded new URL() with try/catch, but the primary branch did not. Wrap it the same way so an unparseable value returns null instead of throwing. Adds a regression test.
Member
|
Thanks for your interest in Mail0; however, this repository is no longer accepting pull request. |
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.
What's broken
getListUnsubscribeActioninapps/server/src/lib/email-utils.tsthrowsTypeError: Invalid URLon a malformedList-Unsubscribeheader. The primary URL-parse path has no try/catch, while the fallback path already guards the samenew URL(...)call — so a malformed header crashes instead of degrading gracefully.Why it happens
The primary branch calls
new URL(...)on the extracted header value without catching the exception that an invalid URL throws; only the fallback branch was wrapped.Fix
Wrap the primary
new URL(...)parse in the same try/catch the fallback uses, so a malformedList-Unsubscribevalue is handled (falls through) instead of throwing.Test
Processing a malformed
List-Unsubscribeheader no longer throws and returns a safe result; a valid header still parses. Fails before, passes after.