Skip to content

Commit

Permalink
Survive malformed source record
Browse files Browse the repository at this point in the history
  • Loading branch information
mtx500 committed Jan 14, 2024
1 parent 4e88944 commit 4a70f94
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
21 changes: 21 additions & 0 deletions GeneGenie.Gedcom.Tests/Data/Heredis7PC.ged
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
0 HEAD
1 SOUR HEREDIS 7 PC
2 VERS MAC X 10.0
2 CORP bsd concept ©
3 WEB www.heredis.com
1 DATE 28 MAR 2006
1 GEDC
2 VERS 5.5
2 FORM LINEAGE-LINKED
1 CHAR MACINTOSH
1 PLAC
2 FORM Town , Area code , County , Region , Country, Subdivision
1 SUBM @S0@
0 @S0@ SUBM
1 NAME Smith
0 @S1@ SOUR
1 TYPE Other
2 CALN
3 MEDI Autre type
1 QUAY 2
0 TRLR
3 changes: 3 additions & 0 deletions GeneGenie.Gedcom.Tests/GeneGenie.Gedcom.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<None Update="Data\TortureTests\TGC551.ged">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\Heredis7PC.ged">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\SubmitterReference.ged">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ namespace GeneGenie.Gedcom
/// </summary>
public class GedcomSurviveMalformedTest
{
[Fact]
private void Heredis7SourceRecord()
{
var reader = GedcomRecordReader.CreateReader("./Data/Heredis7PC.ged");
}

[Fact]
private void SubmitterReferenceWithWrongId()
{
Expand Down
3 changes: 2 additions & 1 deletion GeneGenie.Gedcom/Parser/GedcomRecordReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,8 @@ private void ReadSourceRecord()
}

// _ParseState.PreviousLevel + 3)
else if ((!string.IsNullOrEmpty(parseState.PreviousTag)) && level == sourceRecord.Level + 3)
else if ((!string.IsNullOrEmpty(parseState.PreviousTag)) && level == sourceRecord.Level + 3
&& sourceRecord.EventsRecorded.Count >0)
{
GedcomRecordedEvent recordedEvent = sourceRecord.EventsRecorded[sourceRecord.EventsRecorded.Count - 1];
switch (tag)
Expand Down

0 comments on commit 4a70f94

Please sign in to comment.