Skip to content

pg_log.py: fix email header stripping, empty bodies and cc leaking - #126

Merged
zaihuaji merged 1 commit into
mainfrom
hua-work-common
Sep 24, 2026
Merged

zaihuaji merged 1 commit into
mainfrom
hua-work-common

Conversation

@zaihuaji

Copy link
Copy Markdown
Collaborator

Summary

  • send_customized_email() stripped its header lines with a global replace(), so a To:/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 to send_python_email(), which substitutes and CLEARS the buffered PGLOG['EMLMSG'] - mailing an unrelated message to that recipient. Now returns FAILURE with an error.
  • send_python_email() treated an explicitly empty cc as "no cc given" and carbon copied the sender into the process-global PGLOG['CCDADDR'], which then rode along on every later email of the same process. Only cc=None means "use CCDADDR" now.
  • Version bumped to 3.0.18 (pyproject.toml, __init__.py, README).

Test plan

  • End-to-end with a fake SMTP server: realistic parked report -> SUCCESS, headers correct, body-level To:/Subject: lines preserved, CCDADDR untouched
  • Empty body -> FAILURE, 0 mails sent, PGLOG['EMLMSG'] preserved
  • Missing From: header -> FAILURE, 0 mails sent

…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>
Copilot AI lite review requested due to automatic review settings September 24, 2026 18:08
@zaihuaji
zaihuaji merged commit 96448dd into main Sep 24, 2026
2 checks passed

Copilot AI 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.

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 High severity

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)
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.

2 participants