<commit_before><?php
/**
* CalDAV Server - handle PROPFIND method
*
* @package   rscds
* @subpackage   caldav
* @author    <NAME> <<EMAIL>>
* @copyright Catalyst .Net Ltd
* @license   http://gnu.org/copyleft/gpl.html GNU GPL v2
*/
dbg_error_log("PROPFIND", "method handler");

if ( ! ($request->AllowedTo('read') || $request->AllowedTo('freebusy')) ) {
  $request->DoResponse( 403, translate("You may not access that calendar") );
}

require_once("XMLElement.php");
require_once("iCalendar.php");

$href_list = array();
$attribute_list = array();
$unsupported = array();
$arbitrary = array();

foreach( $request->xml_tags AS $k => $v ) {

  $tag = $v['tag'];
  dbg_error_log( "PROPFIND", " Handling Tag '%s' => '%s' ", $k, $v );
  switch ( $tag ) {
    case 'DAV::PROPFIND':
    case 'DAV::PROP':
      dbg_error_log( "PROPFIND", ":Request: %s -> %s", $v['type'], $tag );
      break;

    case 'URN:IETF:PARAMS:XML:NS:CALDAV:CALENDAR-DESCRIPTION':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:CALENDAR-TIMEZONE':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:SUPPORTED-CALENDAR-DATA':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MAX-RESOURCE-SIZE':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MIN-DATE-TIME':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MAX-DATE-TIME':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MAX-INSTANCES':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MAX-ATTENDEES-PER-INSTANCE':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:CALENDAR-HOME-SET':
    case 'HTTP://APACHE.ORG/DAV/PROPS/:EXECUTABLE':
    case 'DAV::CHECKED-OUT':
    case 'DAV::CHECKED-IN':
    case 'DAV::SOURCE':
    case 'DAV::LOCKDISCOVERY':
      /** These are ignored */
      break;

    case 'DAV::ACL':                            /** acl             - only vaguely supported */
    case 'DAV::CREATIONDATE':                   /** creationdate    - should work fine */
    case 'DAV::GETLASTMODIFIED':                /** getlastmodified - should work fine */
    case 'DAV::DISPLAYNAME':                    /** displayname     - should work fine */
    case 'DAV::GETCONTENTLENGTH':               /** getcontentlength- should work fine */
    case 'DAV::GETCONTENTTYPE':                 /** getcontenttype  - should work fine */
    case 'DAV::GETETAG':                        /** getetag         - should work fine */
    case 'DAV::SUPPORTEDLOCK':                  /** supportedlock   - should work fine */
    case 'DAV::RESOURCETYPE':                   /** resourcetype    - should work fine */
    case 'DAV::GETCONTENTLANGUAGE':             /** resourcetype    - should return the user's chosen locale, or default locale */
    case 'DAV::SUPPORTED-PRIVILEGE-SET':        /** supported-privilege-set    - should work fine */
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:SUPPORTED-COLLATION-SET':           /** fixed server definition - should work fine */
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:SUPPORTED-CALENDAR-COMPONENT-SET':  /** fixed server definition - should work fine */
    case 'DAV::CURRENT-USER-PRIVILEGE-SET':     /** current-user-privilege-set - only vaguely supported */
    case 'DAV::ALLPROP':                        /** allprop - limited support */
      $attribute = substr($v['tag'],5);
      $attribute_list[$attribute] = 1;
      dbg_error_log( "PROPFIND", "Adding attribute '%s'", $attribute );
      break;

    case 'DAV::HREF':
      // dbg_log_array( "PROPFIND", "DAV::HREF", $v, true );
      $href_list[] = $v['value'];
      dbg_error_log( "PROPFIND", "Adding attribute '%s'", $attribute );
      break;

    /**
    * Add the ones that are specifically unsupported here.
    */
    case 'UNSUPPORTED':
      if ( preg_match('/^(.*):([^:]+)$/', $tag, $matches) ) {
        $unsupported[$matches[2]] = $matches[1];
      }
      else {
        $unsupported[$tag] = "";
      }
      dbg_error_log( "PROPFIND", "Unsupported tag >>%s<<", $tag);
      break;

    /**
    * Add the ones that are specifically unsupported here.
    */
    default:
      $arbitrary[$tag] = $tag;
      dbg_error_log( "PROPFIND", "Adding arbitrary DAV property '%s'", $attribute );
      break;
  }
}


/**
* Returns the array of privilege names converted into XMLElements
*/
function privileges($privilege_names, $container="privilege") {
  $privileges = array();
  foreach( $privilege_names AS $k => $v ) {<commit_msg>Use the right variable name.<commit_after><?php
/**
* CalDAV Server - handle PROPFIND method
*
* @package   rscds
* @subpackage   caldav
* @author    <NAME> <<EMAIL>>
* @copyright Catalyst .Net Ltd
* @license   http://gnu.org/copyleft/gpl.html GNU GPL v2
*/
dbg_error_log("PROPFIND", "method handler");

if ( ! ($request->AllowedTo('read') || $request->AllowedTo('freebusy')) ) {
  $request->DoResponse( 403, translate("You may not access that calendar") );
}

require_once("XMLElement.php");
require_once("iCalendar.php");

$href_list = array();
$attribute_list = array();
$unsupported = array();
$arbitrary = array();

foreach( $request->xml_tags AS $k => $v ) {

  $tag = $v['tag'];
  dbg_error_log( "PROPFIND", " Handling Tag '%s' => '%s' ", $k, $v );
  switch ( $tag ) {
    case 'DAV::PROPFIND':
    case 'DAV::PROP':
      dbg_error_log( "PROPFIND", ":Request: %s -> %s", $v['type'], $tag );
      break;

    case 'URN:IETF:PARAMS:XML:NS:CALDAV:CALENDAR-DESCRIPTION':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:CALENDAR-TIMEZONE':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:SUPPORTED-CALENDAR-DATA':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MAX-RESOURCE-SIZE':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MIN-DATE-TIME':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MAX-DATE-TIME':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MAX-INSTANCES':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:MAX-ATTENDEES-PER-INSTANCE':
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:CALENDAR-HOME-SET':
    case 'HTTP://APACHE.ORG/DAV/PROPS/:EXECUTABLE':
    case 'DAV::CHECKED-OUT':
    case 'DAV::CHECKED-IN':
    case 'DAV::SOURCE':
    case 'DAV::LOCKDISCOVERY':
      /** These are ignored */
      break;

    case 'DAV::ACL':                            /** acl             - only vaguely supported */
    case 'DAV::CREATIONDATE':                   /** creationdate    - should work fine */
    case 'DAV::GETLASTMODIFIED':                /** getlastmodified - should work fine */
    case 'DAV::DISPLAYNAME':                    /** displayname     - should work fine */
    case 'DAV::GETCONTENTLENGTH':               /** getcontentlength- should work fine */
    case 'DAV::GETCONTENTTYPE':                 /** getcontenttype  - should work fine */
    case 'DAV::GETETAG':                        /** getetag         - should work fine */
    case 'DAV::SUPPORTEDLOCK':                  /** supportedlock   - should work fine */
    case 'DAV::RESOURCETYPE':                   /** resourcetype    - should work fine */
    case 'DAV::GETCONTENTLANGUAGE':             /** resourcetype    - should return the user's chosen locale, or default locale */
    case 'DAV::SUPPORTED-PRIVILEGE-SET':        /** supported-privilege-set    - should work fine */
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:SUPPORTED-COLLATION-SET':           /** fixed server definition - should work fine */
    case 'URN:IETF:PARAMS:XML:NS:CALDAV:SUPPORTED-CALENDAR-COMPONENT-SET':  /** fixed server definition - should work fine */
    case 'DAV::CURRENT-USER-PRIVILEGE-SET':     /** current-user-privilege-set - only vaguely supported */
    case 'DAV::ALLPROP':                        /** allprop - limited support */
      $attribute = substr($v['tag'],5);
      $attribute_list[$attribute] = 1;
      dbg_error_log( "PROPFIND", "Adding attribute '%s'", $attribute );
      break;

    case 'DAV::HREF':
      // dbg_log_array( "PROPFIND", "DAV::HREF", $v, true );
      $href_list[] = $v['value'];
      dbg_error_log( "PROPFIND", "Adding attribute '%s'", $attribute );
      break;

    /**
    * Add the ones that are specifically unsupported here.
    */
    case 'UNSUPPORTED':
      if ( preg_match('/^(.*):([^:]+)$/', $tag, $matches) ) {
        $unsupported[$matches[2]] = $matches[1];
      }
      else {
        $unsupported[$tag] = "";
      }
      dbg_error_log( "PROPFIND", "Unsupported tag >>%s<<", $tag);
      break;

    /**
    * Add the ones that are specifically unsupported here.
    */
    default:
      $arbitrary[$tag] = $tag;
      dbg_error_log( "PROPFIND", "Adding arbitrary DAV property '%s'", $tag );
      break;
  }
}


/**
* Returns the array of privilege names converted into XMLElements
*/
function privileges($privilege_names, $container="privilege") {
  $privileges = array();
  foreach( $privilege_names AS $k => $v ) {
{'fraction_non_alphanumeric': 0.16804471876091767, 'fraction_numerical': 0.00186328170490276, 'mean_word_length': 2.8033658104517274, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '478816', 'n_tokens_mistral': 2961, 'n_tokens_neox': 2894, 'n_words': 598}