From a60c1423a70bb9c66f8743f3aee0949cbaf3d731 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 20 Mar 2022 18:59:21 +0100 Subject: [PATCH] ios: attempt to fix cookie related issue server: fail-safe in case client id is not found in http cookies --- CHANGELOG.md | 5 +++++ package.json | 2 +- src/client/index.js | 34 ++++++++++++++++++++++------------ src/server/server.js | 12 ++++++++++++ 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8453ff84..0e2324ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.15.6 + +- bug fixes + - ios: prevent server error related to the use of cookies + ## 1.15.5 - bug fixes diff --git a/package.json b/package.json index 1a0f8cf0..f00408c6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.15.5", + "version": "1.15.6", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" diff --git a/src/client/index.js b/src/client/index.js index 68ef1c18..a2ed6d74 100644 --- a/src/client/index.js +++ b/src/client/index.js @@ -10,27 +10,37 @@ document.addEventListener('DOMContentLoaded', function(event) { var uiLoading = require('./ui/ui-loading') uiLoading(locales('loading_server')) - setTimeout(()=>{ + function init() { - var ipc = require('./ipc/'), - backup = require('./backup') + setTimeout(()=>{ - ipc.init() + var ipc = require('./ipc/'), + backup = require('./backup') + + ipc.init() - require('./ui/init') + require('./ui/init') - document.title = TITLE + document.title = TITLE - ipc.send('open', {hotReload: backup.exists}) + ipc.send('open', {hotReload: backup.exists}) - window.onunload = ()=>{ - ipc.send('close') - } + window.onunload = ()=>{ + ipc.send('close') + } - backup.load() + backup.load() - }, 100) + }, 100) + + } + + if (document.requestStorageAccess) { + document.requestStorageAccess().then(init, init) + } else { + init() + } }) diff --git a/src/server/server.js b/src/server/server.js index 21ae04b7..88ff8c3e 100644 --- a/src/server/server.js +++ b/src/server/server.js @@ -45,6 +45,18 @@ resolveDirs.push(settings.read('remote-root') || '') // remote-root / absolute function resolvePath(url, clientId) { + if (clientId === undefined) { + // safari seems to be picky with cookies + console.error(`(ERROR, HTTP) Could not resolve requested url ${url} (client id not found in http cookies)`) + return false + } + + if (!ipc.clients[clientId]) { + // this should never happen, but just in case... + console.error(`(ERROR, HTTP) Could not resolve requested url ${url} (unregistered client id ${clientId})`) + return false + } + var sessionPath = path.dirname(ipc.clients[clientId].sessionPath) url = resolveHomeDir(url)