Only check unsupported browsers on user rendering

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ 2022-10-22 12:49:11 +02:00
parent 3323b1ac0d
commit a8e8a89ade
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
22 changed files with 127 additions and 15 deletions

View File

@ -823,12 +823,23 @@
</InvalidOperand>
</file>
<file src="apps/encryption/lib/Crypto/Crypt.php">
<InvalidArgument occurrences="2">
<code>$res</code>
<code>$res</code>
</InvalidArgument>
<InvalidReturnStatement occurrences="1">
<code>openssl_pkey_new($config)</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>resource</code>
</InvalidReturnType>
<RedundantCondition occurrences="2">
<code>$userSession</code>
<code>$userSession</code>
</RedundantCondition>
<TypeDoesNotContainType occurrences="2">
<code>get_class($res) === 'OpenSSLAsymmetricKey'</code>
<code>is_resource($res)</code>
</TypeDoesNotContainType>
</file>
<file src="apps/encryption/lib/Crypto/EncryptAll.php">
@ -1066,6 +1077,12 @@
<code>addServiceListener</code>
</InvalidArgument>
</file>
<file src="apps/files_external/lib/Lib/Storage/FtpConnection.php">
<UndefinedConstant occurrences="2">
<code>FTP_BINARY</code>
<code>FTP_BINARY</code>
</UndefinedConstant>
</file>
<file src="apps/files_external/lib/Lib/Storage/SFTP.php">
<InternalMethod occurrences="1">
<code>put</code>
@ -1097,10 +1114,12 @@
</TooManyArguments>
</file>
<file src="apps/files_external/lib/Service/BackendService.php">
<InvalidArgument occurrences="1">
<code>'OCA\\Files_External::loadAdditionalBackends'</code>
</InvalidArgument>
<TooManyArguments occurrences="1">
<code>dispatch</code>
</TooManyArguments>
<InvalidArgument occurrences="1"/>
</file>
<file src="apps/files_sharing/lib/AppInfo/Application.php">
<InvalidArgument occurrences="6">
@ -1130,7 +1149,6 @@
</InvalidArgument>
<InvalidScalarArgument occurrences="1">
<code>$maxUploadFilesize</code>
<code>$maxUploadFilesize</code>
</InvalidScalarArgument>
<NullArgument occurrences="1">
<code>null</code>
@ -1457,7 +1475,6 @@
<file src="apps/user_ldap/lib/Group_LDAP.php">
<InvalidScalarArgument occurrences="1">
<code>$groupID</code>
<code>$groupID</code>
</InvalidScalarArgument>
</file>
<file src="apps/user_ldap/lib/Group_Proxy.php">
@ -1651,7 +1668,8 @@
</UndefinedInterfaceMethod>
</file>
<file src="core/Application.php">
<InvalidArgument occurrences="9">
<InvalidArgument occurrences="10">
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
@ -1749,6 +1767,9 @@
<InvalidScalarArgument occurrences="1">
<code>$levelNum</code>
</InvalidScalarArgument>
<TypeDoesNotContainType occurrences="1">
<code>$identifier === false</code>
</TypeDoesNotContainType>
</file>
<file src="core/Command/Maintenance/DataFingerprint.php">
<InvalidScalarArgument occurrences="1">
@ -3741,6 +3762,12 @@
<code>\Test\Util\User\Dummy</code>
</UndefinedClass>
</file>
<file src="lib/private/legacy/OC_Util.php">
<InvalidOperand occurrences="2">
<code>$version</code>
<code>$version</code>
</InvalidOperand>
</file>
<file src="lib/public/AppFramework/ApiController.php">
<NoInterfaceProperties occurrences="1">
<code>$this-&gt;request-&gt;server</code>

View File

@ -5,6 +5,7 @@
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Julius Härtl <jus@bitgrid.net>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Mario Danic <mario@lovelyhq.com>
@ -42,6 +43,7 @@ use OC\Authentication\Listeners\UserDeletedStoreCleanupListener;
use OC\Authentication\Listeners\UserDeletedTokenCleanupListener;
use OC\Authentication\Listeners\UserDeletedWebAuthnCleanupListener;
use OC\Authentication\Notifications\Notifier as AuthenticationNotifier;
use OC\Core\Listener\BeforeTemplateRenderedListener;
use OC\Core\Notification\CoreNotifier;
use OC\DB\Connection;
use OC\DB\MissingColumnInformation;
@ -51,6 +53,7 @@ use OC\DB\SchemaWrapper;
use OC\Metadata\FileEventListener;
use OC\TagManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\Node\NodeDeletedEvent;
use OCP\Files\Events\Node\NodeWrittenEvent;
@ -310,6 +313,7 @@ class Application extends App {
}
);
$eventDispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class);
$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class);
$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class);

View File

@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
/**
* @copyright 2022 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OC\Core\Listener;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
class BeforeTemplateRenderedListener implements IEventListener {
public function handle(Event $event): void {
if (!($event instanceof BeforeTemplateRenderedEvent)) {
return;
}
if ($event->getResponse()->getRenderAs() === TemplateResponse::RENDER_AS_USER) {
// Making sure to inject just after core
\OCP\Util::addScript('core', 'unsupported-browser-redirect');
}
}
}

View File

@ -36,11 +36,6 @@ import './globals.js'
import './jquery/index.js'
import { initCore } from './init.js'
import { registerAppsSlideToggle } from './OC/apps.js'
import { testSupportedBrowser } from './utils/RedirectUnsupportedBrowsers.js'
if (!window.TESTING && !OC?.config?.no_unsupported_browser_warning) {
testSupportedBrowser()
}
window.addEventListener('DOMContentLoaded', function() {
initCore()

View File

@ -0,0 +1,26 @@
/**
* @copyright 2022 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { testSupportedBrowser } from './utils/RedirectUnsupportedBrowsers.js'
if (!window.TESTING && !OC?.config?.no_unsupported_browser_warning) {
testSupportedBrowser()
}

View File

@ -1,5 +1,5 @@
/**
* @copyright 2021 John Molakvoæ <skjnldsv@protonmail.com>
* @copyright 2022 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*

View File

@ -1,5 +1,5 @@
/**
* @copyright 2021 John Molakvoæ <skjnldsv@protonmail.com>
* @copyright 2022 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
@ -19,8 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { generateUrl } from '@nextcloud/router'
import { supportedBrowsersRegExp } from '../services/BrowsersListService.js'
import browserStorage from '../services/BrowserStorageService.js'
import logger from '../logger.js'
@ -49,6 +47,9 @@ export const testSupportedBrowser = function() {
// If incompatible, NOT overridden AND NOT already on the warning page,
// redirect to the unsupported warning page
if (window.location.pathname.indexOf(redirectPath) === -1) {
window.location = generateUrl(redirectPath)
const redirectUrl = window.location.href.replace(window.location.origin, '')
const base64Param = Buffer.from(redirectUrl).toString('base64')
history.pushState(null, null, `${redirectPath}?redirect_url=${base64Param}`)
window.location.reload()
}
}

View File

@ -1,5 +1,5 @@
<!--
- @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
- @copyright 2022 John Molakvoæ <skjnldsv@protonmail.com>
-
- @author John Molakvoæ <skjnldsv@protonmail.com>
-
@ -136,6 +136,14 @@ export default {
// Set the flag allowing this browser and redirect to home
forceBrowsing() {
browserStorage.setItem(browserStorageKey, true)
// Redirect if there is the data
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.has('redirect_url')) {
const redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/'
window.location = redirectPath
return
}
window.location = generateUrl('/')
},

BIN
dist/core-common.js vendored

Binary file not shown.

Binary file not shown.

BIN
dist/core-main.js vendored

Binary file not shown.

BIN
dist/core-main.js.map vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1016,6 +1016,7 @@ return array(
'OC\\Core\\Events\\PasswordResetEvent' => $baseDir . '/core/Events/PasswordResetEvent.php',
'OC\\Core\\Exception\\LoginFlowV2NotFoundException' => $baseDir . '/core/Exception/LoginFlowV2NotFoundException.php',
'OC\\Core\\Exception\\ResetPasswordException' => $baseDir . '/core/Exception/ResetPasswordException.php',
'OC\\Core\\Listener\\BeforeTemplateRenderedListener' => $baseDir . '/core/Listener/BeforeTemplateRenderedListener.php',
'OC\\Core\\Middleware\\TwoFactorMiddleware' => $baseDir . '/core/Middleware/TwoFactorMiddleware.php',
'OC\\Core\\Migrations\\Version13000Date20170705121758' => $baseDir . '/core/Migrations/Version13000Date20170705121758.php',
'OC\\Core\\Migrations\\Version13000Date20170718121200' => $baseDir . '/core/Migrations/Version13000Date20170718121200.php',

View File

@ -1049,6 +1049,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Core\\Events\\PasswordResetEvent' => __DIR__ . '/../../..' . '/core/Events/PasswordResetEvent.php',
'OC\\Core\\Exception\\LoginFlowV2NotFoundException' => __DIR__ . '/../../..' . '/core/Exception/LoginFlowV2NotFoundException.php',
'OC\\Core\\Exception\\ResetPasswordException' => __DIR__ . '/../../..' . '/core/Exception/ResetPasswordException.php',
'OC\\Core\\Listener\\BeforeTemplateRenderedListener' => __DIR__ . '/../../..' . '/core/Listener/BeforeTemplateRenderedListener.php',
'OC\\Core\\Middleware\\TwoFactorMiddleware' => __DIR__ . '/../../..' . '/core/Middleware/TwoFactorMiddleware.php',
'OC\\Core\\Migrations\\Version13000Date20170705121758' => __DIR__ . '/../../..' . '/core/Migrations/Version13000Date20170705121758.php',
'OC\\Core\\Migrations\\Version13000Date20170718121200' => __DIR__ . '/../../..' . '/core/Migrations/Version13000Date20170718121200.php',

View File

@ -144,11 +144,15 @@ module.exports = {
// We need to provide the path to node_moduels as otherwise npm link will fail due
// to tribute.js checking for jQuery in @nextcloud/vue
jQuery: path.resolve(path.join(__dirname, 'node_modules/jquery')),
// Shim ICAL to prevent using the global object (window.ICAL).
// The library ical.js heavily depends on instanceof checks which will
// break if two separate versions of the library are used (e.g. bundled one
// and global one).
ICAL: 'ical.js',
// https://github.com/webpack/changelog-v5/issues/10
Buffer: ['buffer', 'Buffer'],
}),
],
resolve: {

View File

@ -39,6 +39,7 @@ module.exports = {
systemtags: path.resolve(__dirname, 'core/src', 'systemtags/merged-systemtags.js'),
'unified-search': path.join(__dirname, 'core/src', 'unified-search.js'),
'unsupported-browser': path.join(__dirname, 'core/src', 'unsupported-browser.js'),
'unsupported-browser-redirect': path.join(__dirname, 'core/src', 'unsupported-browser-redirect.js'),
},
dashboard: {
main: path.join(__dirname, 'apps/dashboard/src', 'main.js'),