Skip to content

Commit

Permalink
add - doc - Added preliminary support for QP
Browse files Browse the repository at this point in the history
---

Added preliminary support for QUOTED-PRINTABLE properties. However,
VisualCard doesn't currently support decoding such properties, so they
currently get parsed as-is.

This is in response to PR #3, thanks @henrihein!

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO authored Dec 25, 2024
2 parents cd91377 + f18a61b commit 61d34fb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
8 changes: 8 additions & 0 deletions VisualCard/CardTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ public static Card[] GetCards(StreamReader stream)
var prop = new PropertyInfo(CardLine);
prefix = prop.Prefix;
value = prop.Value;
while (prop.Continue)
{
string nextLine = stream.ReadLine();

prop.AddLine(nextLine);
//Add it to the current line for later processing
CardLine += nextLine;
}
}
catch
{
Expand Down
25 changes: 24 additions & 1 deletion VisualCard/Parsers/Arguments/PropertyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace VisualCard.Parsers.Arguments
public class PropertyInfo : IEquatable<PropertyInfo?>
{
private readonly string rawValue = "";
private string tailValue = "";
private readonly string prefix = "";
private readonly string group = "";
private readonly ArgumentInfo[] arguments = [];
Expand All @@ -41,7 +42,7 @@ public class PropertyInfo : IEquatable<PropertyInfo?>
/// Raw value
/// </summary>
public string Value =>
rawValue;
rawValue + tailValue;

/// <summary>
/// Property prefix
Expand All @@ -67,6 +68,11 @@ public class PropertyInfo : IEquatable<PropertyInfo?>
public ArgumentInfo[] Arguments =>
arguments;

/// <summary>
/// Specifies if this property spans multiple lines
/// </summary>
public bool Multiline { get; set; }

/// <summary>
/// Checks to see if both the property info instances are equal
/// </summary>
Expand Down Expand Up @@ -117,6 +123,19 @@ public override int GetHashCode()
public static bool operator !=(PropertyInfo? left, PropertyInfo? right) =>
!(left == right);

internal static string Encoding(ArgumentInfo[] args)
=> VcardCommonTools.GetValuesString(args, "", VcardConstants._encodingArgumentSpecifier);

/// <inheritdoc/>
public bool Continue
=> Multiline ? (0 < Value?.Length ? '=' == Value[Value.Length - 1] : false) : false;

/// <inheritdoc/>
public void AddLine(string line)
{
tailValue += line;
}

internal PropertyInfo(string line)
{
// Now, parse this value
Expand All @@ -142,6 +161,10 @@ internal PropertyInfo(string line)
this.rawValue = value;
this.prefix = prefix;
this.arguments = finalArgs;
if (VcardConstants._quotedPrintable == Encoding(this.arguments))
Multiline = true;
else
Multiline = false;
this.group = group.Trim();
}
}
Expand Down
3 changes: 3 additions & 0 deletions VisualCard/Parsers/VcardConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ internal static class VcardConstants
internal const string _spaceBreak = " ";
internal const string _tabBreak = "\x0009";

//Encodings
internal const string _quotedPrintable = "QUOTED-PRINTABLE";

// Available in vCard 2.1, 3.0, 4.0, and 5.0
internal const char _fieldDelimiter = ';';
internal const char _valueDelimiter = ',';
Expand Down

0 comments on commit 61d34fb

Please sign in to comment.