From 03723bf2af169007b3f582f5c7a8e4908903f236 Mon Sep 17 00:00:00 2001 From: jjd314 Date: Thu, 22 May 2014 16:21:06 -0400 Subject: [PATCH] Update ical.js: handle quoted param values Although the original comment said nobody uses those, Google sent me one today (TZID="(UTC-05:00) America/New_York", whatever that might mean). Changed the split to a regexp. --- ical.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ical.js b/ical.js index 54146de..7a062fc 100755 --- a/ical.js +++ b/ical.js @@ -249,20 +249,18 @@ i += 1 } - var kv = l.split(":") + var exp = /([^":;]+)((?:;(?:[^":;]+)(?:=(?:(?:"[^"]*")|(?:[^":;]+))))*):(.+)/; + var kv = l.match(exp); - if (kv.length < 2){ + if (kv === null) { // Invalid line - must have k&v continue; } + kv = kv.slice(1); - // Although the spec says that vals with colons should be quote wrapped - // in practise nobody does, so we assume further colons are part of the - // val - var value = kv.slice(1).join(":") - , kp = kv[0].split(";") - , name = kp[0] - , params = kp.slice(1) + var value = kv[kv.length - 1] + , name = kv[0] + , params = kv[1]?kv[1].split(';').slice(1):[] ctx = self.handleObject(name, value, params, ctx, stack, l) || {} }