Skip to content

fix(rules): Cloudflare email-protection links read as mailto links across link rules and the crawl queue #838 - #1009

Merged
nc9 merged 1 commit into
mainfrom
fix/838-email-protection-links
Oct 22, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/838-email-protection-links

Conversation

@nc9

@nc9 nc9 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #838

Cloudflare's email address obfuscation rewrites mailto: links to /cdn-cgi/l/email-protection#<hex>. #829 stopped links/broken-links reading them as 404 pages. This closes the remaining paths:

  • links/tel-mailto counts the link as a mailto and checks the decoded address (from the fragment, or data-cfemail on the anchor or inside it). One that does not decode is counted and never reported as invalid or mismatched.
  • links/nofollow-internal and links/https-downgrade skip it.
  • The crawler never enqueues the path from a sitemap or a carried finding (seeds are the user's own choice), and drops it from a cached page's stored links before queueing.
  • /cdn-cgi/image/... URLs are still checked as images (existing parser and crawler tests from fix(rules): Cloudflare email-protection links are not broken links #811 #829 cover it; the new crawler test asserts it too).

This re-applies one commit from draft #926 (211dcd9) on current main: that commit sits on a branch with the link-section work that is not on public main, so the three rule files were re-done by hand against main (no section labelling) and the tests, crawler hunk and docs line applied as they were.

Tests: email-protection-838.test.ts in rules (8, all fail with the three rule files reverted), the two crawler tests (3), 11 pass. tsgo --noEmit clean in packages/rules and packages/crawler. tangly check --strict passes.

Docs: tel-mailto, nofollow-internal, https-downgrade pages updated, CHANGELOG bullet added. Agent skill: no change needed.

@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Review of #1009 (Cloudflare email-protection links). I read the diff and the cloudflare-email utils. I did not run the tests.

I found nothing that should block the merge. Dependencies and exports are in place: @squirrelscan/utils is already a dependency of both rules and crawler, and the helper is exported from both the index and the ./cloudflare-email subpath.

  • (low) packages/rules/src/links/https-downgrade.ts:46: only http:// hrefs reach the helper, and the helper does a cheap /cdn-cgi/ precheck before parsing, so the cost is small. One side effect is that the rule now skips an http:// email-protection link on any host, including a third-party one. That matches the parser's "any host" behaviour and the docs, so I think it's fine. You may want to say so explicitly in the test names.
  • (low) packages/rules/src/links/tel-mailto.ts:~165: a decoded address that carries ?subject= is rewritten to mailto:addr?subject=.... I assume the existing email-extraction code strips the query, but no test covers a decoded payload with a query. A small test would pin that.
  • (nit) tel-mailto.ts: href is reassigned with let to a synthetic mailto: value. That value then ends up in invalidMailto and in mismatch ids, so a user would see mailto:hi@… where the page has /cdn-cgi/.... Reporting the original href would be clearer.
  • (nit) crawler.ts: the email-protection check is repeated in two places (the enqueue guard and the cached-page link filter). That is acceptable, since the comments explain why each is needed.

Test coverage is good: the crawler tests exercise the real crawl, the sitemap, the carried-URL case and the stale-cache path. The /cdn-cgi/image/ control confirms images are still queued. The rules tests cover both the decodable and undecodable cases.

…-mailto, nofollow-internal, https-downgrade and never queued by the crawl #838

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/838-email-protection-links branch from 07e93bd to 7fa56f1 Compare October 22, 2026 02:44
@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Review of #1009 (Cloudflare email-protection links). I read the diff and the helper in packages/utils/src/cloudflare-email.ts. I did not run the tests.

I found no blocking problems. The change is scoped, the helper is pure, and the docs and CHANGELOG are updated. The new tests cover the crawler paths (fresh fetch, sitemap, carried seed, stale cache) and the three rules.

  • (low) packages/rules/src/links/tel-mailto.ts: an obfuscated link that doesn't decode is counted as a mailto and never judged. That is a reasonable tradeoff, but it hides a payload that is really malformed. Nothing in the output marks the case, so it is invisible to users. Consider a short note in the check message if that matters.
  • (low) packages/rules/src/links/tel-mailto.ts: obfuscatedAddress only returns decoded text that contains @. A data-cfemail payload that decodes to [email protected]?subject=.. goes through the existing mailto parsing, which looks right. A test with a ?subject= payload would pin that down.
  • (nit) packages/crawler/src/core/crawler.ts: the source !== "seed" exemption is deliberate and commented. A one-line test that a user-supplied seed pointing at the path is still crawled would document the behaviour.
  • (nit) isCloudflareEmailProtectionUrl runs once per link in the crawler's cached-page filter. The /cdn-cgi/ regex pre-check keeps this cheap, so no change is needed.

@nc9
nc9 merged commit 8d7f04b into main Oct 22, 2026
45 of 48 checks passed
@nc9
nc9 deleted the fix/838-email-protection-links branch October 22, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant