Skip to content

fix(firestore-send-email): anchor the SMTP_CONNECTION_URI validation regex - #3170

Open
CorieW wants to merge 1 commit into
kitsfrom
invertase/kits-send-email-anchor-smtp-uri-regex
Open

CorieW wants to merge 1 commit into
kitsfrom
invertase/kits-send-email-anchor-smtp-uri-regex

Conversation

@CorieW

@CorieW CorieW commented Sep 10, 2026

Copy link
Copy Markdown
Member

The SMTP_CONNECTION_URI validation regex had no $ on its first alternative, so anything after a valid prefix was accepted: smtps://smtp.gmail.com:465 and then total garbage passed, as did the malformed ...:smtp.gmail.com:465 form that uses : instead of @ as the userinfo separator. The bug is inherited, so this fixes the kit and the legacy extension.yaml together. 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 test in kits/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".

…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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread firestore-send-email/extension.yaml
Comment thread kits/firestore-send-email/src/config.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(firestore-send-email): anchor the SMTP_CONNECTION_URI validation regex (kit and legacy)

2 participants