Skip to content

Commit

Permalink
Fix double quote parsing error (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
scootermon authored Aug 19, 2024
1 parent a6d0f9a commit 8b0f559
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ical.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const text = function (t = '') {
.replace(/\\,/g, ',')
.replace(/\\;/g, ';')
.replace(/\\[nN]/g, '\n')
.replace(/\\\\/g, '\\');
.replace(/\\\\/g, '\\')
.replace(/^"(.*)"$/, '$1');
};

const parseValue = function (value) {
Expand All @@ -34,6 +35,9 @@ const parseValue = function (value) {
return number;
}

// Remove quotes if found
value = value.replace(/^"(.*)"$/, '$1');

return value;
};

Expand Down Expand Up @@ -698,7 +702,7 @@ module.exports = {
}

// Remove any double quotes in any tzid statement// except around (utc+hh:mm
if (l.indexOf('TZID=') && !l.includes('"(')) {
if (l.includes('TZID=') && !l.includes('"(')) {
l = l.replace(/"/g, '');
}

Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,22 @@ vows
}
}
},
'with test22.ics (quoted parameter values)': {
topic() {
return ical.parseFile('./test/test22.ics');
},
'grabbing VEVENT': {
topic(topic) {
return _.values(topic)[0];
},
'it has the correct response comment'(event) {
// See: <https://github.com/jens-maus/node-ical/issues/326>
assert.equal(event.attendee.params['X-RESPONSE-COMMENT'], 'Test link: https://example.com/test');
assert.equal(event.attendee.params.CUTYPE, 'INDIVIDUAL');
assert.equal(event.attendee.val, 'mailto:[email protected]');
}
}
},
'with test_with_tz_list.ics': {
topic() {
return ical.parseFile('./test/test_with_tz_list.ics');
Expand Down
6 changes: 6 additions & 0 deletions test/test22.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BEGIN:VCALENDAR
BEGIN:VEVENT
SUMMARY:Meeting
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;X-NUM-GUESTS=0;X-RESPONSE-COMMENT="Test link: https://example.com/test":mailto:[email protected]
END:VEVENT
END:VCALENDAR

0 comments on commit 8b0f559

Please sign in to comment.