Detect and ignore path loops#558
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds crawler-trap detection during URL normalization by rejecting URLs with excessive repetition in path segments and/or query parameters, helping prevent infinite/degenerate crawls in the preprocessor.
Changes:
- Introduces
hasPathLoop()to detect repeated path segments and repeated query parameter pairs. - Integrates loop detection into
NormalizeURLfor both CGO and non-CGO URL parsing backends. - Expands preprocessor test coverage with new path-loop specific tests and additional
NormalizeURLcases.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/pkg/preprocessor/url_test.go | Adds NormalizeURL test cases that should now fail when path repetition indicates a loop/trap. |
| internal/pkg/preprocessor/url_cgofree.go | Captures pathname/search from ada parser and rejects URLs flagged by hasPathLoop(). |
| internal/pkg/preprocessor/url_cgo.go | Same as above for the CGO-backed ada parser. |
| internal/pkg/preprocessor/pathloop_test.go | New unit tests validating path/query repetition detection behavior. |
| internal/pkg/preprocessor/pathloop.go | New loop/trap detection helper used by NormalizeURL. |
| internal/pkg/preprocessor/error.go | Adds a new exported error for loop/trap detection failures. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #558 +/- ##
==========================================
+ Coverage 56.66% 56.81% +0.14%
==========================================
Files 131 132 +1
Lines 6621 6667 +46
==========================================
+ Hits 3752 3788 +36
- Misses 2495 2502 +7
- Partials 374 377 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This reverts commit 2f72ca0. Idea still makes sense, but implementation needs work.
willmhowes
requested changes
Feb 9, 2026
willmhowes
approved these changes
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detect and stop loops in path and query.