Ticket #2482: new_fix_for_req_garble.patch
| File new_fix_for_req_garble.patch, 5.2 kB (added by manickam, 1 year ago) |
|---|
-
lib/routing/sfPathInfoRouting.class.php
old new 81 81 82 82 for ($i = 0; $i < $count; $i++) 83 83 { 84 // see if there's a value associated with this parameter, if not we're done with path data 84 // see if there's a value associated with this parameter, 85 // if not, set the value to empty string 86 // But if parameter is empty string, ignore subsequent value 87 85 88 if ($count > ($i + 1)) 86 89 { 87 $this->currentRouteParameters[$array[$i]] = $array[++$i];90 ($array[$i] != '') ? ($this->currentRouteParameters[$array[$i]] = $array[++$i]) : ++$i; 88 91 } 92 else 93 { 94 ($array[$i] != '') ? ($this->currentRouteParameters[$array[$i]] = '') : ''; 95 } 89 96 } 90 97 91 98 return $this->currentRouteParameters; -
lib/routing/sfPatternRouting.class.php
old new 491 491 $url = substr($url, 0, $pos); 492 492 } 493 493 494 //To fix multiple slash case causing request_params to get garbled 495 $orig_url = $url; 496 preg_match_all( '#/+#', $orig_url, $slashes ); 497 494 498 // we remove multiple / 495 499 $url = preg_replace('#/+#', '/', $url); 496 500 $out = array(); … … 504 508 505 509 $break = false; 506 510 507 if (preg_match($regexp, $url, $r ))511 if (preg_match($regexp, $url, $r, PREG_OFFSET_CAPTURE)) 508 512 { 509 513 $break = true; 510 514 … … 531 535 } 532 536 533 537 $pos = 0; 534 foreach ($r as $found )538 foreach ($r as $founded) 535 539 { 540 $found = $founded[0]; 541 536 542 // if $found is a named url element (i.e. ':action') 537 543 if (isset($names[$pos])) 538 544 { … … 541 547 // unnamed elements go in as 'pass' 542 548 else 543 549 { 550 //To fix multiple slashes case causing request params to get garbled 551 $prev_slash_count = substr_count( substr( $url, 0, $founded[1] ), '/' ); 552 $in_slash_count = substr_count( substr( $url, $founded[1], strlen( $found ) ), '/' ); 553 554 $prev_offset = $end_offset = 0; 555 for( $i=0; $i<$prev_slash_count; $i++ ) 556 { 557 $prev_offset += strlen( $slashes[0][$i] ) -1; 558 } 559 560 for( ; $i<$prev_slash_count + $in_slash_count; $i++) 561 { 562 $end_offset += strlen( $slashes[0][$i] ) -1; 563 } 564 565 $found = substr( $orig_url, $prev_offset + $founded[1], strlen($found) + $end_offset ); 566 //End of "To fix multiple slashes case causing request params to get garbled" 567 544 568 $pass = explode('/', $found); 545 569 $found = ''; 546 570 for ($i = 0, $max = count($pass); $i < $max; $i += 2) 547 571 { 548 if (!isset($pass[$i + 1])) 549 { 550 continue; 551 } 572 if ($pass[$i] == '') continue;//If key is empty, ignore subsequent value.. Instead If value alone is absent, set key to empty string. 552 573 553 574 $found .= $pass[$i].'='.$pass[$i + 1].'&'; 554 575 } -
lib/util/sfSimpleAutoload.class.php
old new 141 141 require_once(dirname(__FILE__).'/sfFinder.class.php'); 142 142 143 143 $finder = sfFinder::type('file')->ignore_version_control()->follow_link()->name('*'.$ext); 144 foreach (glob($dir) as $dir) 144 145 if (($dirs = glob($dir))) 145 146 { 146 if (in_array($dir, $this->dirs))147 foreach (glob($dir) as $dir) 147 148 { 148 if ( $this->cacheLoaded)149 if (in_array($dir, $this->dirs)) 149 150 { 150 continue; 151 if ($this->cacheLoaded) 152 { 153 continue; 154 } 151 155 } 156 else 157 { 158 $this->dirs[] = $dir; 159 } 160 161 $this->cacheChanged = true; 162 $this->addFiles($finder->in($dir), false); 152 163 } 153 else154 {155 $this->dirs[] = $dir;156 }157 158 $this->cacheChanged = true;159 $this->addFiles($finder->in($dir), false);160 164 } 161 165 } 162 166