Skip to content

fix: guard against undef in deBase64 and stale $1 in deQP#52

Open
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/fix-preproc-extract-bugs
Open

fix: guard against undef in deBase64 and stale $1 in deQP#52
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/fix-preproc-extract-bugs

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

What

Fix two latent bugs in the preprocessor extraction methods.

Why

  • deBase64::doit() crashes with uninitialized warnings when extract_base64() returns undef — happens when the base64 header is present but no body separator follows (truncated email).
  • deQP::extract_qp() returns stale $1 from the outer regex when the inner body-separator match fails, silently returning wrong data instead of undef.

Both are the same class of bug: unchecked return values from regex operations on malformed input.

How

  • Added an early return unless defined $body guard in deBase64::doit() after the extract_base64() call.
  • Wrapped the inner regex in deQP::extract_qp() with a proper if check so $1 is never stale. Changed return undef to bare return for list-context safety.

Testing

  • Added 4 new tests in t/preproc.t covering the undef/stale-$1 edge cases.
  • Full test suite passes (32 preproc tests, all green).

🤖 Generated with Claude Code


Quality Report

Changes: 3 files changed, 43 insertions(+), 3 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

…extract_qp()

deBase64::doit() crashed with uninitialized warnings when extract_base64()
returned undef (e.g., base64 header present but no body separator).
Added early return guard.

deQP::extract_qp() returned stale $1 from the outer regex when the inner
body-separator regex failed, producing wrong data. Wrapped in proper if
check. Also changed bare 'return undef' to 'return' for context safety.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@toddr

toddr commented May 26, 2026

Copy link
Copy Markdown
Member

@toddr-bot ask does this new code create a bypass that wasn't previously present?

@toddr toddr marked this pull request as ready for review May 26, 2026 22:21
@toddr toddr self-assigned this May 26, 2026
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