diff --git a/js/src/modules/git-info.js b/js/src/modules/git-info.js index 792053a5e9..19c06f85dc 100644 --- a/js/src/modules/git-info.js +++ b/js/src/modules/git-info.js @@ -43,7 +43,7 @@ const GitInfo = { if (data && data.version && data.date) { const current = GitInfo.parseVersionString($('span.version').text()); const latest = GitInfo.parseVersionString(data.version); - const url = './url.php?url=https://www.phpmyadmin.net/files/' + Functions.escapeHtml(encodeURIComponent(data.version)) + '/'; + const url = 'index.php?route=/url&url=https://www.phpmyadmin.net/files/' + Functions.escapeHtml(encodeURIComponent(data.version)) + '/'; let versionInformationMessage = document.createElement('span'); versionInformationMessage.className = 'latest'; const versionInformationMessageLink = document.createElement('a'); diff --git a/libraries/classes/Common.php b/libraries/classes/Common.php index 496e166a6c..706074dc33 100644 --- a/libraries/classes/Common.php +++ b/libraries/classes/Common.php @@ -95,7 +95,7 @@ final class Common $request = self::getRequest(); $route = $request->getRoute(); - if ($route === '/import-status') { + if ($route === '/import-status' || $route === '/url') { $GLOBALS['isMinimumCommon'] = true; } @@ -209,6 +209,10 @@ final class Common $GLOBALS['containerBuilder']->set('theme_manager', ThemeManager::getInstance()); Tracker::enable(); + if ($route === '/url') { + UrlRedirector::redirect(); + } + return; } diff --git a/libraries/classes/Controllers/ChangeLogController.php b/libraries/classes/Controllers/ChangeLogController.php index b1b96813df..d1f5b667c5 100644 --- a/libraries/classes/Controllers/ChangeLogController.php +++ b/libraries/classes/Controllers/ChangeLogController.php @@ -8,6 +8,7 @@ declare(strict_types=1); namespace PhpMyAdmin\Controllers; use PhpMyAdmin\Http\ServerRequest; +use PhpMyAdmin\Url; use function __; use function array_keys; @@ -64,30 +65,34 @@ class ChangeLogController extends AbstractController $faq_url = 'https://docs.phpmyadmin.net/en/latest/faq.html'; $replaces = [ - '@(https?://[./a-zA-Z0-9.-_-]*[/a-zA-Z0-9_])@' => '\\1', + '@(https?://[./a-zA-Z0-9.-_-]*[/a-zA-Z0-9_])@' => '\\1', // mail address '/([0-9]{4}-[0-9]{2}-[0-9]{2}) (.+[^ ]) +<(.*@.*)>/i' => '\\1 \\2', // FAQ entries - '/FAQ ([0-9]+)\.([0-9a-z]+)/i' => 'FAQ \\1.\\2', + '/FAQ ([0-9]+)\.([0-9a-z]+)/i' => 'FAQ \\1.\\2', // GitHub issues - '/issue\s*#?([0-9]{4,5}) /i' => 'issue #\\1 ', + '/issue\s*#?([0-9]{4,5}) /i' => 'issue #\\1 ', // CVE/CAN entries - '/((CAN|CVE)-[0-9]+-[0-9]+)/' => '\\1', // PMASAentries - '/(PMASA-[0-9]+-[0-9]+)/' => '\\1', + '/(PMASA-[0-9]+-[0-9]+)/' => '\\1', // Highlight releases (with links) '/([0-9]+)\.([0-9]+)\.([0-9]+)\.0 (\([0-9-]+\))/' => '' - . '' + . '' . '\\1.\\2.\\3.0 \\4', '/([0-9]+)\.([0-9]+)\.([0-9]+)\.([1-9][0-9]*) (\([0-9-]+\))/' => '' - . '' + . '' . '\\1.\\2.\\3.\\4 \\5', // Highlight releases (not linkable) @@ -95,7 +100,6 @@ class ChangeLogController extends AbstractController // Links target and rel '/a href="/' => 'a target="_blank" rel="noopener noreferrer" href="', - ]; $this->response->header('Content-type: text/html; charset=utf-8'); diff --git a/libraries/classes/Core.php b/libraries/classes/Core.php index 2ecff03c31..94b5b6ff3d 100644 --- a/libraries/classes/Core.php +++ b/libraries/classes/Core.php @@ -633,10 +633,10 @@ class Core $query = http_build_query(['url' => $vars['url']]); if ($GLOBALS['config'] !== null && $GLOBALS['config']->get('is_setup')) { - return '../url.php?' . $query; + return '../index.php?route=/url&' . $query; } - return './url.php?' . $query; + return 'index.php?route=/url&' . $query; } /** diff --git a/libraries/classes/Html/Generator.php b/libraries/classes/Html/Generator.php index 746f012589..da73100420 100644 --- a/libraries/classes/Html/Generator.php +++ b/libraries/classes/Html/Generator.php @@ -636,8 +636,8 @@ class Generator . urlencode(self::generateRowQueryOutput($sqlQuery)); $explainLink .= ' [' . self::linkOrButton( - htmlspecialchars('url.php?url=' . urlencode($url)), - null, + Url::getFromRoute('/url'), + ['url' => $url], sprintf(__('Analyze Explain at %s'), 'mariadb.org'), [], '_blank', @@ -1071,7 +1071,7 @@ class Generator if (! empty($target)) { $tagParams['target'] = $target; - if ($target === '_blank' && str_starts_with($url, 'url.php?')) { + if ($target === '_blank' && str_starts_with($url, 'index.php?route=/url&url=')) { $tagParams['rel'] = 'noopener noreferrer'; } } diff --git a/libraries/classes/Sanitize.php b/libraries/classes/Sanitize.php index f8366aec60..056459767e 100644 --- a/libraries/classes/Sanitize.php +++ b/libraries/classes/Sanitize.php @@ -46,7 +46,7 @@ class Sanitize $url = strtolower($url); $valid_starts = [ 'https://', - './url.php?url=https%3a%2f%2f', + 'index.php?route=/url&url=https%3a%2f%2f', './doc/html/', './index.php?', ]; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c6df54e6e3..b071d0db63 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $matches[1] diff --git a/psalm.xml b/psalm.xml index 4b3a1cadd4..83a7d3d1ab 100644 --- a/psalm.xml +++ b/psalm.xml @@ -18,7 +18,6 @@ - diff --git a/scripts/check-release-excludes.sh b/scripts/check-release-excludes.sh index 9c23a6d791..0d945400d6 100755 --- a/scripts/check-release-excludes.sh +++ b/scripts/check-release-excludes.sh @@ -183,8 +183,6 @@ validateExtension() { ;; index.php) ;; - url.php) - ;; js/messages.php) ;; config.sample.inc.php) diff --git a/templates/home/index.twig b/templates/home/index.twig index 9e089f840c..1d0a3f36dc 100644 --- a/templates/home/index.twig +++ b/templates/home/index.twig @@ -18,7 +18,7 @@ {% trans 'phpMyAdmin Demo Server' %}
- {% apply format('demo.phpmyadmin.net')|raw %} + {% apply format('demo.phpmyadmin.net')|raw %} {% trans %} You are using the demo server. You can do anything here, but please do not change root, debian-sys-maint and pma users. More information is available at %s. {% endtrans %} diff --git a/templates/login/form.twig b/templates/login/form.twig index 2f0c915a32..4770ea8e67 100644 --- a/templates/login/form.twig +++ b/templates/login/form.twig @@ -4,7 +4,7 @@
{% trans 'phpMyAdmin Demo Server' %}
- {% apply format('demo.phpmyadmin.net')|raw %} + {% apply format('demo.phpmyadmin.net')|raw %} {% trans %} You are using the demo server. You can do anything here, but please do not change root, debian-sys-maint and pma users. More information is available at %s. {% endtrans %} diff --git a/templates/setup/home/index.twig b/templates/setup/home/index.twig index 6afaebdc99..a3ede4e973 100644 --- a/templates/setup/home/index.twig +++ b/templates/setup/home/index.twig @@ -172,8 +172,8 @@ diff --git a/test/classes/Advisory/AdvisorTest.php b/test/classes/Advisory/AdvisorTest.php index 468f425c51..25f849be6a 100644 --- a/test/classes/Advisory/AdvisorTest.php +++ b/test/classes/Advisory/AdvisorTest.php @@ -227,7 +227,7 @@ class AdvisorTest extends AbstractTestCase 'justification_formula' => 'value', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', - 'recommendation' => 'See web', 'id' => 'Distribution', ], @@ -247,7 +247,7 @@ class AdvisorTest extends AbstractTestCase 'justification_formula' => 'ADVISOR_timespanFormat(1377027)', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', - 'recommendation' => 'See web', 'id' => 'Distribution', ], @@ -268,9 +268,9 @@ class AdvisorTest extends AbstractTestCase 'justification_formula' => 'ADVISOR_formatByteDown(1000000, 2, 2)', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', - 'recommendation' => 'See web' - . ' and web2', 'id' => 'Distribution', ], @@ -292,9 +292,9 @@ class AdvisorTest extends AbstractTestCase 'name' => 'Distribution', 'issue' => '' . 'long_query_time is set to 10 seconds or more', - 'recommendation' => 'See web' - . ' and web2', 'id' => 'Distribution', ], diff --git a/test/classes/Config/FormDisplayTest.php b/test/classes/Config/FormDisplayTest.php index 7c0e4b2442..e89974f994 100644 --- a/test/classes/Config/FormDisplayTest.php +++ b/test/classes/Config/FormDisplayTest.php @@ -312,7 +312,8 @@ class FormDisplayTest extends AbstractTestCase public function testGetDocLink(): void { $this->assertEquals( - './url.php?url=https%3A%2F%2Fdocs.phpmyadmin.net%2Fen%2Flatest%2Fconfig.html%23cfg_Servers_3_test_2_', + 'index.php?route=/url&url=' + . 'https%3A%2F%2Fdocs.phpmyadmin.net%2Fen%2Flatest%2Fconfig.html%23cfg_Servers_3_test_2_', $this->object->getDocLink('Servers/3/test/2/') ); diff --git a/test/classes/CoreTest.php b/test/classes/CoreTest.php index e0bcd4531e..d61c6533df 100644 --- a/test/classes/CoreTest.php +++ b/test/classes/CoreTest.php @@ -484,7 +484,7 @@ class CoreTest extends AbstractNetworkTestCase $lang = _pgettext('PHP documentation language', 'en'); $this->assertEquals( Core::getPHPDocLink('function'), - './url.php?url=https%3A%2F%2Fwww.php.net%2Fmanual%2F' + 'index.php?route=/url&url=https%3A%2F%2Fwww.php.net%2Fmanual%2F' . $lang . '%2Ffunction' ); } @@ -512,11 +512,11 @@ class CoreTest extends AbstractNetworkTestCase return [ [ 'https://wiki.phpmyadmin.net', - './url.php?url=https%3A%2F%2Fwiki.phpmyadmin.net', + 'index.php?route=/url&url=https%3A%2F%2Fwiki.phpmyadmin.net', ], [ 'https://wiki.phpmyadmin.net', - './url.php?url=https%3A%2F%2Fwiki.phpmyadmin.net', + 'index.php?route=/url&url=https%3A%2F%2Fwiki.phpmyadmin.net', ], [ 'wiki.phpmyadmin.net', diff --git a/test/classes/Html/GeneratorTest.php b/test/classes/Html/GeneratorTest.php index d05fc57571..39f3ee6b8a 100644 --- a/test/classes/Html/GeneratorTest.php +++ b/test/classes/Html/GeneratorTest.php @@ -177,7 +177,7 @@ class GeneratorTest extends AbstractTestCase $target = 'docu'; $lang = _pgettext('PHP documentation language', 'en'); - $expected = '' . ''
             . __('Documentation') . ''; @@ -282,14 +282,15 @@ class GeneratorTest extends AbstractTestCase ], [ [ - 'url.php?url=http://phpmyadmin.net/', + 'index.php?route=/url&url=http://phpmyadmin.net/', null, 'text', [], '_blank', ], 1000, - 'text', + 'text', ], [ [ @@ -355,12 +356,12 @@ class GeneratorTest extends AbstractTestCase public function testGetServerSSL(): void { $sslNotUsed = 'SSL is not being used' - . ' Documentation'; $sslNotUsedCaution = 'SSL is not being used' - . ' Documentation'; @@ -414,7 +415,7 @@ class GeneratorTest extends AbstractTestCase $this->assertEquals( 'SSL is used with disabled verification' - . ' Documentation', Generator::getServerSSL() @@ -428,7 +429,7 @@ class GeneratorTest extends AbstractTestCase $this->assertEquals( 'SSL is used without certification authority' - . ' Documentation', Generator::getServerSSL() @@ -443,7 +444,7 @@ class GeneratorTest extends AbstractTestCase $this->assertEquals( 'SSL is used' - . ' Documentation', Generator::getServerSSL() diff --git a/test/classes/Html/MySQLDocumentationTest.php b/test/classes/Html/MySQLDocumentationTest.php index 9057667c5c..7e84e66501 100644 --- a/test/classes/Html/MySQLDocumentationTest.php +++ b/test/classes/Html/MySQLDocumentationTest.php @@ -18,7 +18,7 @@ class MySQLDocumentationTest extends AbstractTestCase $GLOBALS['cfg']['ServerDefault'] = 1; $this->assertEquals( - 'Documentation', MySQLDocumentation::showDocumentation('page', 'anchor') diff --git a/test/classes/MessageTest.php b/test/classes/MessageTest.php index d9b9b9f7ed..d3073e6278 100644 --- a/test/classes/MessageTest.php +++ b/test/classes/MessageTest.php @@ -352,7 +352,7 @@ class MessageTest extends AbstractTestCase ], [ '[a@https://example.com/@Documentation]link[/a]', - 'link', + 'link', ], [ '[a@./non-existing@Documentation]link[/a]', @@ -360,19 +360,19 @@ class MessageTest extends AbstractTestCase ], [ '[doc@foo]link[/doc]', - 'link', ], [ '[doc@page@anchor]link[/doc]', - 'link', ], [ '[doc@faqmysql]link[/doc]', - 'link', ], @@ -463,7 +463,7 @@ class MessageTest extends AbstractTestCase { $this->object->setMessage('[kbd]test[/kbd] [doc@cfg_Example]test[/doc]'); $this->assertEquals( - 'test test', $this->object->getMessage() diff --git a/test/classes/Plugins/Auth/AuthenticationConfigTest.php b/test/classes/Plugins/Auth/AuthenticationConfigTest.php index 833351b9ea..6187b54850 100644 --- a/test/classes/Plugins/Auth/AuthenticationConfigTest.php +++ b/test/classes/Plugins/Auth/AuthenticationConfigTest.php @@ -97,7 +97,7 @@ class AuthenticationConfigTest extends AbstractTestCase ); $this->assertStringContainsString( - 'MySQL said: ' . 'DocumentationassertEquals( - 'link', + 'link', Sanitize::sanitizeMessage('[a@https://www.phpmyadmin.net/@target]link[/a]') ); @@ -60,7 +60,7 @@ class SanitizeTest extends AbstractTestCase public function testDoc(string $link, string $expected): void { $this->assertEquals( - 'doclink', Sanitize::sanitizeMessage('[doc@' . $link . ']doclink[/doc]') ); @@ -121,7 +121,7 @@ class SanitizeTest extends AbstractTestCase public function testLinkAndXssInHref(): void { $this->assertEquals( - 'doc' + 'doc' . '[a@javascript:alert(\'XSS\');@target]link', Sanitize::sanitizeMessage( '[a@https://docs.phpmyadmin.net/]doc[/a][a@javascript:alert(\'XSS\');@target]link[/a]' @@ -402,13 +402,13 @@ class SanitizeTest extends AbstractTestCase ], [ false, - './url.php?url=https://example.com', + 'index.php?route=/url&url=https://example.com', false, false, ], [ true, - './url.php?url=https%3a%2f%2fexample.com', + 'index.php?route=/url&url=https%3a%2f%2fexample.com', false, false, ], diff --git a/url.php b/url.php deleted file mode 100644 index 44fb191800..0000000000 --- a/url.php +++ /dev/null @@ -1,42 +0,0 @@ -PHP 7.2.5+ is required.

Currently installed version is: ' . PHP_VERSION . '

'); -} - -// phpcs:disable PSR1.Files.SideEffects -define('PHPMYADMIN', true); -// phpcs:enable - -require_once ROOT_PATH . 'libraries/constants.php'; - -/** - * Activate autoloader - */ -if (! @is_readable(AUTOLOAD_FILE)) { - die( - '

File ' . AUTOLOAD_FILE . ' missing or not readable.

' - . '

Most likely you did not run Composer to ' - . '' - . 'install library files.

' - ); -} - -require AUTOLOAD_FILE; - -$GLOBALS['isMinimumCommon'] = true; - -Common::run(); - -UrlRedirector::redirect();