Skip to content

Commit c708848

Browse files
authored
Merge pull request #45621 from nextcloud/backport/45494/stable29
2 parents 8f69173 + 4cade9e commit c708848

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

core/Controller/UnsupportedBrowserController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public function __construct(IRequest $request) {
5151
public function index(): Response {
5252
Util::addScript('core', 'unsupported-browser');
5353
Util::addStyle('core', 'icons');
54-
return new TemplateResponse('core', 'unsupportedbrowser', [], TemplateResponse::RENDER_AS_ERROR);
54+
55+
// not using RENDER_AS_ERROR as we need the JSConfigHelper for url generation
56+
return new TemplateResponse('core', 'unsupportedbrowser', [], TemplateResponse::RENDER_AS_GUEST);
5557
}
5658
}

core/src/views/UnsupportedBrowser.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@
4949
</template>
5050

5151
<script>
52-
import { generateUrl } from '@nextcloud/router'
52+
// eslint-disable-next-line n/no-extraneous-import
53+
import { agents } from 'caniuse-lite/dist/unpacker/agents.js'
54+
import { generateUrl, getRootUrl } from '@nextcloud/router'
5355
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
56+
5457
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
5558
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
5659
import Web from 'vue-material-design-icons/Web.vue'
57-
// eslint-disable-next-line n/no-extraneous-import
58-
import { agents } from 'caniuse-lite/dist/unpacker/agents.js'
5960
6061
import { browserStorageKey } from '../utils/RedirectUnsupportedBrowsers.js'
6162
import { supportedBrowsers } from '../services/BrowsersListService.js'
@@ -130,12 +131,22 @@ export default {
130131
// Redirect if there is the data
131132
const urlParams = new URLSearchParams(window.location.search)
132133
if (urlParams.has('redirect_url')) {
133-
const redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/'
134+
let redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/'
135+
136+
// remove index.php and double slashes
137+
redirectPath = redirectPath
138+
.replace('index.php', '')
139+
.replace(getRootUrl(), '')
140+
.replace(/\/\//g, '/')
141+
142+
// if we have a valid redirect url, use it
134143
if (redirectPath.startsWith('/')) {
135144
window.location = generateUrl(redirectPath)
136145
return
137146
}
138147
}
148+
149+
// else redirect to root
139150
window.location = generateUrl('/')
140151
},
141152

dist/core-unsupported-browser.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-unsupported-browser.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)