Changeset 23018


Ignore:
Timestamp:
2013/08/01 01:16:56 (11 years ago)
Author:
Seasoft
Message:

#1417 (LC_Page#getRootPath $path にクエリー文字列を含むと誤動作)
#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)
#2318 (LC_Page#getRootPath realpath 関数のエラーを無視して不適切な値を返す)
#2319 (LC_Page#getRootPath 意図しない値を返す場合がある)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/class/pages/LC_Page.php

    r22931 r23018  
    292292     * 
    293293     * @param string $path 結果を取得するためのパス 
    294      * @return string EC-CUBE のWEBルート(/html/)を / としたパス 
     294     * @return string EC-CUBE のWEBルート(/html/)からのパス。 
    295295     */ 
    296296    function getRootPath($path) 
    297297    { 
     298        // realpath 関数は、QUERY_STRING を扱えないため、退避する。 
     299        $query_string = ''; 
     300        if (preg_match('/^(.+)\\?(.+)$/', $path, $arrMatch)) { 
     301            $path = $arrMatch[1]; 
     302            $query_string = $arrMatch[2]; 
     303        } 
     304 
    298305        // Windowsの場合は, ディレクトリの区切り文字を\から/に変換する 
    299306        $path = str_replace('\\', '/', $path); 
     
    312319            $realPath = realpath($path); 
    313320        } 
     321        if ($realPath === false) { 
     322            trigger_error('realpath でエラー発生。', E_USER_ERROR); 
     323        } 
    314324        $realPath = str_replace('\\', '/', $realPath); 
    315325 
     
    320330 
    321331        // HTML_REALDIR を削除した文字列を取得. 
    322         $rootPath = str_replace($htmlPath, '', $realPath); 
    323         $rootPath = ltrim($rootPath, '/'); 
     332        if (substr($realPath, 0, strlen($htmlPath)) !== $htmlPath) { 
     333            trigger_error('不整合', E_USER_ERROR); 
     334        } 
     335        $rootPath = substr($realPath, strlen($htmlPath)); 
     336 
     337        // QUERY_STRING を復元する。 
     338        if (strlen($query_string) >= 1) { 
     339            $rootPath .= '?' . $query_string; 
     340        } 
    324341 
    325342        return $rootPath; 
Note: See TracChangeset for help on using the changeset viewer.