MDL-30393 lib/bennu minor fixes for RFC-2445 and PHP 5.x support.

This commit is contained in:
Jonathan Harker 2011-11-22 12:53:01 +13:00
parent fe41ba7489
commit 95641b4529
3 changed files with 55 additions and 2 deletions

View file

@ -237,6 +237,11 @@ class iCalendar_component {
$components = array(); // Initialise a stack of components
$this->clear_errors();
foreach ($lines as $key => $line) {
// ignore empty lines
if (trim($line) == '') {
continue;
}
// Divide the line up into label, parameters and data fields.
if (!preg_match('#^(?P<label>[-[:alnum:]]+)(?P<params>(?:;(?:(?:[-[:alnum:]]+)=(?:[^[:cntrl:]";:,]+|"[^[:cntrl:]"]+")))*):(?P<data>.*)$#', $line, $match)) {
$this->parser_error('Invalid line: '.$key.', ignoring');

View file

@ -54,9 +54,9 @@ class iCalendar_parameter {
return rfc2445_is_valid_value($value, RFC2445_TYPE_CAL_ADDRESS);
break;
// These are textual parameters, so the MUST NOT contain double quotes
// RFC-2445: can contain quotes.
case 'CN':
return (strpos($value, '"') === false);
return true;
break;
// These have enumerated legal values

View file

@ -218,6 +218,7 @@ class iCalendar_property_calscale extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -235,6 +236,7 @@ class iCalendar_property_method extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -255,6 +257,7 @@ class iCalendar_property_prodid extends iCalendar_property {
var $val_default = NULL;
function __construct() {
parent::__construct();
$this->val_default = '-//John Papaioannou/NONSGML Bennu '._BENNU_VERSION.'//EN';
$this->valid_parameters = array(
@ -270,6 +273,7 @@ class iCalendar_property_version extends iCalendar_property {
var $val_default = '2.0';
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -290,6 +294,7 @@ class iCalendar_property_attach extends iCalendar_property {
var $val_type = RFC2445_TYPE_URI;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'FMTTYPE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ENCODING' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -336,6 +341,7 @@ class iCalendar_property_categories extends iCalendar_property {
var $val_multi = true;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
@ -350,6 +356,7 @@ class iCalendar_property_class extends iCalendar_property {
var $val_default = 'PUBLIC';
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -367,6 +374,7 @@ class iCalendar_property_comment extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -381,6 +389,7 @@ class iCalendar_property_description extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -395,6 +404,7 @@ class iCalendar_property_geo extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -435,6 +445,7 @@ class iCalendar_property_location extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -449,6 +460,7 @@ class iCalendar_property_percent_complete extends iCalendar_property {
var $val_type = RFC2445_TYPE_INTEGER;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -471,6 +483,7 @@ class iCalendar_property_priority extends iCalendar_property {
var $val_type = RFC2445_TYPE_INTEGER;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -494,6 +507,7 @@ class iCalendar_property_resources extends iCalendar_property {
var $val_multi = true;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -508,6 +522,7 @@ class iCalendar_property_status extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -538,6 +553,7 @@ class iCalendar_property_summary extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -555,6 +571,7 @@ class iCalendar_property_completed extends iCalendar_property {
var $val_type = RFC2445_TYPE_DATE_TIME;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -575,6 +592,7 @@ class iCalendar_property_dtend extends iCalendar_property {
var $val_type = RFC2445_TYPE_DATE_TIME;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -617,6 +635,7 @@ class iCalendar_property_due extends iCalendar_property {
var $val_type = RFC2445_TYPE_DATE_TIME;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -659,6 +678,7 @@ class iCalendar_property_dtstart extends iCalendar_property {
var $val_type = RFC2445_TYPE_DATE_TIME;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -702,6 +722,7 @@ class iCalendar_property_duration extends iCalendar_property {
var $val_type = RFC2445_TYPE_DURATION;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -724,6 +745,7 @@ class iCalendar_property_freebusy extends iCalendar_property {
var $val_multi = true;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'FBTYPE' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
@ -758,6 +780,7 @@ class iCalendar_property_transp extends iCalendar_property {
var $val_default = 'OPAQUE';
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -783,6 +806,7 @@ class iCalendar_property_attendee extends iCalendar_property {
// TODO: standard has lots of detail here, make triple sure that we eventually conform
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'CN' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -823,6 +847,7 @@ class iCalendar_property_contact extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -837,6 +862,7 @@ class iCalendar_property_organizer extends iCalendar_property {
var $val_type = RFC2445_TYPE_CAL_ADDRESS;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'CN' => RFC2445_OPTIONAL | RFC2445_ONCE,
'DIR' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -877,6 +903,7 @@ class iCalendar_property_recurrence_id extends iCalendar_property {
var $val_type = RFC2445_TYPE_DATE_TIME;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'RANGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -909,6 +936,7 @@ class iCalendar_property_related_to extends iCalendar_property {
// TODO: the value of this property must reference another component's UID
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'RELTYPE' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
@ -922,6 +950,7 @@ class iCalendar_property_url extends iCalendar_property {
var $val_type = RFC2445_TYPE_URI;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -934,6 +963,7 @@ class iCalendar_property_uid extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -955,6 +985,7 @@ class iCalendar_property_exdate extends iCalendar_property {
var $val_multi = true;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -984,6 +1015,7 @@ class iCalendar_property_exrule extends iCalendar_property {
var $val_type = RFC2445_TYPE_RECUR;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -997,6 +1029,7 @@ class iCalendar_property_rdate extends iCalendar_property {
var $val_multi = true;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'TZID' => RFC2445_OPTIONAL | RFC2445_ONCE,
'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -1026,6 +1059,7 @@ class iCalendar_property_rrule extends iCalendar_property {
var $val_type = RFC2445_TYPE_RECUR;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1039,6 +1073,7 @@ class iCalendar_property_action extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1061,6 +1096,7 @@ class iCalendar_property_repeat extends iCalendar_property {
var $val_type = RFC2445_TYPE_INTEGER;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1072,6 +1108,7 @@ class iCalendar_property_trigger extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'RELATED' => RFC2445_OPTIONAL | RFC2445_ONCE,
@ -1100,6 +1137,7 @@ class iCalendar_property_created extends iCalendar_property {
var $val_type = RFC2445_TYPE_DATE_TIME;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1120,6 +1158,7 @@ class iCalendar_property_dtstamp extends iCalendar_property {
var $val_type = RFC2445_TYPE_DATE_TIME;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1140,6 +1179,7 @@ class iCalendar_property_last_modified extends iCalendar_property {
var $val_type = RFC2445_TYPE_DATE_TIME;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1161,6 +1201,7 @@ class iCalendar_property_sequence extends iCalendar_property {
var $val_default = 0;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1184,6 +1225,7 @@ class iCalendar_property_x extends iCalendar_property {
var $val_type = NULL;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
@ -1214,6 +1256,7 @@ class iCalendar_property_request_status extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
@ -1339,6 +1382,7 @@ class iCalendar_property_tzid extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1359,6 +1403,7 @@ class iCalendar_property_tzname extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL
@ -1380,6 +1425,7 @@ class iCalendar_property_tzoffsetfrom extends iCalendar_property {
var $val_type = RFC2445_TYPE_UTC_OFFSET;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1400,6 +1446,7 @@ class iCalendar_property_tzoffsetto extends iCalendar_property {
var $val_type = RFC2445_TYPE_UTC_OFFSET;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);
@ -1424,6 +1471,7 @@ class iCalendar_property_class extends iCalendar_property {
var $val_type = RFC2445_TYPE_TEXT;
function __construct() {
parent::__construct();
$this->valid_parameters = array(
RFC2445_XNAME => RFC2445_OPTIONAL
);