Changeset 16588

Show
Ignore:
Timestamp:
06/13/08 08:18:45 (1 year ago)
Author:
rambo
Message:

prevent the feed registrations from hijacking the url-space in straight-mode, fixed can_handle_dispatcher

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/org.routamc.photostream/handler/feed.php

    r15371 r16588  
    6363    function _can_handle_dispatcher($handler_id, $args) 
    6464    { 
    65         if (!array_key_exists($args[0], $this->_supported_types)) 
    66         { 
     65        $args_copy = $args; 
     66        $type = array_pop($args_copy); 
     67        $type = str_replace('.xml', '', $type);  
     68        if (!array_key_exists($type, $this->_supported_types)) 
     69        { 
     70            debug_push_class(__CLASS__, __FUNCTION__); 
     71            debug_add("feed type {$type} is not supported", MIDCOM_LOG_WARN); 
     72            debug_print_r('$args: ', $args); 
     73            debug_print_r('$this->_supported_types: ', $this->_supported_types); 
     74            debug_pop(); 
    6775            return false; 
    6876        } 
  • branches/MidCOM_2_8/org.routamc.photostream/viewer.php

    r15522 r16588  
    361361            'variable_args' => 0, 
    362362        ); 
    363  
    364         $this->_request_switch['api-email'] = Array 
    365         ( 
    366             'handler' => Array('org_routamc_photostream_handler_api_email', 'import'), 
    367             'fixed_args' => Array('api', 'email'), 
    368         ); 
    369363         
    370364        // Handle /sort/<property>/ 
     
    382376            'fixed_args' => array('sort'), 
    383377            'variable_args' => 2, 
     378        ); 
     379 
     380        // Handle /api/email 
     381        $this->_request_switch['api-email'] = Array 
     382        ( 
     383            'handler' => Array('org_routamc_photostream_handler_api_email', 'import'), 
     384            'fixed_args' => Array('api', 'email'), 
    384385        ); 
    385386 
     
    504505            unset($new_id, $new_switch); 
    505506        } 
     507        /* 
     508        debug_push_class(__CLASS__, __FUNCTION__); 
     509        debug_print_r('new $this->_request_switch: ', $this->_request_switch); 
     510        debug_pop(); 
     511        */ 
    506512    } 
    507513 
     
    509515    { 
    510516        debug_push_class(__CLASS__, __FUNCTION__); 
     517        debug_print_r('Checking $new_switch: ', $new_switch); 
     518        if (   (   !isset($new_switch['fixed_args']) 
     519                || empty($new_switch['fixed_args']) 
     520            && $new_switch['variable_args'] == 1) 
     521            ) 
     522        { 
     523            // Since we do not want to make hugely elaborate can_handle we just disallow feed handler that would trap the /<feedtype> (preventing subfolders etc) 
     524            debug_add('$new_switch would trap /<anything>, which is bad, rewriting to /feed/index/<anything>', MIDCOM_LOG_INFO); 
     525            array_unshift($new_switch['fixed_args'], 'feed', 'index'); 
     526            debug_print_r('$new_switch after rewrite: ', $new_switch); 
     527            debug_pop(); 
     528            return true; 
     529        } 
    511530        foreach ($this->_request_switch as $handler_id => $switch_data) 
    512531        {