Skip to content

Commit 3663c4a

Browse files
authored
Merge pull request #45624 from nextcloud/backport/45494/stable27
2 parents 849587a + 737084e commit 3663c4a

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

core/Controller/UnsupportedBrowserController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public function __construct(IRequest $request) {
4646
public function index(): Response {
4747
Util::addScript('core', 'unsupported-browser');
4848
Util::addStyle('core', 'icons');
49-
return new TemplateResponse('core', 'unsupportedbrowser', [], TemplateResponse::RENDER_AS_ERROR);
49+
50+
// not using RENDER_AS_ERROR as we need the JSConfigHelper for url generation
51+
return new TemplateResponse('core', 'unsupportedbrowser', [], TemplateResponse::RENDER_AS_GUEST);
5052
}
5153
}

core/src/views/UnsupportedBrowser.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
4848
</template>
4949

5050
<script>
51-
import { generateUrl } from '@nextcloud/router'
51+
import { generateUrl, getRootUrl } from '@nextcloud/router'
5252
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
53+
5354
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
5455
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
5556
import Web from 'vue-material-design-icons/Web.vue'
@@ -140,12 +141,22 @@ export default {
140141
// Redirect if there is the data
141142
const urlParams = new URLSearchParams(window.location.search)
142143
if (urlParams.has('redirect_url')) {
143-
const redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/'
144+
let redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/'
145+
146+
// remove index.php and double slashes
147+
redirectPath = redirectPath
148+
.replace('index.php', '')
149+
.replace(getRootUrl(), '')
150+
.replace(/\/\//g, '/')
151+
152+
// if we have a valid redirect url, use it
144153
if (redirectPath.startsWith('/')) {
145154
window.location = generateUrl(redirectPath)
146155
return
147156
}
148157
}
158+
159+
// else redirect to root
149160
window.location = generateUrl('/')
150161
},
151162

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)