node-vcard icon indicating copy to clipboard operation
node-vcard copied to clipboard

Escaped colons are improperly parsed

Open ultimate-tester opened this issue 7 years ago • 2 comments

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.

ultimate-tester avatar Dec 11 '17 13:12 ultimate-tester

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' }

callaginn avatar May 08 '20 06:05 callaginn

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.

callaginn avatar May 08 '20 16:05 callaginn