diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs index b3f48687841a07..6231acd3ff3814 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs @@ -721,7 +721,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)'='); diff --git a/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.GlobalExtendedAttributes.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.GlobalExtendedAttributes.Tests.cs index 9874835fdda231..755f3377703fc6 100644 --- a/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.GlobalExtendedAttributes.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.GlobalExtendedAttributes.Tests.cs @@ -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) { @@ -101,7 +103,7 @@ public void GlobalExtendedAttribute_Roundtrips(string key, string value) { PaxGlobalExtendedAttributesTarEntry entry = Assert.IsType(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()); } } } diff --git a/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.Tests.cs index 9e7de0a54aedcf..f1eaa4269a7731 100644 --- a/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.Tests.cs @@ -335,8 +335,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) { @@ -351,7 +353,7 @@ public void PaxExtendedAttribute_Roundtrips(string key, string value) { PaxTarEntry entry = Assert.IsType(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); } }