Skip to content

fix(normalizer): strip mailto: prefix and query params from email targets (#353) - #356

Merged
NovaCode37 merged 1 commit into
NovaCode37:mainfrom
DYNOSuprovo:fix/strip-mailto-prefix-from-email-targets
Sep 13, 2026
Merged

NovaCode37 merged 1 commit into
NovaCode37:mainfrom
DYNOSuprovo:fix/strip-mailto-prefix-from-email-targets

Conversation

@DYNOSuprovo

Copy link
Copy Markdown
Contributor

Summary

Closes #353.

When pasting an email target such as mailto:someone@example.com or mailto:a@b.com?subject=hi, the mailto: prefix survived into the scan target string and was passed down to underlying email reconnaissance modules.

This change keeps both normalizers (cli.py on the backend and frontend/src/lib/scan-target.ts on the frontend) in sync:

  • Case-insensitively strips leading mailto: prefixes (mailto:, MAILTO:).
  • Drops query parameter strings following ? (e.g., ?subject=x).
  • Preserves downstream email casing normalization (lowercased) and scan type detection (email).

Changes Made

  1. cli.py (normalize_target):

    • Strips leading case-insensitive mailto: prefix.
    • Drops anything after ? to cleanly extract the email address.
  2. frontend/src/lib/scan-target.ts (normalizeScanTarget):

    • Mirrors the same mailto: and query parameter stripping logic before scheme and domain normalization.
  3. frontend/scripts/test-scan-target.mjs:

    • Updates normalizeScanTarget test assertions to verify that mailto: is stripped rather than retained.
    • Adds test cases for mailto:a@b.com?subject=x and case-insensitive query parameter handling.
    • Verifies detectScanType correctly recognizes mailto:a@b.com?subject=x as 'email'.
  4. tests/test_cli_target_normalization.py:

    • Adds test cases in test_normalize_target verifying mailto:user@example.com, MAILTO:USER@EXAMPLE.COM, mailto:a@b.com?subject=x, and mixed-case query strings all resolve to clean lowercased email addresses.
    • Adds test_detect_type assertions for mailto: inputs.

Verification

  • node scripts/test-scan-target.mjs in frontend/: Passed (scan target normalization tests passed).
  • All frontend test suites (test:urls, test:i18n, test:i18n-lookup, test:scan-target, test:encoder): Passed.
  • TypeScript check (tsc --noEmit src/lib/scan-target.ts): Passed with 0 errors.
  • pytest tests/test_cli_target_normalization.py: 20 passed.
  • Full pytest test suite (pytest tests/ -q): All 393 tests passed.
  • Flake8 critical rules check (flake8 --count --select=E9,F63,F7,F82): 0 errors.
  • DCO: Commit signed off per Developer Certificate of Origin (git commit -s).

…gets (NovaCode37#353)

Signed-off-by: DYNOSuprovo <DYNOSuprovo@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Thanks for the first pull request here. CI needs a maintainer to approve the run before it starts, so it may sit for a bit before anything happens. pytest tests/ -q passing is the main thing I look at.

@github-actions github-actions Bot added python Pull requests that update python code javascript Pull requests that update javascript code labels Sep 11, 2026
@NovaCode37
NovaCode37 merged commit bb08ff8 into NovaCode37:main Sep 13, 2026
9 checks passed
@NovaCode37

Copy link
Copy Markdown
Owner

Merged, closes #353. Both normalizers stay in step, and you updated the existing test that asserted the prefix was kept rather than just adding new ones, which is the part people usually miss. Checked it together with #358, since both touch cli.py: they merge cleanly and the full suite passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Email targets keep their mailto: prefix

2 participants