Skip to content

Commit

Permalink
fix - Fixed incomplete entries after blank lines within ...
Browse files Browse the repository at this point in the history
...vCard

---

We've fixed incomplete entries that get appended in the initial parser.

---

Type: fix
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Apr 4, 2024
1 parent c2beb9f commit 9f2de8e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions VisualCard/CardTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,14 @@ public static Card[] GetCards(StreamReader stream)
string CardLine;
StringBuilder CardContent = new();
Version CardVersion = new();
bool CardSawNull = false;
CardLine = stream.ReadLine();
while (!stream.EndOfStream)
{
bool append = false;

// Skip empty lines
CardLine = stream.ReadLine();
if (string.IsNullOrEmpty(CardLine))
{
CardLine = stream.ReadLine();
CardSawNull = true;
if (!stream.EndOfStream)
continue;
}
Expand All @@ -105,14 +102,11 @@ public static Card[] GetCards(StreamReader stream)
BeginSpotted = true;
VersionSpotted = false;
EndSpotted = false;
CardSawNull = false;
continue;
}

// Now that the beginning of the card tag is spotted, parse the version as we need to know how to select the appropriate parser.
// All VCards are required to have their own version directly after the BEGIN:VCARD tag
if (!CardSawNull)
CardLine = stream.ReadLine();
CardSawNull = false;
if (CardLine != $"{VcardConstants._versionSpecifier}:2.1" &&
CardLine != $"{VcardConstants._versionSpecifier}:3.0" &&
CardLine != $"{VcardConstants._versionSpecifier}:4.0" &&
Expand All @@ -123,6 +117,7 @@ public static Card[] GetCards(StreamReader stream)
{
VersionSpotted = true;
CardVersion = new(CardLine.Substring(8));
continue;
}

// If the ending tag is spotted, reset everything.
Expand All @@ -139,7 +134,6 @@ public static Card[] GetCards(StreamReader stream)
// Clear the content in case we want to make a second contact
CardContent.Clear();
BeginSpotted = false;
CardLine = stream.ReadLine();
}
else if (append)
CardContent.AppendLine();
Expand Down

0 comments on commit 9f2de8e

Please sign in to comment.