Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Survive malformed source record #148

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
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
Loading