summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/phar-stub.php20
-rw-r--r--src/SemanticScuttle/Environment.php4
-rw-r--r--tests/SemanticScuttle/EnvironmentTest.php22
3 files changed, 40 insertions, 6 deletions
diff --git a/res/phar-stub.php b/res/phar-stub.php
index 9a4dfd4..8e69745 100644
--- a/res/phar-stub.php
+++ b/res/phar-stub.php
@@ -25,12 +25,22 @@ function mapUrls($path)
if (isset($arMap[$path])) {
return $arMap[$path];
}
- $pos = strrpos($path, '.');
- if ($pos === false || strlen($path) - $pos > 5) {
- //clean url
- $path .= '.php';
+ $parts = explode('/', $path);
+ $partPos = 1;
+ if (in_array($parts[$partPos], array('js', 'player', 'themes'))) {
+ return '/www' . $path;
}
- return '/www' . $path;
+ if (in_array($parts[$partPos], array('ajax', 'api', 'gsearch'))) {
+ $partPos = 2;
+ }
+ $pos = strrpos($parts[$partPos], '.');
+ if ($pos === false) {
+ $parts[$partPos] .= '.php';
+ $_SERVER['PATH_INFO'] = '/' . implode(
+ '/', array_slice($parts, $partPos + 1)
+ );
+ }
+ return '/www' . implode('/', $parts);
}
Phar::webPhar(
diff --git a/src/SemanticScuttle/Environment.php b/src/SemanticScuttle/Environment.php
index 4ba9c82..7c8e669 100644
--- a/src/SemanticScuttle/Environment.php
+++ b/src/SemanticScuttle/Environment.php
@@ -31,7 +31,9 @@ class SemanticScuttle_Environment
{
if (isset($_SERVER['PHAR_PATH_TRANSLATED'])) {
$fscript = '/' . $_SERVER['SCRIPT_NAME'];
- if ($fscript == $_SERVER['PATH_INFO']) {
+ if ($fscript == $_SERVER['PATH_INFO']
+ || $fscript == $_SERVER['PATH_INFO'] . '.php'
+ ) {
return null;
} else if (substr($_SERVER['PATH_INFO'], 0, strlen($fscript)) == $fscript) {
return substr($_SERVER['PATH_INFO'], strlen($fscript));
diff --git a/tests/SemanticScuttle/EnvironmentTest.php b/tests/SemanticScuttle/EnvironmentTest.php
index 01dab82..154430e 100644
--- a/tests/SemanticScuttle/EnvironmentTest.php
+++ b/tests/SemanticScuttle/EnvironmentTest.php
@@ -251,6 +251,28 @@ class SemanticScuttle_EnvironmentTest extends PHPUnit_Framework_TestCase
);
}
+ public function testGetServerPathInfoPharCleanUrl()
+ {
+ $_SERVER = array(
+ 'HTTP_HOST' => 'dist.bm.bogo',
+ 'SERVER_NAME' => 'dist.bm.bogo',
+ 'SERVER_ADDR' => '127.0.0.1',
+ 'SERVER_PORT' => '80',
+ 'DOCUMENT_ROOT' => '/etc/apache2/htdocs' ,
+ 'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/SemanticScuttle-0.98.X.phar' ,
+ 'QUERY_STRING' => '',
+ 'REQUEST_URI' => '/SemanticScuttle-0.98.X.phar/populartags',
+ 'SCRIPT_NAME' => 'populartags.php',
+ 'PATH_INFO' => '/populartags',
+ 'PATH_TRANSLATED' => 'phar:///home/cweiske/Dev/semanticscuttle/cwdev/dist/SemanticScuttle-0.98.X.phar/www/populartags.php',
+ 'PHP_SELF' => '/SemanticScuttle-0.98.X.phar/populartags',
+ 'PHAR_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/populartags',
+ );
+ $this->assertNull(
+ SemanticScuttle_Environment::getServerPathInfo()
+ );
+ }
+
public function testGetServerPathInfoPharWithInfo()
{
$_SERVER = array(