Conversation
_update_page() set $self->{last_uri} for every successful response,
and last_uri is the sole source of the Referer header in
_modify_request(). Because a HEAD request does not push the page
stack, a following back() had nothing to pop, so the HEAD URL
persisted as last_uri and leaked as the Referer of the next get().
Gate the last_uri update on the request being GET or POST, the same
condition request() uses to decide whether to push the page stack.
Non-navigational requests (HEAD/PUT/DELETE) no longer affect the
Referer sent on subsequent requests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #426 +/- ##
==========================================
+ Coverage 89.80% 89.81% +0.01%
==========================================
Files 3 3
Lines 853 854 +1
Branches 225 226 +1
==========================================
+ Hits 766 767 +1
Misses 37 37
Partials 50 50 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
@petdance I saw you had linked a branch for a similar fix, but it didn't appear to have any new commits in it. Does this fix seem reasonable? |
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.
Closes #150
Problem
A
$mech->head($url)request leaked its URL as theRefererheader on subsequentget()requests, even after callingback()._update_page()set$self->{last_uri}for every successful response, andlast_uriis the sole source of theRefererheader in_modify_request(). Because a HEAD request does not push the page stack, a followingback()had nothing to pop, so the HEAD URL persisted aslast_uriand leaked as theRefererof the next request.Changes
lib/WWW/Mechanize.pm: gate thelast_uriupdate in_update_page()on the request beingGETorPOST— the same conditionrequest()uses to decide whether to push the page stack. Non-navigational requests (HEAD/PUT/DELETE) no longer affect theReferersent on subsequent requests.t/local/referer.t: add coverage that a HEAD does not clobber theRefererof the next request, including theback()case called out in the issue. Converted the fixedtests => Nplan todone_testing.t/local/referer-server: raise the connection ceiling to cover the new requests, with an explanatory comment.Changes: note the fix.Testing
t/local/suite passes (322 tests)..pm/.tfiles passperltidy --assert-tidy.🤖 Generated with Claude Code