Changeset 18767


Ignore:
Timestamp:
2010/08/02 10:43:51 (14 years ago)
Author:
nanasess
bzr:base-revision:
svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:18766
bzr:committer:
Kentaro Ohkouchi <ohkouchi@loop-az.jp>
bzr:file-ids:

data/class/util/SC_Utils.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Futil%2FSC_Utils.php
test/TestSuite.php 15114@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Ftest%2FTestSuite.php
test/class/util util-20100802013951-87mspb4qllp7hwwu-1
test/class/util/SC_Utils_Test.php sc_utils_test.php-20100802013957-750m2yralg9cowkd-1
test/class/util/Util_AllTests.php util_alltests.php-20100802013957-750m2yralg9cowkd-2
bzr:mapping-version:
v4
bzr:repository-uuid:
1e3b908f-19a9-db11-a64c-001125224ba8
bzr:revision-id:
ohkouchi@loop-az.jp-20100802014347-0nmgk10iml8gzru5
bzr:revno:
2250
bzr:revprop:branch-nick:
branches/version-2_5-dev
bzr:root:
branches/version-2_5-dev
bzr:text-parents:

data/class/util/SC_Utils.php ohkouchi@loop-az.jp-20100623032937-dhwktuevjyk0jv13
test/TestSuite.php ohkouchi@loop-az.jp-20100726081655-tqxqwy02bxqhswcu
bzr:timestamp:
2010-08-02 10:43:47.825999975 +0900
bzr:user-agent:
bzr2.1.2+bzr-svn1.0.2
svn:original-date:
2010-08-02T01:43:47.826000Z
Message:
  • merged r18709
    • SC_Utils::searchInstallerPath() が相対パスの URL を返さないように修正(#348)
  • SC_Utils::getRealURL() のテストケース追加
Location:
branches/version-2_5-dev
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/util/SC_Utils.php

    r18743 r18767  
    105105    function searchInstallerPath($path) { 
    106106        $installer = 'install/index.php'; 
     107 
     108        if (SC_Utils::sfIsHTTPS()) { 
     109            $proto = "https://"; 
     110        } else { 
     111            $proto = "http://"; 
     112        } 
     113        $host = $proto . $_SERVER['SERVER_NAME']; 
    107114        if ($path == '/') { 
    108             return $path . $installer; 
     115            return $host . $path . $installer; 
    109116        } 
    110117        if (substr($path, -1, 1) != '/') { 
    111118            $path .= $path . '/'; 
    112119        } 
    113         if (SC_Utils::sfIsHTTPS()) { 
    114             $proto = "https://"; 
    115         } else { 
    116             $proto = "http://"; 
    117         } 
    118         $installer_url = $proto . $_SERVER['SERVER_NAME'] . $path . $installer; 
    119         $resources = fopen($installer_url, 'r'); 
     120        $installer_url = $host . $path . $installer; 
     121        $resources = fopen(SC_Utils::getRealURL($installer_url), 'r'); 
    120122        if ($resources === false) { 
    121123            $installer_url = SC_Utils::searchInstallerPath($path . '../'); 
    122124        } 
    123125        return $installer_url; 
     126    } 
     127 
     128    /** 
     129     * 相対パスで記述された URL から絶対パスの URL を取得する. 
     130     * 
     131     * この関数は, http(s):// から始まる URL を解析し, 相対パスで記述されていた 
     132     * 場合, 絶対パスに変換して返す 
     133     * 
     134     * 例) 
     135     * http://www.example.jp/aaa/../index.php 
     136     * ↓ 
     137     * http://www.example.jp/index.php 
     138     * 
     139     * @param string $url http(s):// から始まる URL 
     140     * @return string $url を絶対パスに変換した URL 
     141     */ 
     142    function getRealURL($url) { 
     143        $parse = parse_url($url); 
     144        $tmp = split('/', $parse['path']); 
     145        $results = array(); 
     146        foreach ($tmp as $v) { 
     147            if ($v == '' || $v == '.') { 
     148                // queit. 
     149            } elseif ($v == '..') { 
     150                array_pop($results); 
     151            } else { 
     152                array_push($results, $v); 
     153            } 
     154        } 
     155 
     156        $path = join('/', $results); 
     157        return $parse['scheme'] . '://' . $parse['host'] . '/' . $path; 
    124158    } 
    125159 
  • branches/version-2_5-dev/test/TestSuite.php

    r18763 r18767  
    2727require_once(realpath(dirname(__FILE__)) . "/class/db/DB_AllTests.php"); 
    2828require_once(realpath(dirname(__FILE__)) . "/class/helper/Helper_AllTests.php"); 
     29require_once(realpath(dirname(__FILE__)) . "/class/util/Util_AllTests.php"); 
    2930 
    3031/** 
     
    4142        $suite->addTest(DB_AllTests::suite()); 
    4243        $suite->addTest(Helper_AllTests::suite()); 
     44        $suite->addTest(Util_AllTests::suite()); 
    4345        return $suite; 
    4446    } 
Note: See TracChangeset for help on using the changeset viewer.