mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #5008 from overleaf/jpa-drop-ie11-for-real
[web] redirect IE11 from all the pages to the unsupported browsers page GitOrigin-RevId: 9124ca6feef4e82125d7948543a8bdb1d7702c3b
This commit is contained in:
parent
7919017118
commit
827768be92
3 changed files with 50 additions and 3 deletions
|
@ -6,6 +6,10 @@ const { getSafeRedirectPath } = require('../Features/Helpers/UrlHelper')
|
||||||
function unsupportedBrowserMiddleware(req, res, next) {
|
function unsupportedBrowserMiddleware(req, res, next) {
|
||||||
if (!Settings.unsupportedBrowsers) return next()
|
if (!Settings.unsupportedBrowsers) return next()
|
||||||
|
|
||||||
|
// Prevent redirect loop
|
||||||
|
const path = Url.parse(req.url).pathname
|
||||||
|
if (path === '/unsupported-browser') return next()
|
||||||
|
|
||||||
const userAgent = req.headers['user-agent']
|
const userAgent = req.headers['user-agent']
|
||||||
|
|
||||||
if (!userAgent) return next()
|
if (!userAgent) return next()
|
||||||
|
@ -33,7 +37,8 @@ function renderUnsupportedBrowserPage(req, res) {
|
||||||
let fromURL
|
let fromURL
|
||||||
if (typeof req.query.fromURL === 'string') {
|
if (typeof req.query.fromURL === 'string') {
|
||||||
try {
|
try {
|
||||||
fromURL = Settings.siteUrl + getSafeRedirectPath(req.query.fromURL)
|
fromURL =
|
||||||
|
Settings.siteUrl + (getSafeRedirectPath(req.query.fromURL) || '/')
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
res.render('general/unsupported-browser', { fromURL })
|
res.render('general/unsupported-browser', { fromURL })
|
||||||
|
|
|
@ -62,6 +62,8 @@ const _ = require('underscore')
|
||||||
module.exports = { initialize }
|
module.exports = { initialize }
|
||||||
|
|
||||||
function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
||||||
|
webRouter.use(unsupportedBrowserMiddleware)
|
||||||
|
|
||||||
if (!Settings.allowPublicAccess) {
|
if (!Settings.allowPublicAccess) {
|
||||||
webRouter.all('*', AuthenticationController.requireGlobalLogin)
|
webRouter.all('*', AuthenticationController.requireGlobalLogin)
|
||||||
}
|
}
|
||||||
|
@ -277,7 +279,6 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
||||||
maxRequests: 30,
|
maxRequests: 30,
|
||||||
timeInterval: 60,
|
timeInterval: 60,
|
||||||
}),
|
}),
|
||||||
unsupportedBrowserMiddleware,
|
|
||||||
ProjectController.projectListPage
|
ProjectController.projectListPage
|
||||||
)
|
)
|
||||||
webRouter.post(
|
webRouter.post(
|
||||||
|
@ -299,7 +300,6 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
||||||
maxRequests: 15,
|
maxRequests: 15,
|
||||||
timeInterval: 60,
|
timeInterval: 60,
|
||||||
}),
|
}),
|
||||||
unsupportedBrowserMiddleware,
|
|
||||||
AuthenticationController.validateUserSession(),
|
AuthenticationController.validateUserSession(),
|
||||||
AuthorizationMiddleware.ensureUserCanReadProject,
|
AuthorizationMiddleware.ensureUserCanReadProject,
|
||||||
ProjectController.loadEditor
|
ProjectController.loadEditor
|
||||||
|
|
|
@ -65,6 +65,48 @@ describe('UnsupportedBrowsers', function () {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('redirects unsupported browsers from any page', function (done) {
|
||||||
|
const url = '/foo/bar/baz'
|
||||||
|
this.user.request(
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
headers: {
|
||||||
|
// IE11 user agent
|
||||||
|
'user-agent':
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
(error, response) => {
|
||||||
|
expect(error).to.not.exist
|
||||||
|
expect(response.statusCode).to.equal(302)
|
||||||
|
expect(response.headers.location).to.equal(
|
||||||
|
'/unsupported-browser?fromURL=' + encodeURIComponent(url)
|
||||||
|
)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render the unsupported browser page for unsupported browser', function (done) {
|
||||||
|
const url =
|
||||||
|
'/unsupported-browser?fromURL=' + encodeURIComponent('/foo/bar/baz')
|
||||||
|
this.user.request(
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
headers: {
|
||||||
|
// IE11 user agent
|
||||||
|
'user-agent':
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
(error, response) => {
|
||||||
|
expect(error).to.not.exist
|
||||||
|
expect(response.statusCode).to.equal(200)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it('shows the previous URL', function (done) {
|
it('shows the previous URL', function (done) {
|
||||||
const url = '/project/60867f47174dfd13f1e00000'
|
const url = '/project/60867f47174dfd13f1e00000'
|
||||||
this.user.request(
|
this.user.request(
|
||||||
|
|
Loading…
Reference in a new issue