Skip to content

Commit

Permalink
Fix missing path (non existing) on condition attirute should not ente…
Browse files Browse the repository at this point in the history
…r infinite loop #188
  • Loading branch information
cleftheris committed May 17, 2021
1 parent cda7656 commit 6d7023b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.9.17.{build}
version: 1.9.18.{build}
image: Visual Studio 2019
configuration: Release
platform: Any CPU
Expand Down
2 changes: 1 addition & 1 deletion src/indice.Edi/EdiSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ private static Dictionary<string, string> SearchForward(EdiReader reader, Queue<
reader.Read();
cache.Enqueue(new EdiEntry(reader.Path, reader.TokenType, reader.Value as string));
}
} while (!found || reader.TokenType != EdiToken.SegmentStart);
} while (!found && reader.TokenType != EdiToken.SegmentStart);

if (found) {
searchResults[path] = value;
Expand Down
3 changes: 2 additions & 1 deletion src/indice.Edi/indice.Edi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Description>Edi.Net Class Library</Description>
<Copyright>Copyright (c) 2015 Indice</Copyright>
<AssemblyTitle>Edi.Net</AssemblyTitle>
<VersionPrefix>1.9.17</VersionPrefix>
<VersionPrefix>1.9.18</VersionPrefix>
<!--<VersionSuffix>beta1</VersionSuffix>-->
<Authors>c.leftheris</Authors>
<TargetFrameworks>net40;net45;netstandard1.0;netstandard1.3;netstandard2.0</TargetFrameworks>
Expand All @@ -29,6 +29,7 @@
- Bug fix related to nested segment group structures with the same segment name #172.
- Bug fix for Wildcard paths working only for collections #170.
- Fix for segment collection serialization. When some collection items where being serialized as elements instead #168.
- Fix missing path (non existing) on condition attirute should not enter infinite loop #188
</PackageReleaseNotes>
<PackageIcon>icon-256.png</PackageIcon>
<PackageProjectUrl>https://github.com/indice-co/EDI.Net</PackageProjectUrl>
Expand Down
15 changes: 6 additions & 9 deletions test/indice.Edi.Tests/EdiTextReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,22 +1061,19 @@ public void EdiFact_Issue174() {
Assert.Equal(3, interchange.Msg.VehicleRecord.GIR_List.Count);
}

[Fact(Skip = "This test will eat all your memory. Change the Path on the two EdiCondition attributes to UNH/1/0, and it works.")]
[Fact]
[Trait(Traits.Tag, "EDIFact"), Trait(Traits.Issue, "#188")]
public void EdiFact_Issue188() {
public void EdiFact_MissingPath_On_Condition_Doesnot_enter_InfiniteLoop_Issue188() {
var grammar = EdiGrammar.NewEdiFact();
var interchange = default(Models.Interchange_Issue188);
using (var stream = Helpers.GetResourceStream("edifact.Issue188.edi")) {
interchange = new EdiSerializer().Deserialize<Interchange_Issue188>(new StreamReader(stream), grammar);
}
// This test originally would eat all your memory.
// There is a misconfiguration made in order to trigger the bug that makes the SearchForward function to enter into an infinite loop.
// The correct configuration to change the Path on the two EdiCondition attributes to UNH/1/0, and it works.

Assert.Equal(2, interchange.IftminMessages.Count);
Assert.Equal("20210319", interchange.IftminMessages[0].DTMs[0].Value);
Assert.Equal("20210320", interchange.IftminMessages[1].DTMs[0].Value);

Assert.Equal(2, interchange.InvoiceMessages.Count);
Assert.Equal("20210322", interchange.InvoiceMessages[0].DTMs[0].Value);
Assert.Equal("20210323", interchange.InvoiceMessages[1].DTMs[0].Value);
Assert.Equal(0, interchange.IftminMessages.Count);
}
}
}
11 changes: 7 additions & 4 deletions test/indice.Edi.Tests/indice.Edi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>indice.Edi.Tests Class Library</Description>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -22,13 +22,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="coverlet.collector" Version="1.1.0" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>

0 comments on commit 6d7023b

Please sign in to comment.