Changeset 2595 for lang/php

Show
Ignore:
Timestamp:
12/06/07 13:17:25 (5 years ago)
Author:
tasuku
Message:

r323@dhcp158 (orig r66): tasuku | 2007-09-12 21:53:08 +0900
include/extends file path check added


Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/php/mumu/trunk/mumu.php

    r2594 r2595  
    7676class MuUtil { 
    7777  public static function getpath($basepath, $path) { 
     78    $basepath = realpath($basepath); 
    7879    $o = getcwd(); 
    7980    chdir(dirname($basepath)); 
    8081    $r = realpath($path); 
     82    if ($basepath == $realpath) { 
     83      // avoid include/extends loop 
     84      return false; 
     85    } 
    8186    chdir($o); 
    8287    return $r; 
     
    230235    $this->block_dict = $block_dict; 
    231236    if ($parentPath && $path) { 
    232       $epath = MuUtil::getpath($path, $parentPath); 
    233       if (($this->parent_tfile = MuParser::parse_from_file($epath)) === false) { 
    234         // TODO: ���顼���������ƥ�졼�������˶����Ƥ�����     } 
     237      if (($epath = MuUtil::getpath($path, $parentPath)) === false 
     238          || ($this->parent_tfile = MuParser::parse_from_file($epath)) === false) { 
     239        throw new MuParserException('invalid filename specified on extends'); 
     240      } 
    235241    } 
    236242  } 
     
    303309  private $tplfile; 
    304310  function __construct($includePath, $path) { 
    305     // FIXME: �������ƥ�����å���̵�¥롼�ץ���å� 
    306     $epath = MuUtil::getpath($path, $includePath); 
    307     if (($this->tplfile = MuParser::parse_from_file($epath)) === false) { 
    308       // TODO: ���顼���������ƥ�졼�������˶����Ƥ�����     $this->tplfile = $this->make_errornode('invalidfilename_include'); 
     311    if (($epath = MuUtil::getpath($path, $includePath)) === false 
     312        || ($this->tplfile = MuParser::parse_from_file($epath)) === false) { 
     313      throw new MuParserException('include filename is invalid'); 
    309314    } 
    310315  }