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 161 additions and 25 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('/')
},

4
dist/core-common.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
dist/core-main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
/*! For license information please see core-unsupported-browser-redirect.js.LICENSE.txt */
!function(){var e,n={25714:function(e,n,r){"use strict";var o,t,i,u=r(81655),l=r(31e3),c=r.n(l),a=r(77727),d=r.n(a),f=(0,u.ZI)({allowHigherVersions:!0,browsers:d()}),s=(c()(d()),(0,r(62556).getBuilder)("core").clearOnLogout().persist().build()),p=r(22200),b=r(17499),h=null===(o=(0,p.getCurrentUser)())?(0,b.IY)().setApp("core").build():(0,b.IY)().setApp("core").setUid(o.uid).build(),v=r(48764).Buffer,w="/unsupported",g="true"===s.getItem("unsupported-browser-ignore");window.TESTING||null!==(t=OC)&&void 0!==t&&null!==(i=t.config)&&void 0!==i&&i.no_unsupported_browser_warning||function(){if(f.test(navigator.userAgent))h.debug("this browser is officially supported ! 🚀");else if(g)h.debug("this browser is NOT supported but has been manually overridden ! ⚠️");else if(-1===window.location.pathname.indexOf(w)){var e=window.location.href.replace(window.location.origin,""),n=v.from(e).toString("base64");history.pushState(null,null,"".concat(w,"?redirect_url=").concat(n)),window.location.reload()}}()},72950:function(){}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={id:e,loaded:!1,exports:{}};return n[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=n,o.amdD=function(){throw new Error("define cannot be used indirect")},o.amdO={},e=[],o.O=function(n,r,t,i){if(!r){var u=1/0;for(d=0;d<e.length;d++){r=e[d][0],t=e[d][1],i=e[d][2];for(var l=!0,c=0;c<r.length;c++)(!1&i||u>=i)&&Object.keys(o.O).every((function(e){return o.O[e](r[c])}))?r.splice(c--,1):(l=!1,i<u&&(u=i));if(l){e.splice(d--,1);var a=t();void 0!==a&&(n=a)}}return n}i=i||0;for(var d=e.length;d>0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[r,t,i]},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,{a:n}),n},o.d=function(e,n){for(var r in n)o.o(n,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},o.j=8876,function(){o.b=document.baseURI||self.location.href;var e={8876:0};o.O.j=function(n){return 0===e[n]};var n=function(n,r){var t,i,u=r[0],l=r[1],c=r[2],a=0;if(u.some((function(n){return 0!==e[n]}))){for(t in l)o.o(l,t)&&(o.m[t]=l[t]);if(c)var d=c(o)}for(n&&n(r);a<u.length;a++)i=u[a],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(d)},r=self.webpackChunknextcloud=self.webpackChunknextcloud||[];r.forEach(n.bind(null,0)),r.push=n.bind(null,r.push.bind(r))}(),o.nc=void 0;var t=o.O(void 0,[7874],(function(){return o(25714)}));t=o.O(t)}();
//# sourceMappingURL=core-unsupported-browser-redirect.js.map?v=e0e9eb378fc9bdf8296c

View File

@ -0,0 +1,20 @@
/**
* @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/>.
*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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>
*

File diff suppressed because one or more lines are too long

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'),