Skip to content

Commit

Permalink
Better parsing of whitespace characters for Content Lines in SimpleDe…
Browse files Browse the repository at this point in the history
…serializer #337
  • Loading branch information
Rian Stockbower committed Nov 20, 2017
1 parent c588b39 commit 147a4dc
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
32 changes: 32 additions & 0 deletions net-core/Ical.Net/Ical.Net.UnitTests/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,5 +410,37 @@ public void JournalStatusAllCaps()
var status = calendar.Journals.First().Status;
Assert.IsTrue(string.Equals(JournalStatus.Final, status, JournalStatus.Comparison));
}

[Test]
public void UnicodeDescription()
{
const string ics = @"BEGIN:VEVENT
DTSTAMP:20171120T124856Z
DTSTART;TZID=Europe/Helsinki:20160707T110000
DTEND;TZID=Europe/Helsinki:20160707T140000
SUMMARY:Some summary
UID:[email protected]
DESCRIPTION:Key points:\n• Some text (text,
, text\, text\, TP) some text\;\n• some tex
t Some text (Text\, Text)\;\n• Some tex
t some text\, some text\, text.\;\n\nsome te
xt some tex‘t some text.
ORGANIZER;X-CONFLUENCE-USER-KEY=ff801df01547101c6720006;CN=Some
user;CUTYPE=INDIVIDUAL:mailto:[email protected]
CREATED:20160627T123608Z
LAST-MODIFIED:20160627T123608Z
ATTENDEE;X-CONFLUENCE-USER-KEY=ff8080ef1df01547101c6720006;CN=Some
text;CUTYPE=INDIVIDUAL:mailto:[email protected]
SEQUENCE:1
X-CONFLUENCE-SUBCALENDAR-TYPE:other
TRANSP:TRANSPARENT
STATUS:CONFIRMED
END:VEVENT";
var deserializedEvent = Calendar.Load<CalendarEvent>(ics).Single();

Assert.IsTrue(deserializedEvent.Description.Contains("\t"));
Assert.IsTrue(deserializedEvent.Description.Contains("•"));
Assert.IsTrue(deserializedEvent.Description.Contains("‘"));
}
}
}
2 changes: 1 addition & 1 deletion net-core/Ical.Net/Ical.Net.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Ical.Net</id>
<version>4.0.1</version>
<version>4.0.3</version>
<title>Ical.Net</title>
<authors>Rian Stockbower, Douglas Day</authors>
<owners>Rian Stockbower</owners>
Expand Down
3 changes: 3 additions & 0 deletions net-core/Ical.Net/Ical.Net/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public static IList<T> Load<T>(Stream s, Encoding e)
public static IList<T> Load<T>(TextReader tr)
=> SimpleDeserializer.Default.Deserialize(tr).OfType<T>().ToList();

public static IList<T> Load<T>(string ical)
=> Load<T>(new StringReader(ical));

private IUniqueComponentList<IUniqueComponent> _mUniqueComponents;
private IUniqueComponentList<CalendarEvent> _mEvents;
private IUniqueComponentList<Todo> _mTodos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static string BuildContentLineRegex()
// contentline = name *(";" param ) ":" value CRLF
var name = $"(?<{_nameGroup}>{identifier})";
// value = *VALUE-CHAR
var value = $"(?<{_valueGroup}>[^\\x00-\\x19]*)";
var value = $"(?<{_valueGroup}>[^\\x00-\\x08\\x0E-\\x1F\\x7F]*)";
var contentLine = $"^{name}(;{param})*:{value}$";
return contentLine;
}
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
A listing of what each [Nuget package](https://www.nuget.org/packages/Ical.Net) version represents.

### v4
* 4.0.3 [#337](https://github.com/rianjs/ical.net/issues/337). Fixed a bug in `SimpleDeserializer` where tab characters (`\t`) were excluded from regex match.
* 4.0.1 [#335](https://github.com/rianjs/ical.net/issues/335). Technically this should be 5.0, but given 4.0.0 only has 24 downloads, I've just done a minor version bump.
* Moved everything from Ical.Net.Collections into the Ical.Net assembly.
* Updated the `PRODID` stamp to say 4.0.
Expand Down

0 comments on commit 147a4dc

Please sign in to comment.