Changeset 3283

Show
Ignore:
Timestamp:
12/06/06 14:34:42 (5 years ago)
Author:
gregmac
Message:

Fix bug with fixlocalprefix not sanitizing pattern, fix verbose priorities

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/agi-bin/fixlocalprefix

    r2732 r3283  
    114114  $chars = '0-9XNZwW#*\.\[\]\-'; //escaped pcre-ready 
    115115   
     116  // convert x n and z to uppercase 
     117  $regex = str_replace(array('x','n','z'), array('X','N','Z'), $pattern); 
    116118  // sanitize the pattern - remove any non-pattern chars 
    117119  $regex = preg_replace("/[^0-9XNZwW#*\.\[\]\-\+\|]/", "", $regex); 
     
    119121  $regex = preg_replace("/((?:\[[^\]]*\])*)([^\[\]\-]*)-?/", "$1$2", $regex); 
    120122 
     123  $agi->verbose('Using pattern '.$regex, 4); 
    121124  // attempt to grab the pieces of the pattern 
    122   if (preg_match('/^(([0-9XNZwW#*\.\[\]\-]+)\|)?(([0-9XNZwW#*\.\[\]\-]+)\+)?([0-9XNZwW#*\.\[\]\-]+)$/', $pattern, $matches)) { 
     125  if (preg_match('/^(([0-9XNZwW#*\.\[\]\-]+)\|)?(([0-9XNZwW#*\.\[\]\-]+)\+)?([0-9XNZwW#*\.\[\]\-]+)$/', $regex, $matches)) { 
    123126    // one of NXXXXXX, 613|NXXXXXX   1+NXXXXXX    613|1+NXXXXXX,   
    124127    // matches[2] = drop (eg 613),  matches[4] = prefix (eg 1),  matches[5] = rest of number (eg NXXXXX) 
     
    127130    $prefix = $matches[4]; 
    128131    $static = $matches[5]; 
    129   } else if (preg_match('/^(([0-9XNZwW#*\.\[\]\-]+)\+)?(([0-9XNZwW#*\.\[\]\-]+)\|)?([0-9XNZwW#*\.\[\]\-]+)$/', $pattern, $matches)) { 
     132  } else if (preg_match('/^(([0-9XNZwW#*\.\[\]\-]+)\+)?(([0-9XNZwW#*\.\[\]\-]+)\|)?([0-9XNZwW#*\.\[\]\-]+)$/', $regex, $matches)) { 
    130133    // one of NXXXXXX,  613|NXXXXXX   1+NXXXXXX    1+613|NXXXXXX 
    131134    // matches[2] = prefix (eg 1),  matches[4] = drop (eg 613),  matches[5] = rest of number (eg NXXXXX) 
     
    136139  } else { 
    137140    if (!is_null($agi)) { 
    138       $agi->verbose('Could not understand pattern "'.$pattern.'"', 3); 
     141      $agi->verbose('Could not understand pattern "'.$pattern.'" ('.$regex.')', 1); 
    139142    } 
    140143    return $false; 
     
    203206       
    204207      if ($newnum = fixNumber($rule, $number, $agi)) { 
    205         $agi->verbose('Dialpattern '.$rule.' matched. '.$number.' -> '.$newnum, 1); 
     208        $agi->verbose('Dialpattern '.$rule.' matched. '.$number.' -> '.$newnum, 2); 
    206209        $agi->set_variable("DIAL_NUMBER", $newnum); 
    207210