From 463fc45b2a14f36a813d42dc24719da1c6166bf0 Mon Sep 17 00:00:00 2001 From: Fabrice Mouhartem Date: Tue, 9 Apr 2024 15:00:12 +0200 Subject: [PATCH 01/19] #1089: Contextual menu `open` on anonymous drive - Related to https://github.com/cryptpad/cryptpad/issues/1089#issuecomment-2044954222 --- www/common/drive-ui.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 65ded1fb8..0434a7fdd 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1201,7 +1201,8 @@ define([ // falsy (open in preview if default is not using the app) var defaultInApp = ['application/pdf']; var openFile = function (el, isRo, app) { - var data = manager.getFileData(el); + // On anonymous drive, `el` already contains file data + var data = el.channel ? el : manager.getFileData(el); if (data.static) { if (data.href) { From 04395f1bd624779c9c0fa86c575738cae774ee5b Mon Sep 17 00:00:00 2001 From: Fabrice Mouhartem Date: Tue, 9 Apr 2024 15:08:51 +0200 Subject: [PATCH 02/19] maintenance: fix typo in comments (minor) --- www/common/drive-ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 0434a7fdd..8cc1a330d 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1197,7 +1197,7 @@ define([ }); }; - // `app`: true (force open wiht the app), false (force open in preview), + // `app`: true (force open with the app), false (force open in preview), // falsy (open in preview if default is not using the app) var defaultInApp = ['application/pdf']; var openFile = function (el, isRo, app) { From 2540f6ec891891ab1348bf0a6fef7d54a0a97691 Mon Sep 17 00:00:00 2001 From: Fabrice Mouhartem Date: Tue, 9 Apr 2024 15:12:40 +0200 Subject: [PATCH 03/19] =?UTF-8?q?maintenance:=20another=20typo=20in=20the?= =?UTF-8?q?=20comments=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/common/drive-ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 8cc1a330d..7a9d02633 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1201,7 +1201,7 @@ define([ // falsy (open in preview if default is not using the app) var defaultInApp = ['application/pdf']; var openFile = function (el, isRo, app) { - // On anonymous drive, `el` already contains file data + // In anonymous drives, `el` already contains file data var data = el.channel ? el : manager.getFileData(el); if (data.static) { From b61775209875e272fa8398270922e046f3df928a Mon Sep 17 00:00:00 2001 From: Fabrice Mouhartem Date: Thu, 11 Apr 2024 17:26:35 +0200 Subject: [PATCH 04/19] Remove redraw in notification dropdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created square angles on the right side of the notification dropdown when hovering above the dismiss (❌) button - Fix #1465 --- customize.dist/src/less2/include/notifications.less | 9 --------- 1 file changed, 9 deletions(-) diff --git a/customize.dist/src/less2/include/notifications.less b/customize.dist/src/less2/include/notifications.less index a0dab0725..6a69b8beb 100644 --- a/customize.dist/src/less2/include/notifications.less +++ b/customize.dist/src/less2/include/notifications.less @@ -36,9 +36,6 @@ } .cp-reminder, .cp-avatar { cursor: pointer; - &:hover { - background-color: @cp_dropdown-bg-hover; - } } .cp-avatar { .avatar_main(30px); @@ -61,9 +58,6 @@ } &.cp-clickable { cursor: pointer; - &:hover { - background-color: @cp_dropdown-bg-hover; - } } } .cp-notification-dismiss { @@ -73,9 +67,6 @@ align-items: center; justify-content: center; cursor: pointer; - &:hover { - background-color: @cp_dropdown-bg-hover; - } } } } From 623b47f097b3d64cdf84dffd41a03b29568fb459 Mon Sep 17 00:00:00 2001 From: nisbet-hubbard <87453615+nisbet-hubbard@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:24:53 +0800 Subject: [PATCH 05/19] Suport .mjs files content-type --- docs/example.httpd.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/example.httpd.conf b/docs/example.httpd.conf index f98b505f2..67127424c 100644 --- a/docs/example.httpd.conf +++ b/docs/example.httpd.conf @@ -34,6 +34,7 @@ SSLStaplingCache "shmcb:logs/ssl_stapling(32768)" downgrade-1.0 force-response-1.0 Protocols h2 http/1.1 LimitRequestBody 157286400 + AddType application/javascript mjs ProxyPass / http://localhost:3000/ upgrade=websocket ProxyPassReverse / http://localhost:3000/ From 08f859ab0edb3c53863dbda6f3fcc55f8371c2d5 Mon Sep 17 00:00:00 2001 From: daria Date: Wed, 17 Apr 2024 15:09:54 +0300 Subject: [PATCH 06/19] add outline to focused elements on Code/Markdown tools --- customize.dist/src/less2/include/toolbar.less | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index 05111c6b0..7a1690900 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -77,6 +77,12 @@ &:hover { background-color: contrast(@cp_toolbar-bg, darken(@cp_toolbar-bg, 5%), lighten(@cp_toolbar-bg, 5%)); } + &:focus { + outline: @cryptpad_color_brand solid 2px; + } + } + button:nth-of-type(1){ + margin-left: 0.3rem; } } From 78fce869bfa8fbc2d3f8107c7c0b33bdbb6b91b5 Mon Sep 17 00:00:00 2001 From: daria Date: Thu, 25 Apr 2024 13:57:41 +0300 Subject: [PATCH 07/19] add shortcut for getting out of Code editor --- www/common/sframe-common-codemirror.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 1d5943255..2cf288bdd 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -176,6 +176,11 @@ define([ else { editor.execCommand("insertTab"); } } }, + //remove focus from editor + "Shift-Enter": function () { + document.activeElement.blur(); + document.querySelector('[tabindex="0"]').focus(); + }, "Shift-Tab": function () { editor.execCommand("indentLess"); }, From 82daeb98aa76c51eceab987671c7abb623bb738b Mon Sep 17 00:00:00 2001 From: Wolfgang Ginolas Date: Fri, 26 Apr 2024 10:56:20 +0200 Subject: [PATCH 08/19] Fix bug when finding unique OO id https://github.com/cryptpad/cryptpad/issues/1446 --- www/common/onlyoffice/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 1e8537993..e16a9dfc7 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -198,7 +198,7 @@ define([ myOOId = Util.createRandomInteger(); // f: function used in .some(f) but defined outside of the while var f = function (id) { - return ids[id] === myOOId; + return ids[id].ooid === myOOId; }; while (Object.keys(ids).some(f)) { myOOId = Util.createRandomInteger(); From cabe1b879baeaa5ad97879cfdf6a2c377a660288 Mon Sep 17 00:00:00 2001 From: Wolfgang Ginolas Date: Tue, 30 Apr 2024 14:26:01 +0200 Subject: [PATCH 09/19] Make sure indexUser is the same everywhere https://github.com/cryptpad/cryptpad/issues/1446 --- .eslintignore | 1 + www/common/onlyoffice/inner.js | 33 ++++++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.eslintignore b/.eslintignore index 91c021b65..e4b7ea216 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,6 +7,7 @@ www/components/ www/bower_components/ www/common/onlyoffice/dist www/common/onlyoffice/x2t +onlyoffice-dist/ www/scratch www/accounts diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index e16a9dfc7..d3d73abaf 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -179,15 +179,11 @@ define([ }); }; - var getUserIndex = function () { - var i = 1; - var ids = content.ids || {}; - Object.keys(ids).forEach(function (k) { - if (ids[k] && ids[k].index && ids[k].index >= i) { - i = ids[k].index + 1; - } - }); - return i; + const getNewUserIndex = function () { + const ids = content.ids || {}; + const indexes = Object.values(ids).map((user) => user.index); + const maxIndex = Math.max(...indexes); + return maxIndex === -Infinity ? 1 : maxIndex+1; }; var setMyId = function () { @@ -207,7 +203,7 @@ define([ var myId = getId(); ids[myId] = { ooid: myOOId, - index: getUserIndex(), + index: getNewUserIndex(), netflux: metadataMgr.getNetfluxId() }; oldIds = JSON.parse(JSON.stringify(ids)); @@ -912,6 +908,15 @@ define([ }); }; + const findUserByOOId = function(ooId) { + return Object.values(content.ids) + .find((user) => user.ooid === ooId); + }; + + const myOOIndex = function() { + return findUserByOOId(myOOId).index; + }; + var getParticipants = function () { var users = metadataMgr.getMetadata().users; var i = 1; @@ -944,18 +949,19 @@ define([ view: false }); i++; - if (!myUniqueOOId) { myUniqueOOId = String(myOOId) + i; } + if (!myUniqueOOId) { myUniqueOOId = String(myOOId) + myOOIndex(); } + console.log('XXX send userdata to OO', {i, myOOIndex: myOOIndex()}); p.push({ id: myUniqueOOId, idOriginal: String(myOOId), username: metadataMgr.getUserData().name || Messages.anonymous, - indexUser: i, + indexUser: myOOIndex(), connectionId: metadataMgr.getNetfluxId() || Hash.createChannelId(), isCloseCoAuthoring:false, view: false }); return { - index: i, + index: myOOIndex(), list: p.filter(Boolean) }; }; @@ -1136,6 +1142,7 @@ define([ } var type = common.getMetadataMgr().getPrivateData().ooType; var b = obj.block && obj.block[0]; + console.log('XXX new lock', {myUniqueOOId, myOOIndex: myOOIndex()}); var msg = { time: now(), user: myUniqueOOId, From d2adb5d068922f33c364aeffb014251061aebb8b Mon Sep 17 00:00:00 2001 From: Wolfgang Ginolas Date: Thu, 2 May 2024 10:52:29 +0200 Subject: [PATCH 10/19] Use myOOId instead of myUniqueOOId in list of partipicants https://github.com/cryptpad/cryptpad/issues/1446 --- www/common/onlyoffice/inner.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index d3d73abaf..57a7ee314 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -913,7 +913,7 @@ define([ .find((user) => user.ooid === ooId); }; - const myOOIndex = function() { + const getMyOOIndex = function() { return findUserByOOId(myOOId).index; }; @@ -948,20 +948,19 @@ define([ isCloseCoAuthoring:false, view: false }); - i++; - if (!myUniqueOOId) { myUniqueOOId = String(myOOId) + myOOIndex(); } - console.log('XXX send userdata to OO', {i, myOOIndex: myOOIndex()}); + const myOOIndex = getMyOOIndex(); + if (!myUniqueOOId) { myUniqueOOId = String(myOOId) + myOOIndex; } p.push({ - id: myUniqueOOId, + id: String(myOOId), idOriginal: String(myOOId), username: metadataMgr.getUserData().name || Messages.anonymous, - indexUser: myOOIndex(), + indexUser: myOOIndex, connectionId: metadataMgr.getNetfluxId() || Hash.createChannelId(), isCloseCoAuthoring:false, view: false }); return { - index: myOOIndex(), + index: myOOIndex, list: p.filter(Boolean) }; }; @@ -1142,7 +1141,6 @@ define([ } var type = common.getMetadataMgr().getPrivateData().ooType; var b = obj.block && obj.block[0]; - console.log('XXX new lock', {myUniqueOOId, myOOIndex: myOOIndex()}); var msg = { time: now(), user: myUniqueOOId, @@ -2675,7 +2673,6 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null }; var onCheckpoint = function (cp) { // We want to load a checkpoint: - console.log('XXX onCheckpoint', JSON.stringify(cp)); loadCp(cp); }; var setHistoryMode = function (bool) { From 41ef72656ddc858890ce7c0a22e503a6d5acdd70 Mon Sep 17 00:00:00 2001 From: daria Date: Fri, 10 May 2024 13:34:38 +0300 Subject: [PATCH 11/19] change shortcut for getting out of text editors Code/Slides --- www/common/sframe-common-codemirror.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 2cf288bdd..2e84c2d11 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -177,9 +177,9 @@ define([ } }, //remove focus from editor - "Shift-Enter": function () { + "Esc": function () { document.activeElement.blur(); - document.querySelector('[tabindex="0"]').focus(); + document.querySelector('.cp-toolbar-link-logo').focus(); }, "Shift-Tab": function () { editor.execCommand("indentLess"); From 870e14b5bb1fa3a1f10bcd12a042fdac901b82ba Mon Sep 17 00:00:00 2001 From: Wolfgang Ginolas Date: Wed, 15 May 2024 09:45:33 +0200 Subject: [PATCH 12/19] Add null check for missing method --- install-onlyoffice.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install-onlyoffice.sh b/install-onlyoffice.sh index 0beb5317b..84c021d91 100755 --- a/install-onlyoffice.sh +++ b/install-onlyoffice.sh @@ -33,7 +33,7 @@ main () { install_version v4 6ebc6938 install_version v5 88a356f0 install_version v6 abd8a309 - install_version v7 9d8b914a + install_version v7 3506b60c install_x2t v7.3+1 ab0c05b0e4c81071acea83f0c6a8e75f5870c360ec4abc4af09105dd9b52264af9711ec0b7020e87095193ac9b6e20305e446f2321a541f743626a598e5318c1 rm -rf "$BUILDS_DIR" @@ -74,7 +74,7 @@ parse_arguments () { shift ;; esac - done + done } ask_for_license () { From 4483b848ff2ba23176cb05dacf073f3e0581ba7b Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 16 May 2024 16:58:39 +0200 Subject: [PATCH 13/19] Fix http server issue with node >= v20.13.0 --- lib/http-worker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/http-worker.js b/lib/http-worker.js index c46d1b3f7..1937b7ad7 100644 --- a/lib/http-worker.js +++ b/lib/http-worker.js @@ -735,7 +735,8 @@ var server = Http.createServer(app); nThen(function (w) { server.listen(Env.httpPort, Env.httpAddress, w()); if (Env.httpSafePort) { - server.listen(Env.httpSafePort, Env.httpAddress, w()); + let safeServer = Http.createServer(app); + safeServer.listen(Env.httpSafePort, Env.httpAddress, w()); } server.on('upgrade', function (req, socket, head) { // TODO warn admins that websockets should only be proxied in this way in a dev environment From 7f45d598cbf230002863bbd84004c38252b97031 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 16 May 2024 17:19:24 +0200 Subject: [PATCH 14/19] Fix merge issues with package.json --- package.json | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/package.json b/package.json index 715da158a..7212e1465 100644 --- a/package.json +++ b/package.json @@ -13,19 +13,6 @@ }, "dependencies": { "@mcrowe/minibloom": "^0.2.0", - "chainpad-crypto": "^0.2.5", - "chainpad-server": "^5.1.0", - "cookie-parser": "^1.4.6", - "body-parser": "^1.20.2", - "express": "~4.19.2", - "fs-extra": "^7.0.0", - "get-folder-size": "^2.0.1", - "netflux-websocket": "^1.0.0", - "http-proxy-middleware": "^2.0.6", - "jsonwebtoken": "^9.0.0", - "notp": "^2.0.3", - "nthen": "0.1.8", - "openid-client": "^5.4.2", "@node-saml/node-saml": "^4.0.5", "alertify.js": "1.0.11", "body-parser": "^1.20.2", @@ -43,7 +30,7 @@ "croppie": "^2.5.0", "dragula": "3.7.2", "drawio": "github:cryptpad/drawio-npm#npm-21.8.2+5", - "express": "~4.18.2", + "express": "~4.19.2", "file-saver": "1.3.1", "fs-extra": "^7.0.0", "get-folder-size": "^2.0.1", From d41cd3067224951903e69ab2273c489627bca7bd Mon Sep 17 00:00:00 2001 From: Wolfgang Ginolas Date: Fri, 24 May 2024 09:39:39 +0200 Subject: [PATCH 15/19] fix install-onlyoffice.sh --- install-onlyoffice.sh | 242 +++++++++++++++++++++--------------------- 1 file changed, 122 insertions(+), 120 deletions(-) diff --git a/install-onlyoffice.sh b/install-onlyoffice.sh index 84c021d91..7be005895 100755 --- a/install-onlyoffice.sh +++ b/install-onlyoffice.sh @@ -6,7 +6,7 @@ set -euo pipefail -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) CONF_DIR=$SCRIPT_DIR/onlyoffice-conf BUILDS_DIR=$CONF_DIR/onlyoffice-builds.git OO_DIR=$SCRIPT_DIR/www/common/onlyoffice/dist @@ -14,86 +14,89 @@ PROPS_FILE="$CONF_DIR"/onlyoffice.properties declare -A PROPS -main () { - mkdir -p "$CONF_DIR" +main() { + mkdir -p "$CONF_DIR" - load_props + load_props - parse_arguments "$@" + parse_arguments "$@" - ask_for_license + ask_for_license - # Remeber the 1st version that is installed. This will help us install only - # needed OnlyOffice versions in a later version of this script. - set_prop oldest_needed_version v1 + # Remeber the 1st version that is installed. This will help us install only + # needed OnlyOffice versions in a later version of this script. + set_prop oldest_needed_version v1 - mkdir -p "$OO_DIR" - install_version v1 4f370beb - install_version v2b d9da72fd - install_version v4 6ebc6938 - install_version v5 88a356f0 - install_version v6 abd8a309 - install_version v7 3506b60c - install_x2t v7.3+1 ab0c05b0e4c81071acea83f0c6a8e75f5870c360ec4abc4af09105dd9b52264af9711ec0b7020e87095193ac9b6e20305e446f2321a541f743626a598e5318c1 + mkdir -p "$OO_DIR" + install_version v1 4f370beb + install_version v2b d9da72fd + install_version v4 6ebc6938 + install_version v5 88a356f0 + install_version v6 abd8a309 + install_version v7 ba82142f + install_x2t v7.3+1 ab0c05b0e4c81071acea83f0c6a8e75f5870c360ec4abc4af09105dd9b52264af9711ec0b7020e87095193ac9b6e20305e446f2321a541f743626a598e5318c1 - rm -rf "$BUILDS_DIR" - if command -v rdfind &> /dev/null; then - rdfind -makehardlinks true -makeresultsfile false $OO_DIR/v* - fi + rm -rf "$BUILDS_DIR" + if command -v rdfind &>/dev/null; then + rdfind -makehardlinks true -makeresultsfile false $OO_DIR/v* + fi } -load_props () { - if [ -e "$PROPS_FILE" ]; then - while IFS='=' read -r key value; do - PROPS["$key"]="$value" - done < "$PROPS_FILE" - fi +load_props() { + if [ -e "$PROPS_FILE" ]; then + while IFS='=' read -r key value; do + PROPS["$key"]="$value" + done <"$PROPS_FILE" + fi } -set_prop () { - PROPS["$1"]="$2" +set_prop() { + PROPS["$1"]="$2" - for i in "${!PROPS[@]}"; do - echo "$i=${PROPS[$i]}" - done > "$PROPS_FILE" + for i in "${!PROPS[@]}"; do + echo "$i=${PROPS[$i]}" + done >"$PROPS_FILE" } -parse_arguments () { - while [[ $# -gt 0 ]]; do - case $1 in - -h|--help) - show_help - shift - ;; - -a|--accept-license) - ACCEPT_LICENSE="1" - shift - ;; - *) - show_help - shift - ;; - esac - done +parse_arguments() { + while [[ $# -gt 0 ]]; do + case $1 in + -h | --help) + show_help + shift + ;; + -a | --accept-license) + ACCEPT_LICENSE="1" + shift + ;; + *) + show_help + shift + ;; + esac + done } -ask_for_license () { - if [ ${ACCEPT_LICENSE+x} ] || [ "${PROPS[agree_license]:-no}" == yes ]; then - return - fi +ask_for_license() { + if [ ${ACCEPT_LICENSE+x} ] || [ "${PROPS[agree_license]:-no}" == yes ]; then + return + fi - ensure_command_available curl + ensure_command_available curl - (echo -e "Please review the license of OnlyOffice:\n\n" ; curl https://raw.githubusercontent.com/ONLYOFFICE/web-apps/master/LICENSE.txt 2>/dev/null) | less + ( + echo -e "Please review the license of OnlyOffice:\n\n" + curl https://raw.githubusercontent.com/ONLYOFFICE/web-apps/master/LICENSE.txt 2>/dev/null + ) | less - read -rp "Do you accept the license? (Y/N): " confirm \ - && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 + read -rp "Do you accept the license? (Y/N): " confirm && + [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 - set_prop "agree_license" yes + set_prop "agree_license" yes } -show_help () { - cat << EOF +show_help() { + cat < "$FULL_DIR"/.commit + echo "$COMMIT" >"$FULL_DIR"/.commit - echo "$DIR updated" - else - echo "$DIR was up to date" - fi + echo "$DIR updated" + else + echo "$DIR was up to date" + fi - - if [ ${CLEAR+x} ]; then - rm -f "$FULL_DIR"/.git - fi + if [ ${CLEAR+x} ]; then + rm -f "$FULL_DIR"/.git + fi } -install_x2t () { - ensure_command_available curl - ensure_command_available sha512sum - ensure_command_available unzip +install_x2t() { + ensure_command_available curl + ensure_command_available sha512sum + ensure_command_available unzip - local VERSION=$1 - local HASH=$2 - local LAST_DIR - LAST_DIR=$(pwd) - local X2T_DIR=$OO_DIR/x2t + local VERSION=$1 + local HASH=$2 + local LAST_DIR + LAST_DIR=$(pwd) + local X2T_DIR=$OO_DIR/x2t - if [ ! -e "$X2T_DIR"/.version ] || [ "$(cat "$X2T_DIR"/.version)" != "$VERSION" ]; then - rm -rf "$X2T_DIR" - mkdir -p "$X2T_DIR" + if [ ! -e "$X2T_DIR"/.version ] || [ "$(cat "$X2T_DIR"/.version)" != "$VERSION" ]; then + rm -rf "$X2T_DIR" + mkdir -p "$X2T_DIR" - cd "$X2T_DIR" + cd "$X2T_DIR" - curl "https://github.com/cryptpad/onlyoffice-x2t-wasm/releases/download/$VERSION/x2t.zip" --location --output x2t.zip - # curl "https://github.com/cryptpad/onlyoffice-x2t-wasm/releases/download/v7.3%2B1/x2t.zip" --location --output x2t.zip - echo "$HASH x2t.zip" > x2t.zip.sha512 - if ! sha512sum --check x2t.zip.sha512; then - echo "x2t.zip does not match expected checksum" - exit 1 - fi - unzip x2t.zip - rm x2t.zip* + curl "https://github.com/cryptpad/onlyoffice-x2t-wasm/releases/download/$VERSION/x2t.zip" --location --output x2t.zip + # curl "https://github.com/cryptpad/onlyoffice-x2t-wasm/releases/download/v7.3%2B1/x2t.zip" --location --output x2t.zip + echo "$HASH x2t.zip" >x2t.zip.sha512 + if ! sha512sum --check x2t.zip.sha512; then + echo "x2t.zip does not match expected checksum" + exit 1 + fi + unzip x2t.zip + rm x2t.zip* - echo "$VERSION" > "$X2T_DIR"/.version + echo "$VERSION" >"$X2T_DIR"/.version - echo "x2t updated" - else - echo "x2t was up to date" - fi + echo "x2t updated" + else + echo "x2t was up to date" + fi } -ensure_command_available () { - if ! command -v "$1" &> /dev/null; then - echo "$1 needs to be installed to run this script" - exit 1 - fi +ensure_command_available() { + if ! command -v "$1" &>/dev/null; then + echo "$1 needs to be installed to run this script" + exit 1 + fi } main "$@" From 89f7b79eec2f6c14fea8646ead953522fce51c26 Mon Sep 17 00:00:00 2001 From: Wolfgang Ginolas Date: Fri, 31 May 2024 14:20:25 +0200 Subject: [PATCH 16/19] Fix OO images when OnlyOffice was reloaded https://github.com/cryptpad/cryptpad/issues/1500 --- www/common/onlyoffice/inner.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 57a7ee314..5aab870ac 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -1597,13 +1597,15 @@ define([ var x2tConvertData = function (data, fileName, format, cb) { var sframeChan = common.getSframeChannel(); - var e = getEditor(); - var fonts = e && e.FontLoader.fontInfos; - var files = e && e.FontLoader.fontFiles.map(function (f) { + var editor = getEditor(); + var fonts = editor && editor.FontLoader.fontInfos; + var files = editor && editor.FontLoader.fontFiles.map(function (f) { return { 'Id': f.Id, }; }); var type = common.getMetadataMgr().getPrivateData().ooType; - var images = (e && window.frames[0].AscCommon.g_oDocumentUrls.urls) || {}; + const images = editor + ? structuredClone(window.frames[0].AscCommon.g_oDocumentUrls.getUrls()) + : {}; // Fix race condition which could drop images sometimes // ==> make sure each image has a 'media/image_name.ext' entry as well @@ -1614,7 +1616,7 @@ define([ }); // Add theme images - var theme = e && window.frames[0].AscCommon.g_image_loader.map_image_index; + var theme = editor && window.frames[0].AscCommon.g_image_loader.map_image_index; if (theme) { Object.keys(theme).forEach(function (url) { if (!/^(\/|blob:|data:)/.test(url)) { @@ -1628,7 +1630,7 @@ define([ type: type, fileName: fileName, outputFormat: format, - images: (e && window.frames[0].AscCommon.g_oDocumentUrls.urls) || {}, + images: (editor && window.frames[0].AscCommon.g_oDocumentUrls.urls) || {}, fonts: fonts, fonts_files: files, mediasSources: getMediasSources(), @@ -2056,6 +2058,15 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null if (blobUrl) { delete downloadImages[name]; debug("CryptPad Image already loaded " + blobUrl); + + // Fix: https://github.com/cryptpad/cryptpad/issues/1500 + // Maybe OO was reloaded, but the CryptPad cache is still intact? + // -> Add the image to OnlyOffice again. + const documentUrls = window.frames[0].AscCommon.g_oDocumentUrls; + if (!(data.name in documentUrls.getUrls())) { + documentUrls.addImageUrl(data.name, blobUrl); + } + return void callback(blobUrl); } From 5ae741926bfe5ad3e694ceea5634979aac0992d1 Mon Sep 17 00:00:00 2001 From: mathilde-cryptpad <156299270+mathilde-cryptpad@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:58:51 +0200 Subject: [PATCH 17/19] update Nginx examples with the new http2 option --- docs/example-advanced.nginx.conf | 6 ++++-- docs/example.nginx.conf | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/example-advanced.nginx.conf b/docs/example-advanced.nginx.conf index d49d8207f..9902c31bf 100644 --- a/docs/example-advanced.nginx.conf +++ b/docs/example-advanced.nginx.conf @@ -9,11 +9,13 @@ # in production and require professional support please contact sales@cryptpad.fr server { - listen 443 ssl http2; - listen [::]:443 ssl http2; + listen 443 ssl; + listen [::]:443 ssl; + http2 on; # Let's Encrypt webroot include letsencrypt-webroot; + # Include mime.types to be able to support .mjs files (see "types" below) include mime.types; diff --git a/docs/example.nginx.conf b/docs/example.nginx.conf index 8bd4fc3a1..dee2cbbc4 100644 --- a/docs/example.nginx.conf +++ b/docs/example.nginx.conf @@ -9,8 +9,9 @@ # in production and require professional support please contact sales@cryptpad.fr server { - listen 443 ssl http2; - listen [::]:443 ssl http2; + listen 443 ssl; + listen [::]:443 ssl; + http2 on; # Let's Encrypt webroot include letsencrypt-webroot; From 6b430c0b01e3a457278a9d8007ade537b0535d7e Mon Sep 17 00:00:00 2001 From: mathilde-cryptpad <156299270+mathilde-cryptpad@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:10:19 +0200 Subject: [PATCH 18/19] clarify how to use the different ports, see #1212 --- config/config.example.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/config.example.js b/config/config.example.js index d6ebb4a50..986a851d8 100644 --- a/config/config.example.js +++ b/config/config.example.js @@ -91,7 +91,10 @@ module.exports = { /* httpSafePort allows you to specify an alternative port from which * the node process should serve sandboxed assets. The default value is - * that of your httpPort + 1. You probably don't need to change this. + * that of your httpPort + 1. You probably don't need to change this as + * it's only meant to be used in development environements and shouldn't + * be setup on production ones where traffic needs to be directed to the + * main httpPort. * */ //httpSafePort: 3001, From 38694fd463f1a12b3a1e585576a64fb7579fd68f Mon Sep 17 00:00:00 2001 From: mathilde-cryptpad <156299270+mathilde-cryptpad@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:12:00 +0200 Subject: [PATCH 19/19] explain with easier words the purpose of httpSafePort --- config/config.example.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/config/config.example.js b/config/config.example.js index 986a851d8..371640fb7 100644 --- a/config/config.example.js +++ b/config/config.example.js @@ -89,12 +89,10 @@ module.exports = { */ //httpPort: 3000, -/* httpSafePort allows you to specify an alternative port from which - * the node process should serve sandboxed assets. The default value is - * that of your httpPort + 1. You probably don't need to change this as - * it's only meant to be used in development environements and shouldn't - * be setup on production ones where traffic needs to be directed to the - * main httpPort. +/* httpSafePort purpose is to emulate another origin for the sandbox when + * you don't have two domains at hand (i.e. when httpSafeOrigin not defined). + * It is meant to be used only in case where you are working on a local + * development instance. The default value is your httpPort + 1. * */ //httpSafePort: 3001,