Changeset 2080

Show
Ignore:
Timestamp:
02/19/2008 02:27:29 AM (9 months ago)
Author:
Geert
Message:

Fixing #415.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/core/Config.php

    r2076 r2080  
    9191                Config::item($key); 
    9292 
    93                 if (strpos($key, '{') !== FALSE) 
     93                // Clean key 
     94                $key = rtrim($key, '.'); 
     95 
     96                if (substr($key, 0, 7) === 'routes.') 
    9497                { 
    95                         // The follow garbage is the biggest hack ever, and shows my total 
    96                         // lack of advanced regex skills. Hopefully Geert can replace this 
    97                         // with a "lookahead" or some kind of fancy-pants regex. :) -Woody 
    98  
    99                         // Final keys 
    100                         $keys = array(); 
    101  
    102                         // Break token and token buffer 
    103                         $break  = '.'; 
    104                         $buffer = ''; 
    105  
    106                         // Parse each letter of the string... ick 
    107                         for ($i = 0, $max = strlen($key); $i <= $max; $i++) 
    108                         { 
    109                                 if ($i === $max AND ! empty($buffer)) 
    110                                 { 
    111                                         if ($break === '}.' AND substr($buffer, -1) === '}') 
    112                                         { 
    113                                                 // Remove the ending "unquote" 
    114                                                 $buffer = substr($buffer, 0, -1); 
    115                                         } 
    116  
    117                                         // Add the final buffer 
    118                                         $keys[] = $buffer; 
    119                                         break; 
    120                                 } 
    121  
    122                                 // Current token 
    123                                 $token = $key{$i}; 
    124  
    125                                 if ($token === '{' AND $break === '.') 
    126                                 { 
    127                                         // Change the break token to "unquote dot" 
    128                                         $break = '}.'; 
    129                                 } 
    130                                 elseif ($token === '.' AND $break === '.') 
    131                                 { 
    132                                         // Add the key and reset the buffer 
    133                                         $keys[] = $buffer; 
    134                                         $buffer = ''; 
    135                                 } 
    136                                 elseif ($break === '}.' AND substr($key, $i, 2) === '}.') 
    137                                 { 
    138                                         // Add the key and reset the buffer 
    139                                         $keys[] = $buffer; 
    140                                         $buffer = ''; 
    141  
    142                                         // Reset the break token 
    143                                         $break = '.'; 
    144  
    145                                         // Increase the buffer to skip the next "dot" 
    146                                         $i++; 
    147                                 } 
    148                                 else 
    149                                 { 
    150                                         // Add the token to the buffer 
    151                                         $buffer = $buffer.$token; 
    152                                 } 
    153                         } 
     98                        // Routes cannot contain sub keys due to possible dots in regex 
     99                        $keys = explode('.', $key, 2); 
    154100                } 
    155101                else 
    156102                { 
    157103                        // Convert dot-noted key string to an array 
    158                         $keys = explode('.', rtrim($key, '.')); 
     104                        $keys = explode('.', $key); 
    159105                } 
    160106