Skip to content

tool: trim trailing URL separators in linear time - #23405

Closed
cla7aye15I4nd wants to merge 4 commits into
curl:masterfrom
cla7aye15I4nd:zheng/curl-remote-name-linear
Closed

cla7aye15I4nd wants to merge 4 commits into
curl:masterfrom
cla7aye15I4nd:zheng/curl-remote-name-linear

Conversation

@cla7aye15I4nd

@cla7aye15I4nd cla7aye15I4nd commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

With curl -O, a URL ending in a long run of / or \ makes filename selection rescan the remaining path after removing each separator. Trim the entire suffix in one pass, then search once for the final path component. Root paths still use the default filename, and mixed slash/backslash handling is retained.

Existing test 1639 now supplies a URL with 60,000 trailing slashes through a test config file, keeping command lines short, and checks the downloaded file name and contents. Test 1644 continues to cover a path component followed by trailing slashes. Both tests pass in a debug CMake build. This is a command-line CPU-efficiency fix; the test covers the long-input behavior but does not assert a runtime threshold.

Comment thread tests/data/test3431 Resolved
@cla7aye15I4nd
cla7aye15I4nd marked this pull request as ready for review October 15, 2026 07:41
@cla7aye15I4nd cla7aye15I4nd changed the title [DONE] tool: trim trailing URL separators in linear time tool: trim trailing URL separators in linear time Oct 15, 2026
Comment thread tests/data/test1639 Resolved
@cla7aye15I4nd
cla7aye15I4nd requested a review from bagder October 15, 2026 17:18
@bagder
bagder requested a balanced review from Copilot October 15, 2026 22:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change preserves filename-selection behavior, includes regression coverage, and has no unresolved findings.

0 open findings

What changed in this PR

Makes command-line curl -O filename selection linear-time for URLs with long trailing separator runs while preserving existing behavior.

Changes:

  • Trims trailing slashes and backslashes before locating the filename.
  • Expands test 1639 to use 60,000 trailing slashes through a config file.
File Description
tests/​data/​test1639 Exercises a long trailing-slash URL without a long command line.
src/​tool_operhlp.c Replaces repeated path searches with one suffix-trimming pass.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bagder bagder closed this in ded4c00 Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants