Skip to content

Fix double slash when rejoining USTAR prefix and name - #131793

Draft
alinpahontu2912 with Copilot wants to merge 2 commits into
mainfrom
copilot/reduce-per-entry-allocation-in-ustar-attribute-rea
Draft

Fix double slash when rejoining USTAR prefix and name#131793
alinpahontu2912 with Copilot wants to merge 2 commits into
mainfrom
copilot/reduce-per-entry-allocation-in-ustar-attribute-rea

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

ReadUstarAttributes unconditionally joined a non-empty ustar prefix and name with /, assuming the prefix never already ends with a separator. Archives with a trailing-slash prefix produced a synthesized // in the resulting logical path.

Changes

  • TarHeader.Read.cs: check whether _prefix already ends with / before inserting the separator when rejoining prefix and name.
_name = _prefix.EndsWith('/') ? $"{_prefix}{_name}" : $"{_prefix}/{_name}";

Co-authored-by: alinpahontu2912 <56953855+alinpahontu2912@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes USTAR header name reconstruction so archives that (incorrectly) include a trailing / in the prefix field don’t produce a synthesized // when combining prefix + name.

Changes:

  • Update ReadUstarAttributes to conditionally insert the / separator only when _prefix doesn’t already end with /.

Comment on lines +568 to +572
// Prefix should not have a trailing separator, but to avoid producing a
// synthesized double slash for archives that do include one, only add
// the separator when it is not already present.
// It should always be a forward slash for compatibility.
_name = _prefix.EndsWith('/') ? $"{_prefix}{_name}" : $"{_prefix}/{_name}";
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-formats-tar
See info in area-owners.md if you want to be subscribed.

Co-authored-by: alinpahontu2912 <56953855+alinpahontu2912@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 4, 2026 11:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants