Conversation
…regex The first alternative had no $ anchor, so any text following a valid prefix was accepted (e.g. `smtps://smtp.gmail.com:465 and then total garbage`). Anchor it in both the kit param and the legacy extension.yaml. Fixes #3067
Contributor
There was a problem hiding this comment.
Code Review
This pull request anchors the SMTP_CONNECTION_URI validation regex in both extension.yaml and config.ts to ensure that trailing garbage after a valid URI is rejected, and updates the test suite accordingly. The review feedback correctly points out that the regex currently uses [s]* which allows invalid schemes like smtpsssss://, and suggests replacing it with s? to restrict the scheme to only smtp or smtps.
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.
The
SMTP_CONNECTION_URIvalidation regex had no$on its first alternative, so anything after a valid prefix was accepted:smtps://smtp.gmail.com:465 and then total garbagepassed, as did the malformed...:smtp.gmail.com:465form that uses:instead of@as the userinfo separator. The bug is inherited, so this fixes the kit and the legacyextension.yamltogether. Fixes #3067.Changes
kits/firestore-send-email/src/config.ts:...(\?[^ ]*)?)|^$/->...(\?[^ ]*)?)$|^$/.firestore-send-email/extension.yaml: same anchor, plus version bump to 0.2.11 and a CHANGELOG entry.kits/firestore-send-email/tests/config.test.ts: flip the test(firestore-send-email): port the legacy unit suites into the kit #3057 characterization test from "accepts trailing garbage" to "rejects trailing text", and add a URI whose password contains,,?,&,%and*to the accept list so the anchor cannot over-tighten.The legacy suite already asserted the malformed separator form is invalid (
firestore-send-email/functions/__tests__/helpers.test.ts), but against a locally anchored copy of the regex that never shipped. That copy is now byte-identical to the shipped pattern.Verified:
npm testinkits/firestore-send-email(160 passed) and a probe of the yaml-decoded pattern against the documented forms plus the garbage forms.Caveat: this rejects previously accepted values, so an existing install with a malformed URI will fail validation on its next reconfigure. That is the intended fix, and such values already failed at runtime with "Invalid URI: please reconfigure with a valid SMTP connection URI".