Skip to content

Commit

Permalink
fix: Update escaping for quoted values
Browse files Browse the repository at this point in the history
see #463
  • Loading branch information
sebbo2002 committed Feb 10, 2023
1 parent c2f92fd commit faf5c70
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function formatDateTZ (timezone: string | null, property: string, date: I
* Escapes special characters in the given string
*/
export function escape (str: string | unknown, inQuotes: boolean): string {
return String(str).replace(inQuotes ? /[\\;,"]/g : /[\\;,]/g, function (match) {
return String(str).replace(inQuotes ? /[\\"]/g : /[\\;,]/g, function (match) {
return '\\' + match;
}).replace(/(?:\r\n|\r|\n)/g, '\\n');
}
Expand Down
2 changes: 1 addition & 1 deletion test/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('ical-generator Cases', function () {
organizer: 'Sebastian Pekarek <mail@sebbo.net>',
attendees: [
{
name: 'Matt',
name: 'Smith, Matt; ("Sales")',
email: 'matt@example.com',
delegatesTo: {
name: 'John',
Expand Down
2 changes: 1 addition & 1 deletion test/results/generate_06.ics
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;DELEGATED-FROM="matt@examp
le.com";CN="John":MAILTO:john@example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=DELEGATED;DELEGATED-TO="john@exampl
e.com";CN="Matt":MAILTO:matt@example.com
e.com";CN="Smith, Matt; (\"Sales\")":MAILTO:matt@example.com
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT10M
Expand Down

0 comments on commit faf5c70

Please sign in to comment.