node-vcard
node-vcard copied to clipboard
Escaped colons are improperly parsed
Google gives back a URL like so:
'URL:https\\://plus.google.com/u/0/38497128973128932',
The colon has been escaped with a double backslash. Once it has been parsed, the output is simply:
https\
This means that the colon was not escaped at all.
If you are willing to accept, a pull request can be made to fix this.
I've noticed a similar issue with vcard photos.
How to Reproduce
INPUT: PHOTO:https://example.com/photo.jpg
OUTPUT: https
Possible Workarounds
You can work around this two different ways:
A) Remove the colon and text before it:
INPUT: PHOTO://example.com/photo.jpg
OUTPUT: //example.com/photo.jpg
B) Add MEDIATYPE information:
INPUT: PHOTO;MEDIATYPE=image/jpeg:https://example.com/photo.jpg
OUTPUT: PHOTO: { type: [ 'MEDIAimage/jpeg' ], value: '//example.com/photo.jpg' }
Possible Fix:
In the this.parsevCard() function of blob/master/vcard.js, change this:
var fields = data[f].split(":");
to this:
var fields = data[f].split(/(?<=^[^:]+):/y);
Basically, they were splitting the string on every single colon and returning the second array item. So stuff like URLs got split multiple times. That regex split makes sure it splits only the first colon.