Merge branch 'Rudloff:master' into master

This commit is contained in:
Advizormcpe1 2022-02-26 14:50:33 +09:00 committed by GitHub
commit 61e21dbdaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 12 deletions

16
SECURITY.md Normal file
View File

@ -0,0 +1,16 @@
# Security Policy
## Supported Versions
Only the latest major release is supported.
| Version | Supported |
|---------|-----------|
| 3.x | Yes |
| 2.x | No |
| 1.x | No |
## Reporting a Vulnerability
If you need to report a vulnerability, you can send an e-mail to
[contact@rudloff.pro](mailto:contact@rudloff.pro).

View File

@ -37,6 +37,34 @@ class ViewFactory
->withScheme('https'); ->withScheme('https');
} }
/**
* @param Uri $uri
* @return Uri
*/
private static function cleanBasePath(Uri $uri): Uri
{
$basePath = $uri->getBasePath();
if (str_ends_with($basePath, 'index.php')) {
$basePath = dirname($basePath);
if ($basePath == '/') {
/*
* Calling withBasePath('/') does nothing,
* we have to use an empty string instead.
*/
$basePath = '';
}
/*
* When the base path ends with index.php,
* routing works correctly, but it breaks the URL of static assets using {base_url}.
* So we alter the base path but only in the URI used by SmartyPlugins.
*/
$uri = $uri->withBasePath($basePath);
}
return $uri;
}
/** /**
* Create Smarty view object. * Create Smarty view object.
* *
@ -76,6 +104,8 @@ class ViewFactory
/** @var LocaleManager $localeManager */ /** @var LocaleManager $localeManager */
$localeManager = $container->get('locale'); $localeManager = $container->get('locale');
$uri = self::cleanBasePath($uri);
$smartyPlugins = new SmartyPlugins($container->get('router'), $uri->withUserInfo('')); $smartyPlugins = new SmartyPlugins($container->get('router'), $uri->withUserInfo(''));
$view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']); $view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']);
$view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']); $view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);

19
composer.lock generated
View File

@ -1346,16 +1346,16 @@
}, },
{ {
"name": "smarty/smarty", "name": "smarty/smarty",
"version": "v3.1.39", "version": "v3.1.43",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/smarty-php/smarty.git", "url": "https://github.com/smarty-php/smarty.git",
"reference": "e27da524f7bcd7361e3ea5cdfa99c4378a7b5419" "reference": "273f7e00fec034f6d61112552e9caf08d19565b7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/smarty-php/smarty/zipball/e27da524f7bcd7361e3ea5cdfa99c4378a7b5419", "url": "https://api.github.com/repos/smarty-php/smarty/zipball/273f7e00fec034f6d61112552e9caf08d19565b7",
"reference": "e27da524f7bcd7361e3ea5cdfa99c4378a7b5419", "reference": "273f7e00fec034f6d61112552e9caf08d19565b7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1399,7 +1399,13 @@
"keywords": [ "keywords": [
"templating" "templating"
], ],
"time": "2021-02-17T21:57:51+00:00" "support": {
"forum": "http://www.smarty.net/forums/",
"irc": "irc://irc.freenode.org/smarty",
"issues": "https://github.com/smarty-php/smarty/issues",
"source": "https://github.com/smarty-php/smarty/tree/v3.1.43"
},
"time": "2022-01-10T09:52:40+00:00"
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
@ -7132,5 +7138,6 @@
"platform-dev": [], "platform-dev": [],
"platform-overrides": { "platform-overrides": {
"php": "7.3.11" "php": "7.3.11"
} },
"plugin-api-version": "2.2.0"
} }

View File

@ -5,11 +5,6 @@ require_once __DIR__ . '/vendor/autoload.php';
use Alltube\App; use Alltube\App;
use Alltube\ErrorHandler; use Alltube\ErrorHandler;
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
header('Location: ' . str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
die;
}
try { try {
// Create app. // Create app.
$app = new App(); $app = new App();

View File

@ -1,5 +1,5 @@
<h1 class="logobis"> <h1 class="logobis">
<a class="logocompatible" href="{base_url}"> <a class="logocompatible" href="{path_for name="index"}">
<span class="logocompatiblemask"><img src="{base_url}/img/logocompatiblemask.png" width="447" height="107" <span class="logocompatiblemask"><img src="{base_url}/img/logocompatiblemask.png" width="447" height="107"
alt="{$config->appName}"/></span> alt="{$config->appName}"/></span>
</a></h1> </a></h1>