pg_log.py: fix email header stripping, empty bodies and cc leaking - #126
Merged
Merged
Conversation
…ump version to 3.0.18 send_customized_email() stripped its header lines with a global replace(), so a To:/Subject: line quoted in the message body was deleted too, and it passed an empty body straight to send_python_email(), which substitutes and clears the buffered PGLOG['EMLMSG'] - mailing an unrelated message to that recipient. send_python_email() also treated an explicitly empty cc as 'no cc given' and carbon copied the sender into the process global CCDADDR, which then rode along on every later email of the same process. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The legacy module-level API retains the original email-handling issues.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Updates email handling to preserve body content, reject empty messages, prevent Cc leakage, and bump the package version to 3.0.18.
Changes:
- Fixes header stripping and empty-body handling.
- Distinguishes omitted from explicitly empty Cc values.
- Updates version metadata and documentation.
| File | Description |
|---|---|
src/rda_python_common/pg_log.py |
Updates email parsing and Cc behavior. |
src/rda_python_common/__init__.py |
Bumps package version. |
README.md |
Updates documented version. |
pyproject.toml |
Updates distribution version. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| for ekey in entries: | ||
| entry = entries[ekey][0] | ||
| ms = re.search(r'(^|\n)({}: *(.*)\n)'.format(entry), emlmsg, re.I) | ||
| ms = re.search(r'(^|\n)({}: *(.*)\n)'.format(entry), msg, re.I) |
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
send_customized_email()stripped its header lines with a globalreplace(), so aTo:/Subject:line quoted anywhere in the message BODY was deleted too. It now splices out only the matched header span.send_customized_email()passed an empty body straight tosend_python_email(), which substitutes and CLEARS the bufferedPGLOG['EMLMSG']- mailing an unrelated message to that recipient. Now returns FAILURE with an error.send_python_email()treated an explicitly emptyccas "no cc given" and carbon copied the sender into the process-globalPGLOG['CCDADDR'], which then rode along on every later email of the same process. Onlycc=Nonemeans "use CCDADDR" now.__init__.py, README).Test plan
To:/Subject:lines preserved,CCDADDRuntouchedPGLOG['EMLMSG']preservedFrom:header -> FAILURE, 0 mails sent