aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Oster <parasytic@users.sourceforge.net>2009-05-29 16:04:23 +0000
committerJason Oster <parasytic@users.sourceforge.net>2009-05-29 16:04:23 +0000
commitaa19cb6558989cd6edb962d27b9d222dce4db9e7 (patch)
treeeffac461f484fc6e20795aa90a4b0073f8573c3a
parentdb1ba3df77c858b3da994cfdad9f0eed0ca4a639 (diff)
downloadphpicalendar-aa19cb6558989cd6edb962d27b9d222dce4db9e7.zip
phpicalendar-aa19cb6558989cd6edb962d27b9d222dce4db9e7.tar.gz
phpicalendar-aa19cb6558989cd6edb962d27b9d222dce4db9e7.tar.bz2
Attempt to parse attendees/organizers without a Common Name attribute and invalid email address
-rw-r--r--functions/ical_parser.php36
-rw-r--r--includes/event.php12
2 files changed, 33 insertions, 15 deletions
diff --git a/functions/ical_parser.php b/functions/ical_parser.php
index d3031d7..b6b2a70 100644
--- a/functions/ical_parser.php
+++ b/functions/ical_parser.php
@@ -420,16 +420,20 @@ foreach ($cal_filelist as $cal_key=>$filename) {
}
break;
case 'ATTENDEE':
- $name = preg_match("/CN=([^;]*)/i", $field, $matches1);
- $email = str_replace("mailto:", "", $data);
- $rsvp = preg_match("/RSVP=([^;]*)/i", $field, $matches2);
- $partstat = preg_match("/PARTSTAT=([^;]*)/i", $field, $matches3);
- $role = preg_match("/ROLE=([^;]*)/i", $field, $matches4);
+ $email = preg_match("/mailto:(.*)/i", $data, $matches1);
+ $name = preg_match("/CN=([^;]*)/i", $field, $matches2);
+ $rsvp = preg_match("/RSVP=([^;]*)/i", $field, $matches3);
+ $partstat = preg_match("/PARTSTAT=([^;]*)/i", $field, $matches4);
+ $role = preg_match("/ROLE=([^;]*)/i", $field, $matches5);
- $name = ($name ? $matches1[1] : $email);
- $rsvp = ($rsvp ? $matches2[1] : '');
- $partstat = ($partstat ? $matches3[1] : '');
- $role = ($role ? $matches4[1] : '');
+ $email = ($email ? $matches1[1] : '');
+ $name = ($name ? $matches2[1] : $email);
+ $rsvp = ($rsvp ? $matches3[1] : '');
+ $partstat = ($partstat ? $matches4[1] : '');
+ $role = ($role ? $matches5[1] : '');
+
+ // Emergency fallback
+ if (empty($name) && empty($email)) $name = $data;
$attendee[] = array ('name' => stripslashes($name),
'email' => stripslashes($email),
@@ -439,10 +443,16 @@ foreach ($cal_filelist as $cal_key=>$filename) {
);
break;
case 'ORGANIZER':
- $data = str_replace ("mailto:", "", $data);
- $field = preg_match("/CN=([^;]*)/i", $field, $matches);
- $field = ($field ? $matches[1] : $data);
- $organizer[] = array ('name' => stripslashes($field), 'email' => stripslashes($data));
+ $email = preg_match("/mailto:(.*)/i", $data, $matches1);
+ $name = preg_match("/CN=([^;]*)/i", $field, $matches2);
+
+ $email = ($email ? $matches1[1] : '');
+ $name = ($name ? $matches2[1] : $email);
+
+ // Emergency fallback
+ if (empty($name) && empty($email)) $name = $data;
+
+ $organizer[] = array ('name' => stripslashes($name), 'email' => stripslashes($email));
break;
case 'LOCATION':
$data = str_replace("\\n", "<br />", $data);
diff --git a/includes/event.php b/includes/event.php
index 4112700..8b98c26 100644
--- a/includes/event.php
+++ b/includes/event.php
@@ -39,7 +39,11 @@ if (isset($organizer) && is_array($organizer)) {
$i=0;
$organizers = array();
foreach ($organizer as $val) {
- $organizers[] .= "<a href=\"mailto:{$organizer[$i]["email"]}\">{$organizer[$i]["name"]}</a>";
+ if (!empty($organizer[$i]["email"])) {
+ $organizers[] .= "<a href=\"mailto:{$organizer[$i]["email"]}\">{$organizer[$i]["name"]}</a>";
+ } else {
+ $organizers[] .= $organizer[$i]["name"];
+ }
$i++;
}
$organizer = implode(', ',$organizers);
@@ -48,7 +52,11 @@ if (isset($attendee) && is_array($attendee)) {
$i=0;
$attendees = array();
foreach ($attendee as $val) {
- $attendees[] .= "<a href=\"mailto:{$attendee[$i]["email"]}\">{$attendee[$i]["name"]}</a>";
+ if (!empty($attendee[$i]["email"])) {
+ $attendees[] .= "<a href=\"mailto:{$attendee[$i]["email"]}\">{$attendee[$i]["name"]}</a>";
+ } else {
+ $attendees[] .= $attendee[$i]["name"];
+ }
$i++;
}
$attendee = implode(', ',$attendees);

© 2014-2020 Faster IT GmbH | imprint | privacy policy