Skip to content

fix(crawler): ignore noscript meta refresh when resolving the seed - #561

Merged
nc9 merged 3 commits into
mainfrom
claude/pub-437-noscript-meta-refresh
Oct 8, 2026
Merged

nc9 merged 3 commits into
mainfrom
claude/pub-437-noscript-meta-refresh

Conversation

@nc9

@nc9 nc9 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What changed

findClientRedirects scanned raw HTML for meta refresh tags with no notion of <noscript>. A browser with scripting on reads <noscript> content as text, so that refresh never fires, but the crawler treated it as a redirect and re-seeded the audit at the no-JS page.

findClientRedirects (packages/utils/src/client-redirects.ts) now runs stripNoscriptMarkup over the HTML first. This covers the JavaScript redirect scan as well, since a script inside <noscript> does not run either.

docs/crawl.mdx notes that client-side redirects inside <noscript> are ignored.

Acceptance criteria

  • findClientRedirects ignores a meta refresh inside <noscript>. Tests in packages/utils/tests/client-redirects-noscript.test.ts: ignores a meta refresh inside <noscript>, plus an uppercase multi-line variant.
  • A meta refresh outside <noscript> is still followed, with a test for each case. Same file: negative control: a meta refresh outside <noscript> is still followed, a meta refresh outside <noscript> wins when the page also has one inside, a meta refresh after a closed <noscript> is still followed.
  • A local fixture whose seed page carries only a <noscript> meta refresh is audited at the seed URL. packages/crawler/tests/seed-noscript-meta-refresh.test.ts runs the real crawler.start() against a local server: the seed URL and page are kept and the fallback page is never stored. Its negative control (the same refresh outside <noscript>) re-seeds at /no-js.html.

Verification

  • bun test packages/utils/tests/client-redirects-noscript.test.ts: 5 pass (3 fail with the fix reverted)
  • bun test packages/crawler/tests/seed-noscript-meta-refresh.test.ts: 2 pass (the seed test fails with the fix reverted)
  • bun test on seed-redirect-pinning, redirect-header-security, apps/cli client-redirects: 64 pass
  • bun run typecheck in packages/utils and packages/crawler: clean
  • bun run lint, bun run format:check: clean
  • cd docs && make validate: all checks passed

Agent skill

No skill change needed. No CLI flag, output or command changed.

Closes #437

findClientRedirects scanned raw HTML with no notion of <noscript>, so a
meta refresh a browser never runs re-seeded the crawl at the no-JS page.
Strip noscript markup before scanning.

Signed-off-by: Nik Cubrilovic <[email protected]>
@claude

claude Bot commented Oct 8, 2026

Copy link
Copy Markdown

Reviewed the diff. I found no correctness, security or performance problems.

  • findClientRedirects now runs the HTML through the existing stripNoscriptMarkup helper before it looks for a meta refresh or a JS redirect. That matches browser behavior with scripting on, and the helper scans the input once. It handles comments, raw-text elements, case and an unclosed <noscript>.

  • The tests cover both the unit level and the real crawler.start() path. They include negative controls, which show the stripping doesn't suppress genuine redirects. The docs note is accurate.

  • (nit) packages/utils/src/client-redirects.ts: the early return in stripNoscriptMarkup means pages without <noscript> pay only one regex test, so the cost is fine. A test with an unclosed <noscript> followed by a refresh would pin down the "to the end" behavior the helper documents.

  • (nit) packages/crawler/tests/seed-noscript-meta-refresh.test.ts: the Bun.serve setup is fine. If another test already has a similar local-server helper, consider sharing it.

@claude

claude Bot commented Oct 8, 2026

Copy link
Copy Markdown

Review of #561 (ignore client-side redirects inside <noscript>)

No blocking findings. The change is small and reuses the existing stripNoscriptMarkup helper. That helper already handles comments, raw-text elements, and unclosed or uppercase tags, in linear time. I read the diff and the helper but did not run the tests.

  • (nit) packages/utils/src/client-redirects.ts: the early return in stripNoscriptMarkup makes the common case cheap. For pages that do contain <noscript>, the HTML is now scanned once more per redirect check. That is negligible next to the fetch, so I'd leave it as is.
  • (nit) Tests: both a unit test and a crawler-level test with a negative control are included, which is good. You could add one case for a <noscript> inside an HTML comment, and one for a JS redirect (window.location) inside <noscript>. The second isn't covered, though the same strip applies to it.
  • (nit) The docs addition in docs/crawl.mdx is clear.

Overall this looks good to merge.

@claude

claude Bot commented Oct 8, 2026

Copy link
Copy Markdown

Reviewed the diff and the existing stripNoscriptMarkup helper in packages/utils/src/dom.ts. I have no findings.

  • The fix reuses the tokenizer that already skips comments, quoted attributes and raw-text elements, and it runs in linear time. It returns early when the HTML has no <noscript, so pages without one pay almost nothing.
  • Inline <script> content is kept, so JavaScript redirect detection outside <noscript> is unchanged.
  • The tests cover the main cases: a refresh inside <noscript>, uppercase and multi-line markup, a refresh outside, a refresh both inside and outside, a refresh after a closed <noscript>, and an unclosed <noscript>. The crawler test has a negative control, so it fails if the fix is reverted.
  • The docs note is accurate.

I didn't run the tests myself. I'm relying on the results in the PR description.

@nc9
nc9 merged commit c16d75b into main Oct 8, 2026
15 checks passed
@nc9
nc9 deleted the claude/pub-437-noscript-meta-refresh branch October 8, 2026 02:56
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.

Crawler follows a <noscript> meta refresh when resolving the seed URL

1 participant