From 72beeff9fb7a2ccfa951c7ddd0f5baadb0ff4f35 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Tue, 22 Nov 2022 08:58:20 -0800 Subject: [PATCH 1/2] Remove TrimStart in PAX extended attributes --- .../System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)'='); From 824e8f4f8f6913355b92ca310cf2eb32e1caec62 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Tue, 22 Nov 2022 08:58:45 -0800 Subject: [PATCH 2/2] Adjust existing tests with two extra inline datas. --- .../TarReader.File.GlobalExtendedAttributes.Tests.cs | 8 +++++--- .../tests/TarReader/TarReader.File.Tests.cs | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) 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); } }