Skip to content

urlapi: avoid dedotdotify() if possible - #22557

Closed
bagder wants to merge 2 commits into
masterfrom
bagder/urlapi-avoid-dedotdot
Closed

bagder wants to merge 2 commits into
masterfrom
bagder/urlapi-avoid-dedotdot

Conversation

@bagder

@bagder bagder commented Aug 12, 2026

Copy link
Copy Markdown
Member

The dedotdotify() function that removes ./ and ../ sequences from paths juggles memory and is slow. Now needs_dedotdot() is called first to determine if the removal process is necessary and otherwise avoids doing it. Avoids unnecessary memory operations.

Adjusted unit test 1395 accordingly because now a lot of input strings return NULL for "no change necessary".

Suggested-by: Max Dymond

The dedotdotify() function that removes ./ and ../ sequences from paths
juggles memory and is slow. Now needs_dedotdot() is called first to
determine if the removal process is necessary and otherwise avoids doing
it. Avoids unnecessary memory operations.

Adjusted unit test 1395 accordingly because now a lot of input strings
return NULL for "no change necessary".

Suggested-by: Max Dymond

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.

Pull request overview

This PR optimizes URL path dot-segment cleanup in lib/urlapi.c by adding a fast prescan to skip dedotdotify() when no rewrite is needed, and updates unit test expectations accordingly (many “no change” inputs now yield NULL output).

Changes:

  • Add needs_dedotdot() prescan and early-return from dedotdotify() to avoid unnecessary work/allocation.
  • Update unit test 1395 expected outputs to reflect the new “no change => NULL output” behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/urlapi.c Adds prescan logic to avoid running dedotdotify() when unnecessary.
tests/unit/unit1395.c Updates expected results to match new dedotdotify() output behavior (more NULLs).

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

Comment thread lib/urlapi.c
Comment thread lib/urlapi.c
@bagder
bagder marked this pull request as ready for review August 12, 2026 10:33
@bagder bagder closed this in eae88a7 Aug 12, 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.

2 participants