Skip to content

Commit 9115c5d

Browse files
workgroupengineeringkewisch
authored andcommitted
vCard phone-number escaping
1 parent c7811df commit 9115c5d

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

lib/ical/design.js

+13
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,19 @@ const vcardValues = extend(commonValues, {
742742
timestamp: icalValues['date-time'],
743743
"language-tag": {
744744
matches: /^[a-zA-Z0-9-]+$/ // Could go with a more strict regex here
745+
},
746+
"phone-number": {
747+
fromICAL: function(aValue) {
748+
return Array.from(aValue).filter(function(c) {
749+
return c === '\\' ? undefined : c;
750+
}).join('');
751+
},
752+
753+
toICAL: function(aValue) {
754+
return Array.from(aValue).map(function(c) {
755+
return c === ',' || c === ";" ? '\\' + c : c;
756+
}).join('');
757+
}
745758
}
746759
});
747760

test/parse_test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ suite('parserv2', function() {
3939
'vcard.vcf',
4040
'vcard_author.vcf',
4141
'vcard3.vcf',
42-
'vcard_grouped.vcf'
42+
'vcard_grouped.vcf',
43+
'escape_semicolon.vcf'
4344
];
4445

4546
list.forEach(function(path) {

test/parser/escape_semicolon.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[
2+
"vcard",
3+
[
4+
[ "version", {}, "text", "3.0" ],
5+
[ "prodid", {}, "text", "-//Sabre//Sabre VObject 4.1.6//EN" ],
6+
[ "uid", {}, "text", "ad612c16-fe12-4ec5-abf6-49998ee5ab88" ],
7+
[ "fn", {}, "text", "First Last NextCloud" ],
8+
[ "adr", { "type": "HOME" }, "text", [ "PO", "Street 2", "Street", "City", "AL", "zip", "Germany" ] ],
9+
[ "adr", { "type": "WORK" }, "text", [ "PO W", "Street 2 W", "Street W", "City Work", "AL work", "zip Work", "Germany work" ] ],
10+
[ "email", { "type": "HOME" }, "text", "[email protected]" ],
11+
[ "email", { "type": "WORK" }, "text", "[email protected]" ],
12+
[ "tel", { "type": [ "HOME", "VOICE" ] }, "phone-number", "11111111" ],
13+
[ "tel", { "type": "CELL" }, "phone-number", "205333" ],
14+
[ "tel", { "type": ["WORK", "FAX" ] }, "phone-number", "205246;;,;" ],
15+
[ "tel", { "type": ["WORK", "VOICE" ] }, "phone-number", "222222" ],
16+
[ "org", {}, "text", "Firma" ],
17+
[ "bday", {}, "date-time", "2019-02-10T00:00:33" ],
18+
[ "nickname", {}, "text", "Hugo" ],
19+
[ "x-abdate", {"group": "item1"}, "date-and-or-time", "20190220T000035" ],
20+
[ "x-ablabel", {"group": "item1"}, "unknown", "_$!<Anniversary>!$_" ],
21+
[ "x-anniversary", {}, "date-and-or-time", "20190220T000035" ],
22+
[ "categories", {}, "text", "Test-Kontakte" ],
23+
[ "rev", {}, "date-time", "2019-10-08T17:05:14Z" ]
24+
],
25+
[]
26+
]

test/parser/escape_semicolon.vcf

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
BEGIN:VCARD
2+
VERSION:3.0
3+
PRODID:-//Sabre//Sabre VObject 4.1.6//EN
4+
UID:ad612c16-fe12-4ec5-abf6-49998ee5ab88
5+
FN:First Last NextCloud
6+
ADR;TYPE=HOME:PO;Street 2;Street;City;AL;zip;Germany
7+
ADR;TYPE=WORK:PO W;Street 2 W;Street W;City Work;AL work;zip Work;Germany w
8+
ork
9+
EMAIL;TYPE=HOME:[email protected]
10+
EMAIL;TYPE=WORK:[email protected]
11+
TEL;TYPE="HOME,VOICE":11111111
12+
TEL;TYPE=CELL:205333
13+
TEL;TYPE="WORK,FAX":205246\;\;\,\;
14+
TEL;TYPE="WORK,VOICE":222222
15+
ORG:Firma
16+
BDAY:20190210T000033
17+
NICKNAME:Hugo
18+
ITEM1.X-ABDATE;VALUE=DATE-AND-OR-TIME:20190220T000035
19+
ITEM1.X-ABLABEL:_$!<Anniversary>!$_
20+
X-ANNIVERSARY;VALUE=DATE-AND-OR-TIME:20190220T000035
21+
CATEGORIES:Test-Kontakte
22+
REV:20191008T170514Z
23+
END:VCARD

0 commit comments

Comments
 (0)