Skip to content

Commit

Permalink
Remove TrimStart in PAX extended attributes (dotnet#78707)
Browse files Browse the repository at this point in the history
* Remove TrimStart in PAX extended attributes

* Adjust existing tests with two extra inline datas.

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
  • Loading branch information
carlossanlop and carlossanlop committed Nov 23, 2022
1 parent 622f6a0 commit 087eccd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ private static bool TryGetNextExtendedAttribute(
{
return false;
}
line = line.Slice(spacePos + 1).TrimStart((byte)' ');
line = line.Slice(spacePos + 1);

// Find the equal separator.
int equalPos = line.IndexOf((byte)'=');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ public void ExtractGlobalExtendedAttributesEntry_Throws()

[Theory]
[InlineData("key", "value")]
[InlineData("key ", " value ")]
[InlineData(" key ", " value ")]
[InlineData("key ", "value ")]
[InlineData(" key", " value")]
[InlineData(" key ", " value ")]
[InlineData(" key spaced ", " value spaced ")]
[InlineData("many sla/s\\hes", "/////////////\\\\\\///////////")]
public void GlobalExtendedAttribute_Roundtrips(string key, string value)
{
Expand All @@ -101,7 +103,7 @@ public void GlobalExtendedAttribute_Roundtrips(string key, string value)
{
PaxGlobalExtendedAttributesTarEntry entry = Assert.IsType<PaxGlobalExtendedAttributesTarEntry>(reader.GetNextEntry());
Assert.Equal(1, entry.GlobalExtendedAttributes.Count);
Assert.Equal(KeyValuePair.Create(key.TrimStart(), value), entry.GlobalExtendedAttributes.First());
Assert.Equal(KeyValuePair.Create(key, value), entry.GlobalExtendedAttributes.First());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,10 @@ public void PaxSizeLargerThanMaxAllowedByStream()

[Theory]
[InlineData("key", "value")]
[InlineData("key ", " value ")]
[InlineData(" key ", " value ")]
[InlineData("key ", "value ")]
[InlineData(" key", " value")]
[InlineData(" key ", " value ")]
[InlineData(" key spaced ", " value spaced ")]
[InlineData("many sla/s\\hes", "/////////////\\\\\\///////////")]
public void PaxExtendedAttribute_Roundtrips(string key, string value)
{
Expand All @@ -343,7 +345,7 @@ public void PaxExtendedAttribute_Roundtrips(string key, string value)
{
PaxTarEntry entry = Assert.IsType<PaxTarEntry>(reader.GetNextEntry());
Assert.Equal(5, entry.ExtendedAttributes.Count);
Assert.Contains(KeyValuePair.Create(key.TrimStart(), value), entry.ExtendedAttributes);
Assert.Contains(KeyValuePair.Create(key, value), entry.ExtendedAttributes);
}
}

Expand Down

0 comments on commit 087eccd

Please sign in to comment.