From 2e75037b4e72c10cc825caa3430aa20bd1b476ab Mon Sep 17 00:00:00 2001 From: rivexe Date: Mon, 13 Feb 2023 14:56:09 +0300 Subject: [PATCH 01/49] php: referenceData --- web/documentserver-example/php/common.php | 18 +++++++ web/documentserver-example/php/doceditor.php | 41 +++++++------- .../php/webeditor-ajax.php | 53 +++++++++++++++++++ 3 files changed, 94 insertions(+), 18 deletions(-) diff --git a/web/documentserver-example/php/common.php b/web/documentserver-example/php/common.php index 66673df7..9f297270 100644 --- a/web/documentserver-example/php/common.php +++ b/web/documentserver-example/php/common.php @@ -624,3 +624,21 @@ function getDocEditorKey($fileName) $key = $key . $stat; // and add it to the document key return generateRevisionId($key); // generate the document key value } + +/** + * Get url to download a file + * + * @param string $fileName + * @param bool $isServer + * + * @return string + */ +function getDownloadUrl($fileName, $isServer = true) +{ + $userAddress = $isServer ? "&userAddress=" . getClientIp() : ""; + return serverPath($isServer) . '/' + . "webeditor-ajax.php" + . "?type=download" + . "&fileName=" . urlencode($fileName) + . $userAddress; +} \ No newline at end of file diff --git a/web/documentserver-example/php/doceditor.php b/web/documentserver-example/php/doceditor.php index c7b67577..373f66d8 100755 --- a/web/documentserver-example/php/doceditor.php +++ b/web/documentserver-example/php/doceditor.php @@ -117,6 +117,13 @@ $config = [ "commentGroups" => $user->commentGroups, "userInfoGroups" => $user->userInfoGroups, ], + "referenceData" => [ + "fileKey" => $user->id != "uid-0" ? json_encode([ + "fileName" => $filename, + "userAddress" => getCurUserHostAddress() + ]) : null, + "instanceId" => serverPath(), + ], ], "editorConfig" => [ "actionLink" => empty($_GET["actionLink"]) ? null : json_decode($_GET["actionLink"]), @@ -283,24 +290,6 @@ function getHistoryDownloadUrl($fileName, $version, $file, $isServer = true) . $userAddress; } -/** - * Get url to download a file - * - * @param string $fileName - * @param bool $isServer - * - * @return string - */ -function getDownloadUrl($fileName, $isServer = true) -{ - $userAddress = $isServer ? "&userAddress=" . getClientIp() : ""; - return serverPath($isServer) . '/' - . "webeditor-ajax.php" - . "?type=download" - . "&fileName=" . urlencode($fileName) - . $userAddress; -} - /** * Get document history * @@ -604,6 +593,21 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl) } }; + var onRequestReferenceData = function(event) { // user refresh external data source + innerAlert("onRequestReferenceData: " + JSON.stringify(event.data)); + + event.data.directUrl = !!config.document.directUrl; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "webeditor-ajax.php?type=reference"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(event.data)); + xhr.onload = function () { + innerAlert(xhr.responseText); + console.log(JSON.parse(xhr.responseText)); + docEditor.setReferenceData(JSON.parse(xhr.responseText)); + } + }; + var сonnectEditor = function () { if (config.editorConfig.createUrl) { diff --git a/web/documentserver-example/php/webeditor-ajax.php b/web/documentserver-example/php/webeditor-ajax.php index be405af8..1b5dd287 100644 --- a/web/documentserver-example/php/webeditor-ajax.php +++ b/web/documentserver-example/php/webeditor-ajax.php @@ -99,6 +99,10 @@ if (isset($_GET["type"]) && !empty($_GET["type"])) { $response_array = csv(); $response_array['status'] = 'success'; die(json_encode($response_array)); + case "reference": + $response_array = reference(); + $response_array['status'] = 'success'; + die(json_encode($response_array)); case "files": $response_array = files(); die(json_encode($response_array)); @@ -570,3 +574,52 @@ function renamefile() return ["result" => $commandRequest]; } + +/** + * Reference data + * + * @return array + */ +function reference() +{ + $post = json_decode(file_get_contents('php://input'), true); + + @header("Content-Type: application/json"); + + $referenceData = $post["referenceData"]; + + if ($referenceData) { + $instanceId = $referenceData["instanceId"]; + if ($instanceId == serverPath()) { + $fileKey = json_decode($referenceData["fileKey"]); + $userAddress = $fileKey->userAddress; + if ($userAddress == getCurUserHostAddress()) { + $fileName = $fileKey->fileName; + } + } + } + + if (!$fileName) { + return ["error" => "File is not found"]; + } + + $data = [ + "fileType" => getInternalExtension($fileName), + "url" => getDownloadUrl($fileName), + "directUrl" => $post["directUrl"] ? getDownloadUrl($fileName) : getDownloadUrl($fileName, false), + "referenceData" => [ + "fileKey" => json_encode([ + "fileName" => $fileName, + "userAddress" => getCurUserHostAddress() + ]), + "instanceId" => serverPath(), + ], + "path" => $fileName + ]; + + if (isJwtEnabled()) { + $data["token"] = jwtEncode($data); + } + + return $data; +} From 69caf5364692e21d5e9c3867e2034709b429d4ae Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 14 Feb 2023 15:20:27 +0300 Subject: [PATCH 02/49] csharp: referenceData --- .../csharp/DocEditor.aspx | 14 +++++ .../csharp/DocEditor.aspx.cs | 11 ++++ .../csharp/WebEditor.ashx.cs | 63 +++++++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/web/documentserver-example/csharp/DocEditor.aspx b/web/documentserver-example/csharp/DocEditor.aspx index eef961ee..7b2394e8 100644 --- a/web/documentserver-example/csharp/DocEditor.aspx +++ b/web/documentserver-example/csharp/DocEditor.aspx @@ -190,6 +190,19 @@ } }; + var onRequestReferenceData = function (event) { // user refresh external data source + + event.data.directUrl = !!config.document.directUrl; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "webeditor.ashx?type=reference"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(event.data)); + xhr.onload = function () { + console.log(xhr.responseText); + docEditor.setReferenceData(JSON.parse(xhr.responseText)); + } + }; + config = <%= DocConfig %>; config.width = "100%"; @@ -242,6 +255,7 @@ }; // prevent file renaming for anonymous users config.events['onRequestRename'] = onRequestRename; + config.events['onRequestReferenceData'] = onRequestReferenceData; } if (config.editorConfig.createUrl) { diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs index cc69832b..8056752e 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -206,6 +206,17 @@ namespace OnlineEditorsExample { "favorite", favorite } } }, + { + "referenceData", new Dictionary() + { + { "fileKey", !user.id.Equals("uid-0") ? + jss.Serialize(new Dictionary{ + {"fileName", FileName}, + {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} + }) : null }, + {"instanceId", _Default.GetServerUrl(false) } + } + }, { // the permission for the document to be edited and downloaded or not "permissions", new Dictionary diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index 415a63bc..59a41b4b 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -71,6 +71,9 @@ namespace OnlineEditorsExample case "rename": Rename(context); break; + case "reference": + Reference(context); + break; } } @@ -409,5 +412,65 @@ namespace OnlineEditorsExample TrackManager.commandRequest("meta", docKey, meta); context.Response.Write("{ \"result\": \"OK\"}"); } + + private static void Reference(HttpContext context) + { + string fileData; + try + { + using (var receiveStream = context.Request.InputStream) + using (var readStream = new StreamReader(receiveStream)) + { + fileData = readStream.ReadToEnd(); + if (string.IsNullOrEmpty(fileData)) return; + } + } + catch (Exception e) + { + throw new HttpException((int)HttpStatusCode.BadRequest, e.Message); + } + + var jss = new JavaScriptSerializer(); + var body = jss.Deserialize>(fileData); + var referenceData = jss.Deserialize > (jss.Serialize(body["referenceData"])); + var instanceId = (string)referenceData["instanceId"]; + var fileKey = (string)referenceData["fileKey"]; + + try + { + var fileKeyObj = jss.Deserialize>(fileKey); + var fileName = (string)fileKeyObj["fileName"]; + var userAddress = (string)fileKeyObj["userAddress"]; + + var data = new Dictionary() { + { "fileType", (Path.GetExtension(fileName) ?? "").ToLower() }, + { "url", DocEditor.getDownloadUrl(fileName)}, + { "directUrl", DocEditor.getDownloadUrl(fileName) }, + { "referenceData", new Dictionary() + { + { "fileKey", jss.Serialize(new Dictionary{ + {"fileName", fileName}, + {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} + }) + }, + {"instanceId", _Default.GetServerUrl(false) } + } + } + }; + + if (JwtManager.Enabled) + { + var token = JwtManager.Encode(data); + data.Add("token", token); + } + + context.Response.Write(jss.Serialize(data).Replace(@"\u0026", "&")); + } + catch (Exception e) + { + context.Response.Write("{ \"error\": \"File not found!\"}"); + } + + } } } \ No newline at end of file From 75046b80c6f56c07e0afe527648cc6233aca5bd5 Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 14 Feb 2023 15:42:36 +0300 Subject: [PATCH 03/49] csharp-mvc: referenceData --- .../csharp-mvc/Models/FileModel.cs | 11 ++++ .../csharp-mvc/Views/Home/Editor.aspx | 13 ++++ .../csharp-mvc/WebEditor.ashx.cs | 63 +++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/web/documentserver-example/csharp-mvc/Models/FileModel.cs b/web/documentserver-example/csharp-mvc/Models/FileModel.cs index a2cd44aa..0c84b7c6 100755 --- a/web/documentserver-example/csharp-mvc/Models/FileModel.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileModel.cs @@ -138,6 +138,17 @@ namespace OnlineEditorsExampleMVC.Models { "favorite", favorite} } }, + { + "referenceData", new Dictionary() + { + { "fileKey", !user.id.Equals("uid-0") ? + jss.Serialize(new Dictionary{ + {"fileName", FileName}, + {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} + }) : null }, + {"instanceId", _Default.GetServerUrl(false) } + } + }, { // the permission for the document to be edited and downloaded or not "permissions", new Dictionary diff --git a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx index faec8ff6..ceb0d857 100644 --- a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx +++ b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx @@ -178,6 +178,18 @@ } }; + var onRequestReferenceData = function (event) { // user refresh external data source + event.data.directUrl = !!config.document.directUrl; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "webeditor.ashx?type=reference"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(event.data)); + xhr.onload = function () { + console.log(xhr.responseText); + docEditor.setReferenceData(JSON.parse(xhr.responseText)); + } + }; + config = <%= Model.GetDocConfig(Request, Url) %>; config.width = "100%"; @@ -239,6 +251,7 @@ }; // prevent file renaming for anonymous users config.events['onRequestRename'] = onRequestRename; + config.events['onRequestReferenceData'] = onRequestReferenceData; } if (config.editorConfig.createUrl) { diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index f0972617..4f0ee891 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -74,6 +74,9 @@ namespace OnlineEditorsExampleMVC case "rename": Rename(context); break; + case "reference": + Reference(context); + break; } } @@ -591,5 +594,65 @@ namespace OnlineEditorsExampleMVC TrackManager.commandRequest("meta", docKey, meta); context.Response.Write("{ \"result\": \"OK\"}"); } + + private static void Reference(HttpContext context) + { + string fileData; + try + { + using (var receiveStream = context.Request.InputStream) + using (var readStream = new StreamReader(receiveStream)) + { + fileData = readStream.ReadToEnd(); + if (string.IsNullOrEmpty(fileData)) return; + } + } + catch (Exception e) + { + throw new HttpException((int)HttpStatusCode.BadRequest, e.Message); + } + + var jss = new JavaScriptSerializer(); + var body = jss.Deserialize>(fileData); + var referenceData = jss.Deserialize > (jss.Serialize(body["referenceData"])); + var instanceId = (string)referenceData["instanceId"]; + var fileKey = (string)referenceData["fileKey"]; + + try + { + var fileKeyObj = jss.Deserialize>(fileKey); + var fileName = (string)fileKeyObj["fileName"]; + var userAddress = (string)fileKeyObj["userAddress"]; + + var data = new Dictionary() { + { "fileType", (Path.GetExtension(fileName) ?? "").ToLower() }, + { "url", DocEditor.getDownloadUrl(fileName)}, + { "directUrl", DocEditor.getDownloadUrl(fileName) }, + { "referenceData", new Dictionary() + { + { "fileKey", jss.Serialize(new Dictionary{ + {"fileName", fileName}, + {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} + }) + }, + {"instanceId", _Default.GetServerUrl(false) } + } + } + }; + + if (JwtManager.Enabled) + { + var token = JwtManager.Encode(data); + data.Add("token", token); + } + + context.Response.Write(jss.Serialize(data).Replace(@"\u0026", "&")); + } + catch (Exception e) + { + context.Response.Write("{ \"error\": \"File not found!\"}"); + } + + } } } \ No newline at end of file From 9213143e145c511bc2af2611b3e9073e4374a7cd Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 15 Feb 2023 14:20:40 +0300 Subject: [PATCH 04/49] chsarp: fix referenceData - path-parameter in ajax-handler added --- web/documentserver-example/csharp/WebEditor.ashx.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index 59a41b4b..221db03d 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -455,7 +455,8 @@ namespace OnlineEditorsExample }, {"instanceId", _Default.GetServerUrl(false) } } - } + }, + { "path", fileName } }; if (JwtManager.Enabled) From 8147608d3bfefc6225363a8bdb4b618eccca0a23 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 15 Feb 2023 14:24:44 +0300 Subject: [PATCH 05/49] csharp-mvc: fix referenceData - path-parameter in ajax-handler added --- web/documentserver-example/csharp-mvc/WebEditor.ashx.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index 4f0ee891..3e924e3b 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -636,7 +636,8 @@ namespace OnlineEditorsExampleMVC }) }, {"instanceId", _Default.GetServerUrl(false) } - } + }, + { "path", fileName } } }; From 97ba0da3c23417e6385419fb47439495abca31b4 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 15 Feb 2023 14:54:12 +0300 Subject: [PATCH 06/49] java: referenceData --- .../main/java/controllers/IndexServlet.java | 45 +++++++++++++++++++ .../src/main/java/entities/FileModel.java | 24 ++++++++++ .../java/src/main/webapp/editor.jsp | 14 ++++++ 3 files changed, 83 insertions(+) diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index b023eb2c..ae018e6c 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -19,6 +19,7 @@ package controllers; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import entities.FileType; import entities.User; import helpers.ConfigManager; @@ -118,6 +119,9 @@ public class IndexServlet extends HttpServlet { case "rename": rename(request, response, writer); break; + case "reference": + reference(request, response, writer); + break; default: break; } @@ -633,6 +637,47 @@ public class IndexServlet extends HttpServlet { } } + // reference data + private static void reference(final HttpServletRequest request, + final HttpServletResponse response, + final PrintWriter writer) { + try { + Scanner scanner = new Scanner(request.getInputStream()); + scanner.useDelimiter("\\A"); + String bodyString = scanner.hasNext() ? scanner.next() : ""; + scanner.close(); + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + + JSONParser parser = new JSONParser(); + JSONObject body = (JSONObject) parser.parse(bodyString); + String instanceId = (String) body.get("instanceId"); + JSONObject fileKey = (JSONObject) body.get("fileKey"); + String fileKeyValue = gson.toJson(fileKey); + + String fileName = (String) fileKey.get("fileName"); + String userAddress = (String) fileKey.get("userAddress"); + + HashMap referenceData = new HashMap<>(); + referenceData.put("instanceId", DocumentManager.getServerUrl(true)); + referenceData.put("fileKey", fileKeyValue); + + HashMap data = new HashMap<>(); + data.put("fileType", FileUtility.getFileExtension(fileName)); + data.put("url", DocumentManager.getDownloadUrl(fileName, true)); + data.put("directUrl", DocumentManager.getDownloadUrl(fileName, true)); + data.put("referenceData", referenceData); + data.put("path", referenceData); + + if (DocumentManager.tokenEnabled()) { + String token = DocumentManager.createToken(data); + data.put("token", token); + } + writer.write(gson.toJson(data)); + } catch (Exception e) { + e.printStackTrace(); + writer.write("{ \"error\" : 1, \"message\" : \"" + e.getMessage() + "\"}"); + } + } // process get request @Override diff --git a/web/documentserver-example/java/src/main/java/entities/FileModel.java b/web/documentserver-example/java/src/main/java/entities/FileModel.java index 4e420d5f..c75d1f67 100755 --- a/web/documentserver-example/java/src/main/java/entities/FileModel.java +++ b/web/documentserver-example/java/src/main/java/entities/FileModel.java @@ -77,6 +77,7 @@ public class FileModel { .lastModified()))); document.setInfo(new Info()); document.getInfo().setFavorite(user.getFavorite()); + document.setReferenceData(new ReferenceData(fileName, DocumentManager.curUserHostAddress(null), user)); String templatesImageUrl = DocumentManager.getTemplateImageUrl(FileUtility.getFileType(fileName)); List> templates = new ArrayList<>(); @@ -302,6 +303,7 @@ public class FileModel { private String key; private Info info; private Permissions permissions; + private ReferenceData referenceData; public String getTitle() { return title; @@ -354,6 +356,13 @@ public class FileModel { public void setPermissions(final Permissions permissionsParam) { this.permissions = permissionsParam; } + + public ReferenceData getReferenceData() { + return referenceData; + } + public void setReferenceData(final ReferenceData referenceDataParam) { + this.referenceData = referenceDataParam; + } } // the permissions parameters @@ -394,6 +403,21 @@ public class FileModel { } } + public class ReferenceData { + private final String instanceId; + private final Map fileKey; + public ReferenceData(final String fileName, final String curUserHostAddress, final User user) { + instanceId = DocumentManager.getServerUrl(true); + Map fileKeyList = new HashMap<>(); + if (!user.getId().equals("uid-0")) { + fileKeyList.put("fileName", fileName); + fileKeyList.put("userAddress", curUserHostAddress); + } else { + fileKeyList = null; + } + fileKey = fileKeyList; + } + } // the Favorite icon state public class Info { private String owner = "Me"; diff --git a/web/documentserver-example/java/src/main/webapp/editor.jsp b/web/documentserver-example/java/src/main/webapp/editor.jsp index 35726ef7..813220c0 100644 --- a/web/documentserver-example/java/src/main/webapp/editor.jsp +++ b/web/documentserver-example/java/src/main/webapp/editor.jsp @@ -161,6 +161,19 @@ } }; + var onRequestReferenceData = function(event) { // user refresh external data source + + event.data.directUrl = !!config.document.directUrl; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "IndexServlet?type=reference"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(event.data)); + xhr.onload = function () { + innerAlert(xhr.responseText); + docEditor.setReferenceData(JSON.parse(xhr.responseText)); + } + }; + config = JSON.parse('<%= FileModel.serialize(Model) %>'); config.width = "100%"; config.height = "100%"; @@ -215,6 +228,7 @@ }; // prevent file renaming for anonymous users config.events['onRequestRename'] = onRequestRename; + config.events['onRequestReferenceData'] = onRequestReferenceData; } if (config.editorConfig.createUrl) { From 43875b06bfda94d5a7b7faac0d620cfb3f3e3b42 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 15 Feb 2023 15:33:07 +0300 Subject: [PATCH 07/49] java-spring: ReferenceData --- .../controllers/FileController.java | 34 +++++++++++++++++++ .../models/filemodel/Document.java | 2 ++ .../models/filemodel/ReferenceData.java | 24 +++++++++++++ .../src/main/resources/templates/editor.html | 13 +++++++ 4 files changed, 73 insertions(+) create mode 100644 web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/ReferenceData.java diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index 502a799a..6597db76 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -19,6 +19,7 @@ package com.onlyoffice.integration.controllers; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; import com.onlyoffice.integration.documentserver.callbacks.CallbackHandler; import com.onlyoffice.integration.documentserver.managers.jwt.JwtManager; import com.onlyoffice.integration.documentserver.storage.FileStorageMutator; @@ -445,4 +446,37 @@ public class FileController { return e.getMessage(); } } + + @PostMapping("/reference") + @ResponseBody + public String reference(@RequestBody final JSONObject body) { + try { + String instanceId = (String) body.get("instanceId"); + JSONObject fileKey = (JSONObject) body.get("fileKey"); + Gson gson = new Gson(); + String fileKeyValue = gson.toJson(fileKey); + + String fileName = (String) fileKey.get("fileName"); + String userAddress = (String) fileKey.get("userAddress"); + HashMap referenceData = new HashMap<>(); + referenceData.put("instanceId", storagePathBuilder.getServerUrl(true)); + referenceData.put("fileKey", fileKeyValue); + + HashMap data = new HashMap<>(); + data.put("fileType", fileUtility.getFileExtension(fileName)); + data.put("url", documentManager.getDownloadUrl(fileName, true)); + data.put("directUrl", documentManager.getDownloadUrl(fileName, true)); + data.put("referenceData", referenceData); + data.put("path", referenceData); + + if (jwtManager.tokenEnabled()) { + String token = jwtManager.createToken(data); + data.put("token", token); + } + return gson.toJson(data); + } catch (Exception e) { + e.printStackTrace(); + return "{ \"error\" : 1, \"message\" : \"" + e.getMessage() + "\"}"; + } + } } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Document.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Document.java index 985b6bc0..45319043 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Document.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Document.java @@ -18,6 +18,7 @@ package com.onlyoffice.integration.documentserver.models.filemodel; +import com.onlyoffice.integration.documentserver.managers.document.DocumentManager; import com.onlyoffice.integration.documentserver.models.configurations.Info; import lombok.Getter; import lombok.Setter; @@ -43,4 +44,5 @@ public class Document { // the parameters pertaining to the document (title, ur as file name when the document is downloaded */ private String url; // the absolute URL where the source viewed or edited document is stored private String directUrl; + private ReferenceData referenceData; } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/ReferenceData.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/ReferenceData.java new file mode 100644 index 00000000..3ecdd749 --- /dev/null +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/ReferenceData.java @@ -0,0 +1,24 @@ +package com.onlyoffice.integration.documentserver.models.filemodel; + +import java.util.HashMap; +import java.util.Map; +import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; +import org.springframework.beans.factory.annotation.Autowired; + +public class ReferenceData { + @Autowired + private FileStoragePathBuilder storagePathBuilder; + private final String instanceId; + private final Map fileKey; + public ReferenceData(final String fileName, final String curUserHostAddress, final User user) { + instanceId = storagePathBuilder.getServerUrl(true); + Map fileKeyList = new HashMap<>(); + if (!user.getId().equals("uid-0")) { + fileKeyList.put("fileName", fileName); + fileKeyList.put("userAddress", curUserHostAddress); + } else { + fileKeyList = null; + } + fileKey = fileKeyList; + } +} diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html index e0802290..7342b281 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html @@ -160,6 +160,18 @@ } }; + var onRequestReferenceData = function(event) { // user refresh external data source + event.data.directUrl = !!config.document.directUrl; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "reference"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(event.data)); + xhr.onload = function () { + innerAlert(xhr.responseText); + docEditor.setReferenceData(JSON.parse(xhr.responseText)); + } + }; + config.width = "100%"; config.height = "100%"; config.events = { @@ -211,6 +223,7 @@ }; // prevent file renaming for anonymous users config.events['onRequestRename'] = onRequestRename; + config.events['onRequestReferenceData'] = onRequestReferenceData; } if (config.editorConfig.createUrl) { From 55734a14589c253702d3fb09857b49276e7c2af1 Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 16 Feb 2023 10:10:23 +0300 Subject: [PATCH 08/49] ruby: referenceData --- .../ruby/app/controllers/home_controller.rb | 39 +++++++++++++++++++ .../ruby/app/models/file_model.rb | 9 +++++ .../ruby/app/views/home/editor.html.erb | 14 +++++++ .../ruby/config/routes.rb | 1 + 4 files changed, 63 insertions(+) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 30d025eb..e7d8dcc5 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -363,4 +363,43 @@ class HomeController < ApplicationController json_data = TrackHelper.command_request("meta", dockey, meta) render plain: '{ "result" : "' + JSON.dump(json_data) + '"}' end + + #ReferenceData + def reference + body = JSON.parse(request.body.read) + referenceData = body["referenceData"] + + if referenceData != nil + instanceId = referenceData["instanceId"] + if instanceId == DocumentHelper.get_server_url(false) + fileKey = JSON.parse(referenceData["fileKey"]) + userAddress = fileKey["userAddress"] + if userAddress == DocumentHelper.cur_user_host_address(nil) + fileName = fileKey["fileName"] + end + end + end + + if !fileName || fileName.eql?("") + render plain: '{ "error": "File not found"}' + return + end + + data = { + :fileType => DocumentHelper.get_internal_extension(fileName), + :url => DocumentHelper.get_download_url(fileName), + :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName) : DocumentHelper.get_download_url(fileName,false), + :referenceData => { + :instanceId => DocumentHelper.get_server_url(false), + :fileKey => fileKey.to_json + }, + :path => fileName + } + + if JwtHelper.is_enabled + data["token"] = JwtHelper.encode(data) + end + + render plain: data.to_json + end end \ No newline at end of file diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 92340a75..24e61d8a 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -105,6 +105,11 @@ class FileModel } ] + fileKey = { + :fileName => @file_name, + :userAddress => DocumentHelper.cur_user_host_address(nil) + } + config = { :type => type(), :documentType => document_type, @@ -133,6 +138,10 @@ class FileModel :reviewGroups => @user.reviewGroups, :commentGroups => @user.commentGroups, :userInfoGroups => @user.userInfoGroups + }, + :referenceData => { + :instanceId => DocumentHelper.get_server_url(false), + :fileKey => !@user.id.eql?("uid-0") ? fileKey.to_json : nil } }, :editorConfig => { diff --git a/web/documentserver-example/ruby/app/views/home/editor.html.erb b/web/documentserver-example/ruby/app/views/home/editor.html.erb index 19cc22e0..ea38e5f1 100755 --- a/web/documentserver-example/ruby/app/views/home/editor.html.erb +++ b/web/documentserver-example/ruby/app/views/home/editor.html.erb @@ -151,6 +151,19 @@ } }; + var onRequestReferenceData = function(event) { // user refresh external data source + + event.data.directUrl = !!config.document.directUrl; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "reference"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(event.data)); + xhr.onload = function () { + innerAlert(xhr.responseText); + docEditor.setReferenceData(JSON.parse(xhr.responseText)); + } + }; + var сonnectEditor = function () { config = <%= raw @file.get_config.to_json %>; @@ -205,6 +218,7 @@ }; // prevent file renaming for anonymous users config.events['onRequestRename'] = onRequestRename; + config.events['onRequestReferenceData'] = onRequestReferenceData; } if (config.editorConfig.createUrl) { diff --git a/web/documentserver-example/ruby/config/routes.rb b/web/documentserver-example/ruby/config/routes.rb index 6d42c1b7..6388fc30 100644 --- a/web/documentserver-example/ruby/config/routes.rb +++ b/web/documentserver-example/ruby/config/routes.rb @@ -14,6 +14,7 @@ Rails.application.routes.draw do match '/files', to: 'home#files', via: 'get' match '/saveas', to: 'home#saveas', via: 'post' match '/rename', to: 'home#rename', via: 'post' + match '/reference', to: 'home#reference', via: 'post' # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". From 1b1d07ebc5bc65fd0c1d7e2282790c8308beecf0 Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 16 Feb 2023 12:19:33 +0300 Subject: [PATCH 09/49] python: referenceData --- web/documentserver-example/python/src/urls.py | 3 +- .../python/src/views/actions.py | 37 +++++++++++++++++++ .../python/templates/editor.html | 16 ++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/python/src/urls.py b/web/documentserver-example/python/src/urls.py index fde0db34..9f757597 100644 --- a/web/documentserver-example/python/src/urls.py +++ b/web/documentserver-example/python/src/urls.py @@ -34,7 +34,8 @@ urlpatterns = [ path('csv', actions.csv), path('files', actions.files), path('saveas', actions.saveAs), - path('rename', actions.rename) + path('rename', actions.rename), + path('reference', actions.reference) ] urlpatterns += staticfiles_urlpatterns() \ No newline at end of file diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 91c83574..2bb0f005 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -245,6 +245,10 @@ def edit(request): 'reviewGroups': user.reviewGroups, 'commentGroups': user.commentGroups, 'userInfoGroups': user.userInfoGroups + }, + 'referenceData' : { + 'instanceId' : docManager.getServerUrl(False, request), + 'fileKey' : json.dumps({'fileName' : filename, 'userAddress': request.META['REMOTE_ADDR']}) if user.id !='uid-0' else None } }, 'editorConfig': { @@ -453,3 +457,36 @@ def downloadhistory(request): response = {} response.setdefault('error', 'File not found') return HttpResponse(json.dumps(response), content_type='application/json', status=404) + +# referenceData +def reference(request): + try: + body = json.loads(request.body) + referenceData = body['referenceData'] + + if referenceData: + instanceId = referenceData['instanceId'] + if instanceId == docManager.getServerUrl(False, request): + fileKey = json.loads(referenceData['fileKey']) + userAddress = fileKey['userAddress'] + if userAddress == request.META['REMOTE_ADDR']: + fileName = fileKey['fileName'] + data = { + 'fileType' : fileUtils.getFileExt(fileName), + 'url' : docManager.getDownloadUrl(fileName, request), + 'directUrl' : docManager.getDownloadUrl(fileName, request) if body["directUrl"] else docManager.getDownloadUrl(fileName, request, False), + 'referenceData' : { + 'instanceId' : docManager.getServerUrl(False, request), + 'fileKey' : json.dumps({'fileName' : fileName, 'userAddress': request.META['REMOTE_ADDR']}) + }, + 'path' : fileName + } + + if (jwtManager.isEnabled()): + data['token'] = jwtManager.encode(data) + + return HttpResponse(json.dumps(data), content_type='application/json') + except Exception: + response = {} + response.setdefault('error', 'File not found') + return HttpResponse(json.dumps(response), content_type='application/json', status=404) diff --git a/web/documentserver-example/python/templates/editor.html b/web/documentserver-example/python/templates/editor.html index 31e5d2eb..64dde07c 100755 --- a/web/documentserver-example/python/templates/editor.html +++ b/web/documentserver-example/python/templates/editor.html @@ -168,6 +168,21 @@ } }; + var onRequestReferenceData = function(event) { // user refresh external data source + innerAlert("onRequestReferenceData: " + JSON.stringify(event.data)); + + event.data.directUrl = !!config.document.directUrl; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "reference"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(event.data)); + xhr.onload = function () { + innerAlert(xhr.responseText); + console.log(JSON.parse(xhr.responseText)); + docEditor.setReferenceData(JSON.parse(xhr.responseText)); + } + }; + var connectEditor = function () { config = {{ cfg | safe }} @@ -223,6 +238,7 @@ }; // prevent file renaming for anonymous users config.events['onRequestRename'] = onRequestRename; + config.events['onRequestReferenceData'] = onRequestReferenceData; } From 42b7c8353e0b10a3432b27adb2f62f1dedb51537 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 17 Feb 2023 09:34:22 +0300 Subject: [PATCH 10/49] php: search for fileName by path added --- web/documentserver-example/php/webeditor-ajax.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/php/webeditor-ajax.php b/web/documentserver-example/php/webeditor-ajax.php index 1b5dd287..e7772968 100644 --- a/web/documentserver-example/php/webeditor-ajax.php +++ b/web/documentserver-example/php/webeditor-ajax.php @@ -599,7 +599,14 @@ function reference() } } - if (!$fileName) { + if (!isset($filename) && isset($post["path"]) && isset($userAddress)) { + $path = basename($post["path"]); + if (file_exists(getStoragePath($path, $userAddress))) { + $fileName = $path; + } + } + + if (!isset($fileName)) { return ["error" => "File is not found"]; } From 7d1c3a994d696170e4fbca83b81269ba30a9a977 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 17 Feb 2023 10:13:43 +0300 Subject: [PATCH 11/49] python: search for fileName by path added --- .../python/src/views/actions.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 2bb0f005..4edc62bc 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -460,9 +460,12 @@ def downloadhistory(request): # referenceData def reference(request): + response = {} try: body = json.loads(request.body) referenceData = body['referenceData'] + fileName = None + userAddress = None if referenceData: instanceId = referenceData['instanceId'] @@ -471,6 +474,20 @@ def reference(request): userAddress = fileKey['userAddress'] if userAddress == request.META['REMOTE_ADDR']: fileName = fileKey['fileName'] + + if fileName is None and userAddress is not None: + try: + path = fileUtils.getFileName(body['path']) + if os.path.exists(docManager.getStoragePath(path,request)): + fileName = path + except KeyError: + response.setdefault('error', 'Path not found') + return HttpResponse(json.dumps(response), content_type='application/json', status=404) + + if fileName is None: + response.setdefault('error', 'File not found') + return HttpResponse(json.dumps(response), content_type='application/json', status=404) + data = { 'fileType' : fileUtils.getFileExt(fileName), 'url' : docManager.getDownloadUrl(fileName, request), @@ -487,6 +504,5 @@ def reference(request): return HttpResponse(json.dumps(data), content_type='application/json') except Exception: - response = {} - response.setdefault('error', 'File not found') + response.setdefault('error', 'Reference data is not correct') return HttpResponse(json.dumps(response), content_type='application/json', status=404) From f76c611033356751e38ae9e59d00cc8ab941c1e6 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 17 Feb 2023 10:40:03 +0300 Subject: [PATCH 12/49] ruby: search for fileName by path added --- .../ruby/app/controllers/home_controller.rb | 77 +++++++++++-------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index e7d8dcc5..82c8d2e5 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -366,40 +366,55 @@ class HomeController < ApplicationController #ReferenceData def reference - body = JSON.parse(request.body.read) - referenceData = body["referenceData"] + begin + body = JSON.parse(request.body.read) + referenceData = body["referenceData"] - if referenceData != nil - instanceId = referenceData["instanceId"] - if instanceId == DocumentHelper.get_server_url(false) - fileKey = JSON.parse(referenceData["fileKey"]) - userAddress = fileKey["userAddress"] - if userAddress == DocumentHelper.cur_user_host_address(nil) - fileName = fileKey["fileName"] + if referenceData != nil + instanceId = referenceData["instanceId"] + if instanceId == DocumentHelper.get_server_url(false) + fileKey = JSON.parse(referenceData["fileKey"]) + userAddress = fileKey["userAddress"] + if userAddress == DocumentHelper.cur_user_host_address(nil) + fileName = fileKey["fileName"] + end end end + + if (!defined?(fileName) && defined?(userAddress)) + begin + path = File.basename(body["path"]) + if File.exists?(DocumentHelper.storage_path(path, nil)) + fileName = path + end + rescue => ex + render plain: '{ "error": "' + ex.message + '"}' + end + end + + if !defined?(fileName) + render plain: '{ "error": "File not found"}' + return + end + + data = { + :fileType => DocumentHelper.get_internal_extension(fileName), + :url => DocumentHelper.get_download_url(fileName), + :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName) : DocumentHelper.get_download_url(fileName,false), + :referenceData => { + :instanceId => DocumentHelper.get_server_url(false), + :fileKey => fileKey.to_json + }, + :path => fileName + } + + if JwtHelper.is_enabled + data["token"] = JwtHelper.encode(data) + end + + render plain: data.to_json + rescue => ex + render plain: '{ "error": "' + ex.message + '"}' end - - if !fileName || fileName.eql?("") - render plain: '{ "error": "File not found"}' - return - end - - data = { - :fileType => DocumentHelper.get_internal_extension(fileName), - :url => DocumentHelper.get_download_url(fileName), - :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName) : DocumentHelper.get_download_url(fileName,false), - :referenceData => { - :instanceId => DocumentHelper.get_server_url(false), - :fileKey => fileKey.to_json - }, - :path => fileName - } - - if JwtHelper.is_enabled - data["token"] = JwtHelper.encode(data) - end - - render plain: data.to_json end end \ No newline at end of file From ee0a167708c178253dd4fc0f806408195950f4e5 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 17 Feb 2023 11:15:33 +0300 Subject: [PATCH 13/49] csharp: search for fileName by path added --- .../csharp/WebEditor.ashx.cs | 72 ++++++++++++------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index 221db03d..9dc5df23 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -26,6 +26,7 @@ using System.Diagnostics; using System.Web.Configuration; using System.Linq; using System.Net; +using System.Net.Sockets; namespace OnlineEditorsExample { @@ -435,43 +436,60 @@ namespace OnlineEditorsExample var referenceData = jss.Deserialize > (jss.Serialize(body["referenceData"])); var instanceId = (string)referenceData["instanceId"]; var fileKey = (string)referenceData["fileKey"]; + var fileName = ""; + var userAddress = ""; - try + if (instanceId == _Default.GetServerUrl(false)) { var fileKeyObj = jss.Deserialize>(fileKey); - var fileName = (string)fileKeyObj["fileName"]; - var userAddress = (string)fileKeyObj["userAddress"]; - - var data = new Dictionary() { - { "fileType", (Path.GetExtension(fileName) ?? "").ToLower() }, - { "url", DocEditor.getDownloadUrl(fileName)}, - { "directUrl", DocEditor.getDownloadUrl(fileName) }, - { "referenceData", new Dictionary() - { - { "fileKey", jss.Serialize(new Dictionary{ - {"fileName", fileName}, - {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} - }) - }, - {"instanceId", _Default.GetServerUrl(false) } - } - }, - { "path", fileName } - }; - - if (JwtManager.Enabled) + userAddress = (string)fileKeyObj["userAddress"]; + if (userAddress == HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))) { - var token = JwtManager.Encode(data); - data.Add("token", token); + fileName = (string)fileKeyObj["fileName"]; } - - context.Response.Write(jss.Serialize(data).Replace(@"\u0026", "&")); } - catch (Exception e) + + if (fileName == "" && userAddress != "") + { + var path = (string)body["path"]; + path = Path.GetFileName(path); + if (File.Exists(_Default.StoragePath(path, userAddress))) + { + fileName = path; + } + } + + if (fileName == "") { context.Response.Write("{ \"error\": \"File not found!\"}"); + return; } + var data = new Dictionary() { + { "fileType", (Path.GetExtension(fileName) ?? "").ToLower() }, + { "url", DocEditor.getDownloadUrl(fileName)}, + { "directUrl", DocEditor.getDownloadUrl(fileName) }, + { "referenceData", new Dictionary() + { + { "fileKey", jss.Serialize(new Dictionary{ + {"fileName", fileName}, + {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} + }) + }, + {"instanceId", _Default.GetServerUrl(false) } + } + }, + { "path", fileName } + }; + + if (JwtManager.Enabled) + { + var token = JwtManager.Encode(data); + data.Add("token", token); + } + + context.Response.Write(jss.Serialize(data).Replace(@"\u0026", "&")); + } } } \ No newline at end of file From c291b1059c8ae3b792646f2f8267edae18475a0f Mon Sep 17 00:00:00 2001 From: Andrei Panov Date: Fri, 17 Feb 2023 11:35:25 +0300 Subject: [PATCH 14/49] nodejs: wopi: fix language --- web/documentserver-example/nodejs/views/wopiAction.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/nodejs/views/wopiAction.ejs b/web/documentserver-example/nodejs/views/wopiAction.ejs index b570409f..86552156 100644 --- a/web/documentserver-example/nodejs/views/wopiAction.ejs +++ b/web/documentserver-example/nodejs/views/wopiAction.ejs @@ -50,7 +50,7 @@ -
+
From 54f501c82b457bb032776281fb8c45a695f96214 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 17 Feb 2023 11:19:42 +0300 Subject: [PATCH 15/49] csharp-mvc: search for fileName by path added --- .../csharp-mvc/WebEditor.ashx.cs | 82 ++++++++++++------- 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index 3e924e3b..28b1f31c 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -614,46 +614,72 @@ namespace OnlineEditorsExampleMVC var jss = new JavaScriptSerializer(); var body = jss.Deserialize>(fileData); - var referenceData = jss.Deserialize > (jss.Serialize(body["referenceData"])); + var referenceData = jss.Deserialize>(jss.Serialize(body["referenceData"])); var instanceId = (string)referenceData["instanceId"]; var fileKey = (string)referenceData["fileKey"]; + var fileName = ""; + var userAddress = ""; - try + if (instanceId == _Default.GetServerUrl(false)) { var fileKeyObj = jss.Deserialize>(fileKey); - var fileName = (string)fileKeyObj["fileName"]; - var userAddress = (string)fileKeyObj["userAddress"]; - - var data = new Dictionary() { - { "fileType", (Path.GetExtension(fileName) ?? "").ToLower() }, - { "url", DocEditor.getDownloadUrl(fileName)}, - { "directUrl", DocEditor.getDownloadUrl(fileName) }, - { "referenceData", new Dictionary() - { - { "fileKey", jss.Serialize(new Dictionary{ - {"fileName", fileName}, - {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} - }) - }, - {"instanceId", _Default.GetServerUrl(false) } - }, - { "path", fileName } - } - }; - - if (JwtManager.Enabled) + userAddress = (string)fileKeyObj["userAddress"]; + if (userAddress == HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))) { - var token = JwtManager.Encode(data); - data.Add("token", token); + fileName = (string)fileKeyObj["fileName"]; } - - context.Response.Write(jss.Serialize(data).Replace(@"\u0026", "&")); } - catch (Exception e) + + if (fileName == "" && userAddress != "") + { + try + { + var path = (string)body["path"]; + path = Path.GetFileName(path); + if (File.Exists(_Default.StoragePath(path, userAddress))) + { + fileName = path; + } + } + catch + { + context.Response.Write("{ \"error\": \"Path not found!\"}"); + return; + } + } + + if (fileName == "") { context.Response.Write("{ \"error\": \"File not found!\"}"); + return; } + var data = new Dictionary() { + { "fileType", (Path.GetExtension(fileName) ?? "").ToLower() }, + { "url", DocEditor.getDownloadUrl(fileName)}, + { "directUrl", DocEditor.getDownloadUrl(fileName) }, + { "referenceData", new Dictionary() + { + { "fileKey", jss.Serialize(new Dictionary{ + {"fileName", fileName}, + {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} + }) + }, + {"instanceId", _Default.GetServerUrl(false) } + } + }, + { "path", fileName } + }; + + if (JwtManager.Enabled) + { + var token = JwtManager.Encode(data); + data.Add("token", token); + } + + context.Response.Write(jss.Serialize(data).Replace(@"\u0026", "&")); } + + } } } \ No newline at end of file From 63b7641c470b0af34c7089eb094875d6f50a64cc Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 17 Feb 2023 11:46:17 +0300 Subject: [PATCH 16/49] csharp: fix - "Path not found" - error handled --- .../csharp/WebEditor.ashx.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index 9dc5df23..4fd063f0 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -451,11 +451,18 @@ namespace OnlineEditorsExample if (fileName == "" && userAddress != "") { - var path = (string)body["path"]; - path = Path.GetFileName(path); - if (File.Exists(_Default.StoragePath(path, userAddress))) + try { - fileName = path; + var path = (string)body["path"]; + path = Path.GetFileName(path); + if (File.Exists(_Default.StoragePath(path, userAddress))) + { + fileName = path; + } + } + catch { + context.Response.Write("{ \"error\": \"Path not found!\"}"); + return; } } From e88c2e9c68019560da961b55c0c0a437b562e15c Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 17 Feb 2023 12:03:42 +0300 Subject: [PATCH 17/49] java: search for fileName by path added + json-data fix --- .../main/java/controllers/IndexServlet.java | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index ae018e6c..fff22938 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -64,7 +64,6 @@ import java.util.Scanner; import static utils.Constants.KILOBYTE_SIZE; - @WebServlet(name = "IndexServlet", urlPatterns = {"/IndexServlet"}) @MultipartConfig public class IndexServlet extends HttpServlet { @@ -650,15 +649,43 @@ public class IndexServlet extends HttpServlet { JSONParser parser = new JSONParser(); JSONObject body = (JSONObject) parser.parse(bodyString); - String instanceId = (String) body.get("instanceId"); - JSONObject fileKey = (JSONObject) body.get("fileKey"); - String fileKeyValue = gson.toJson(fileKey); + JSONObject referenceDataObj = (JSONObject) body.get("referenceData"); + String instanceId = (String) referenceDataObj.get("instanceId"); - String fileName = (String) fileKey.get("fileName"); - String userAddress = (String) fileKey.get("userAddress"); + String fileKeyValue = ""; + String userAddress = ""; + String fileName = ""; + + if (instanceId.equals(DocumentManager.getServerUrl(false))) { + JSONObject fileKey = (JSONObject) referenceDataObj.get("fileKey"); + fileKeyValue = gson.toJson(fileKey); + userAddress = (String) fileKey.get("userAddress"); + if (userAddress.equals(DocumentManager.curUserHostAddress(null))) { + fileName = (String) fileKey.get("fileName"); + } + } + + if (fileName.equals("") && !userAddress.equals("")) { + try { + String path = (String) body.get("path"); + path = FileUtility.getFileName(path); + File f = new File(DocumentManager.storagePath(path, userAddress)); + if (f.exists()) { + fileName = path; + } + } catch (Exception e) { + e.printStackTrace(); + writer.write("{ \"error\" : 1, \"message\" : \"" + e.getMessage() + "\"}"); + } + } + + if (fileName.equals("")) { + writer.write("{ \"error\": \"File not found\"}"); + return; + } HashMap referenceData = new HashMap<>(); - referenceData.put("instanceId", DocumentManager.getServerUrl(true)); + referenceData.put("instanceId", DocumentManager.getServerUrl(false)); referenceData.put("fileKey", fileKeyValue); HashMap data = new HashMap<>(); From e729afdd051de2004a2c9cb84169f5c43c6a961a Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 17 Feb 2023 12:59:09 +0300 Subject: [PATCH 18/49] java-spring: search for fileName by path added + json-data fix --- .../controllers/FileController.java | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index 6597db76..c1e5a0d2 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -20,6 +20,7 @@ package com.onlyoffice.integration.controllers; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.onlyoffice.integration.documentserver.callbacks.CallbackHandler; import com.onlyoffice.integration.documentserver.managers.jwt.JwtManager; import com.onlyoffice.integration.documentserver.storage.FileStorageMutator; @@ -52,8 +53,10 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; +import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.InetAddress; import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @@ -451,13 +454,39 @@ public class FileController { @ResponseBody public String reference(@RequestBody final JSONObject body) { try { - String instanceId = (String) body.get("instanceId"); - JSONObject fileKey = (JSONObject) body.get("fileKey"); - Gson gson = new Gson(); - String fileKeyValue = gson.toJson(fileKey); + JSONObject referenceDataObj = (JSONObject) body.get("referenceData"); + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + String instanceId = (String) referenceDataObj.get("instanceId"); + String fileKeyValue = ""; + String userAddress = ""; + String fileName = ""; + + if (instanceId.equals(storagePathBuilder.getServerUrl(false))) { + JSONObject fileKey = (JSONObject) referenceDataObj.get("fileKey"); + fileKeyValue = gson.toJson(fileKey); + userAddress = (String) fileKey.get("userAddress"); + if (userAddress.equals(InetAddress.getLocalHost().getHostAddress())) { + fileName = (String) fileKey.get("fileName"); + } + } + + if (fileName.equals("") && !userAddress.equals("")) { + try { + String path = (String) body.get("path"); + path = fileUtility.getFileName(path); + File f = new File(storagePathBuilder.getFileLocation(path)); + if (f.exists()) { + fileName = path; + } + } catch (Exception e) { + return "{ \"error\" : 1, \"message\" : \"" + e.getMessage() + "\"}"; + } + } + + if (fileName.equals("")) { + return "{ \"error\": \"File not found\"}"; + } - String fileName = (String) fileKey.get("fileName"); - String userAddress = (String) fileKey.get("userAddress"); HashMap referenceData = new HashMap<>(); referenceData.put("instanceId", storagePathBuilder.getServerUrl(true)); referenceData.put("fileKey", fileKeyValue); From d77be1fcbd4acbe34e2d073c0d1488cbbaf879a6 Mon Sep 17 00:00:00 2001 From: Andrei Panov Date: Fri, 17 Feb 2023 13:26:18 +0300 Subject: [PATCH 19/49] nodejs: wopi: refactor wopi params --- .../nodejs/helpers/wopi/wopiRouting.js | 15 ++++++++++++++- .../nodejs/views/wopiAction.ejs | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/nodejs/helpers/wopi/wopiRouting.js b/web/documentserver-example/nodejs/helpers/wopi/wopiRouting.js index f5603d78..894575f9 100755 --- a/web/documentserver-example/nodejs/helpers/wopi/wopiRouting.js +++ b/web/documentserver-example/nodejs/helpers/wopi/wopiRouting.js @@ -26,6 +26,19 @@ const configServer = config.get('server'); const siteUrl = configServer.get("siteUrl"); // the path to the editors installation const users = require("../users"); +getCustomWopiParams = function (query) { + let tokenParams = ""; + let actionParams = ""; + + const userid = query.userid; // user id + tokenParams += (userid ? "&userid=" + userid : ""); + + const lang = query.lang; // language + actionParams += (lang ? "&ui=" + lang : ""); + + return { "tokenParams": tokenParams, "actionParams": actionParams }; +}; + exports.registerRoutes = function(app) { // define a handler for the default wopi page @@ -115,7 +128,7 @@ exports.registerRoutes = function(app) { actionUrl: utils.getActionUrl(req.docManager.getServerUrl(true), req.docManager.curUserHostAddress(), action, req.params['id']), token: "test", tokenTtl: Date.now() + 1000 * 60 * 60 * 10, - params: req.docManager.getCustomParams(), + params: getCustomWopiParams(req.query), }); } catch (ex) { diff --git a/web/documentserver-example/nodejs/views/wopiAction.ejs b/web/documentserver-example/nodejs/views/wopiAction.ejs index 86552156..00d50a0b 100644 --- a/web/documentserver-example/nodejs/views/wopiAction.ejs +++ b/web/documentserver-example/nodejs/views/wopiAction.ejs @@ -50,8 +50,8 @@ -
- + +
From 20c51ea57789b5a2c1b3831f864f37c732c1e954 Mon Sep 17 00:00:00 2001 From: rivexe Date: Mon, 20 Feb 2023 12:34:35 +0300 Subject: [PATCH 20/49] python: licenses list added --- 3rd-Party.license | 39 ++++ .../python/3rd-Party.license | 37 ++++ .../python/licenses/3rd-Party.license | 37 ++++ .../python/licenses/Django.license | 27 +++ .../python/licenses/PyJWT.license | 21 +++ .../python/licenses/jQuery.BlockUI.license | 9 + .../python/licenses/jQuery.FileUpload.license | 20 ++ .../python/licenses/jQuery.UI.license | 43 +++++ .../licenses/jQuery.iframe-transport.license | 20 ++ .../python/licenses/jQuery.license | 20 ++ .../python/licenses/python-magic.license | 58 ++++++ .../python/licenses/requests.license | 174 ++++++++++++++++++ 12 files changed, 505 insertions(+) create mode 100644 web/documentserver-example/python/3rd-Party.license create mode 100644 web/documentserver-example/python/licenses/3rd-Party.license create mode 100644 web/documentserver-example/python/licenses/Django.license create mode 100644 web/documentserver-example/python/licenses/PyJWT.license create mode 100644 web/documentserver-example/python/licenses/jQuery.BlockUI.license create mode 100644 web/documentserver-example/python/licenses/jQuery.FileUpload.license create mode 100644 web/documentserver-example/python/licenses/jQuery.UI.license create mode 100644 web/documentserver-example/python/licenses/jQuery.iframe-transport.license create mode 100644 web/documentserver-example/python/licenses/jQuery.license create mode 100644 web/documentserver-example/python/licenses/python-magic.license create mode 100644 web/documentserver-example/python/licenses/requests.license diff --git a/3rd-Party.license b/3rd-Party.license index 587c13cf..af7db09e 100644 --- a/3rd-Party.license +++ b/3rd-Party.license @@ -259,6 +259,45 @@ License: BSD-3-Clause License File: PHP_CodeSniffer.license +web/documentserver-example/python + +Django - Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out. (https://github.com/django/django/blob/main/LICENSE) +License: BSD-3-Clause +License File: Django.license + +jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/) +License: MIT +License File: jQuery.license + +jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/) +License: MIT, GPL +License File: jQuery.BlockUI.license + +jQuery.FileUpload - File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads. (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt) +License: MIT +License File: jQuery.FileUpload.license + +jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt) +License: MIT +License File: jQuery.iframe-transport.license + +jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/) +License: MIT +License File: jQuery.UI.license + +PyJWT - A Python implementation of RFC 7519. (https://github.com/jpadilla/pyjwt/blob/master/LICENSE) +License: MIT +License File: PyJWT.license + +python-magic - python-magic is a Python interface to the libmagic file type identification library. (https://github.com/ahupp/python-magic/blob/master/LICENSE) +License: MIT +License File: python-magic.license + +requests - Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs, or to form-encode your PUT & POST data — but nowadays, just use the json method! (https://github.com/psf/requests/blob/main/LICENSE) +License: Apache 2.0 +License File: requests.license + + web/documentserver-example/ruby byebug - Byebug is a Ruby debugger. (https://github.com/deivid-rodriguez/byebug/blob/master/LICENSE) diff --git a/web/documentserver-example/python/3rd-Party.license b/web/documentserver-example/python/3rd-Party.license new file mode 100644 index 00000000..7bc4ff23 --- /dev/null +++ b/web/documentserver-example/python/3rd-Party.license @@ -0,0 +1,37 @@ +ONLYOFFICE Applications example uses code from the following 3rd party projects: + +Django - Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out. (https://github.com/django/django/blob/main/LICENSE) +License: BSD-3-Clause +License File: Django.license + +jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/) +License: MIT +License File: jQuery.license + +jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/) +License: MIT, GPL +License File: jQuery.BlockUI.license + +jQuery.FileUpload - File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads. (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt) +License: MIT +License File: jQuery.FileUpload.license + +jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt) +License: MIT +License File: jQuery.iframe-transport.license + +jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/) +License: MIT +License File: jQuery.UI.license + +PyJWT - A Python implementation of RFC 7519. (https://github.com/jpadilla/pyjwt/blob/master/LICENSE) +License: MIT +License File: PyJWT.license + +python-magic - python-magic is a Python interface to the libmagic file type identification library. (https://github.com/ahupp/python-magic/blob/master/LICENSE) +License: MIT +License File: python-magic.license + +requests - Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs, or to form-encode your PUT & POST data — but nowadays, just use the json method! (https://github.com/psf/requests/blob/main/LICENSE) +License: Apache 2.0 +License File: requests.license diff --git a/web/documentserver-example/python/licenses/3rd-Party.license b/web/documentserver-example/python/licenses/3rd-Party.license new file mode 100644 index 00000000..7bc4ff23 --- /dev/null +++ b/web/documentserver-example/python/licenses/3rd-Party.license @@ -0,0 +1,37 @@ +ONLYOFFICE Applications example uses code from the following 3rd party projects: + +Django - Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out. (https://github.com/django/django/blob/main/LICENSE) +License: BSD-3-Clause +License File: Django.license + +jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/) +License: MIT +License File: jQuery.license + +jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/) +License: MIT, GPL +License File: jQuery.BlockUI.license + +jQuery.FileUpload - File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads. (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt) +License: MIT +License File: jQuery.FileUpload.license + +jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt) +License: MIT +License File: jQuery.iframe-transport.license + +jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/) +License: MIT +License File: jQuery.UI.license + +PyJWT - A Python implementation of RFC 7519. (https://github.com/jpadilla/pyjwt/blob/master/LICENSE) +License: MIT +License File: PyJWT.license + +python-magic - python-magic is a Python interface to the libmagic file type identification library. (https://github.com/ahupp/python-magic/blob/master/LICENSE) +License: MIT +License File: python-magic.license + +requests - Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs, or to form-encode your PUT & POST data — but nowadays, just use the json method! (https://github.com/psf/requests/blob/main/LICENSE) +License: Apache 2.0 +License File: requests.license diff --git a/web/documentserver-example/python/licenses/Django.license b/web/documentserver-example/python/licenses/Django.license new file mode 100644 index 00000000..eac6c9a0 --- /dev/null +++ b/web/documentserver-example/python/licenses/Django.license @@ -0,0 +1,27 @@ +Copyright (c) Django Software Foundation and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of Django nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/web/documentserver-example/python/licenses/PyJWT.license b/web/documentserver-example/python/licenses/PyJWT.license new file mode 100644 index 00000000..5771f1ee --- /dev/null +++ b/web/documentserver-example/python/licenses/PyJWT.license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015-2022 José Padilla + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/web/documentserver-example/python/licenses/jQuery.BlockUI.license b/web/documentserver-example/python/licenses/jQuery.BlockUI.license new file mode 100644 index 00000000..efc544f3 --- /dev/null +++ b/web/documentserver-example/python/licenses/jQuery.BlockUI.license @@ -0,0 +1,9 @@ +Copyright 2007-2013 M. Alsup. + +The BlockUI plugin is dual licensed under the MIT and GPL licenses. + +You may use either license. The MIT license is recommended for most projects because it is simple and easy to understand and it places almost no restrictions on what you can do with the plugin. + +If the GPL suits your project better you are also free to use the plugin under that license. + +You do not have to do anything special to choose one license or the other and you don't have to notify anyone which license you are using. You are free to use the BlockUI plugin in commercial projects as long as the copyright header is left intact. \ No newline at end of file diff --git a/web/documentserver-example/python/licenses/jQuery.FileUpload.license b/web/documentserver-example/python/licenses/jQuery.FileUpload.license new file mode 100644 index 00000000..5dd45bf6 --- /dev/null +++ b/web/documentserver-example/python/licenses/jQuery.FileUpload.license @@ -0,0 +1,20 @@ +MIT License + +Copyright 2010 Sebastian Tschan, https://blueimp.net + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/web/documentserver-example/python/licenses/jQuery.UI.license b/web/documentserver-example/python/licenses/jQuery.UI.license new file mode 100644 index 00000000..a6858323 --- /dev/null +++ b/web/documentserver-example/python/licenses/jQuery.UI.license @@ -0,0 +1,43 @@ +Copyright jQuery Foundation and other contributors, https://jquery.org/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/jquery-ui + +The following license applies to all parts of this software except as +documented below: + +==== + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==== + +Copyright and related rights for sample code are waived via CC0. Sample +code is defined as all source code contained within the demos directory. + +CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +==== + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. \ No newline at end of file diff --git a/web/documentserver-example/python/licenses/jQuery.iframe-transport.license b/web/documentserver-example/python/licenses/jQuery.iframe-transport.license new file mode 100644 index 00000000..5dd45bf6 --- /dev/null +++ b/web/documentserver-example/python/licenses/jQuery.iframe-transport.license @@ -0,0 +1,20 @@ +MIT License + +Copyright 2010 Sebastian Tschan, https://blueimp.net + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/web/documentserver-example/python/licenses/jQuery.license b/web/documentserver-example/python/licenses/jQuery.license new file mode 100644 index 00000000..8ec2b0bc --- /dev/null +++ b/web/documentserver-example/python/licenses/jQuery.license @@ -0,0 +1,20 @@ +Copyright (c) 2009 John Resig, http://jquery.com/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/web/documentserver-example/python/licenses/python-magic.license b/web/documentserver-example/python/licenses/python-magic.license new file mode 100644 index 00000000..81cc4cef --- /dev/null +++ b/web/documentserver-example/python/licenses/python-magic.license @@ -0,0 +1,58 @@ +The MIT License (MIT) + +Copyright (c) 2001-2014 Adam Hupp + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +==== + +Portions of this package (magic/compat.py and test/libmagic_test.py) +are distributed under the following copyright notice: + + +$File: LEGAL.NOTICE,v 1.15 2006/05/03 18:48:33 christos Exp $ +Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995. +Software written by Ian F. Darwin and others; +maintained 1994- Christos Zoulas. + +This software is not subject to any export provision of the United States +Department of Commerce, and may be exported to any country or planet. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice immediately at the beginning of the file, without modification, + this list of conditions, and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. \ No newline at end of file diff --git a/web/documentserver-example/python/licenses/requests.license b/web/documentserver-example/python/licenses/requests.license new file mode 100644 index 00000000..895657b9 --- /dev/null +++ b/web/documentserver-example/python/licenses/requests.license @@ -0,0 +1,174 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. \ No newline at end of file From 8d2cbca12ffdaaa176d93b047786c59e3ac3636a Mon Sep 17 00:00:00 2001 From: rivexe Date: Mon, 20 Feb 2023 16:49:44 +0300 Subject: [PATCH 21/49] php: fix - search for filename by path --- web/documentserver-example/php/webeditor-ajax.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/php/webeditor-ajax.php b/web/documentserver-example/php/webeditor-ajax.php index e7772968..ac396bac 100644 --- a/web/documentserver-example/php/webeditor-ajax.php +++ b/web/documentserver-example/php/webeditor-ajax.php @@ -586,7 +586,7 @@ function reference() @header("Content-Type: application/json"); - $referenceData = $post["referenceData"]; + $referenceData = $post["referenceData"] ?? null; if ($referenceData) { $instanceId = $referenceData["instanceId"]; @@ -599,9 +599,9 @@ function reference() } } - if (!isset($filename) && isset($post["path"]) && isset($userAddress)) { + if (!isset($filename) && isset($post["path"])) { $path = basename($post["path"]); - if (file_exists(getStoragePath($path, $userAddress))) { + if (file_exists(getStoragePath($path))) { $fileName = $path; } } From 9d54ec748ab0be53f9dfff2e404f73f169becd37 Mon Sep 17 00:00:00 2001 From: rivexe Date: Mon, 20 Feb 2023 17:06:56 +0300 Subject: [PATCH 22/49] python: fix - search for filename by path --- .../python/src/views/actions.py | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 4edc62bc..197c2f66 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -461,48 +461,49 @@ def downloadhistory(request): # referenceData def reference(request): response = {} + body = json.loads(request.body) + referenceData = None + fileName = None + userAddress = None + try: - body = json.loads(request.body) referenceData = body['referenceData'] - fileName = None - userAddress = None - - if referenceData: - instanceId = referenceData['instanceId'] - if instanceId == docManager.getServerUrl(False, request): - fileKey = json.loads(referenceData['fileKey']) - userAddress = fileKey['userAddress'] - if userAddress == request.META['REMOTE_ADDR']: - fileName = fileKey['fileName'] - - if fileName is None and userAddress is not None: - try: - path = fileUtils.getFileName(body['path']) - if os.path.exists(docManager.getStoragePath(path,request)): - fileName = path - except KeyError: - response.setdefault('error', 'Path not found') - return HttpResponse(json.dumps(response), content_type='application/json', status=404) - - if fileName is None: - response.setdefault('error', 'File not found') - return HttpResponse(json.dumps(response), content_type='application/json', status=404) - - data = { - 'fileType' : fileUtils.getFileExt(fileName), - 'url' : docManager.getDownloadUrl(fileName, request), - 'directUrl' : docManager.getDownloadUrl(fileName, request) if body["directUrl"] else docManager.getDownloadUrl(fileName, request, False), - 'referenceData' : { - 'instanceId' : docManager.getServerUrl(False, request), - 'fileKey' : json.dumps({'fileName' : fileName, 'userAddress': request.META['REMOTE_ADDR']}) - }, - 'path' : fileName - } - - if (jwtManager.isEnabled()): - data['token'] = jwtManager.encode(data) - - return HttpResponse(json.dumps(data), content_type='application/json') except Exception: - response.setdefault('error', 'Reference data is not correct') + pass + + if referenceData is not None: + instanceId = referenceData['instanceId'] + if instanceId == docManager.getServerUrl(False, request): + fileKey = json.loads(referenceData['fileKey']) + userAddress = fileKey['userAddress'] + if userAddress == request.META['REMOTE_ADDR']: + fileName = fileKey['fileName'] + + if fileName is None: + try: + path = fileUtils.getFileName(body['path']) + if os.path.exists(docManager.getStoragePath(path,request)): + fileName = path + except KeyError: + response.setdefault('error', 'Path not found') + return HttpResponse(json.dumps(response), content_type='application/json', status=404) + + if fileName is None: + response.setdefault('error', 'File not found') return HttpResponse(json.dumps(response), content_type='application/json', status=404) + + data = { + 'fileType' : fileUtils.getFileExt(fileName), + 'url' : docManager.getDownloadUrl(fileName, request), + 'directUrl' : docManager.getDownloadUrl(fileName, request) if body["directUrl"] else docManager.getDownloadUrl(fileName, request, False), + 'referenceData' : { + 'instanceId' : docManager.getServerUrl(False, request), + 'fileKey' : json.dumps({'fileName' : fileName, 'userAddress': request.META['REMOTE_ADDR']}) + }, + 'path' : fileName + } + + if (jwtManager.isEnabled()): + data['token'] = jwtManager.encode(data) + + return HttpResponse(json.dumps(data), content_type='application/json') From d23e139272e059924dfe6abe558c72cddb6c61ce Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 21 Feb 2023 09:29:52 +0300 Subject: [PATCH 23/49] csharp: fix - search for filename by path --- .../csharp/WebEditor.ashx.cs | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index 4fd063f0..1595977f 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -433,34 +433,39 @@ namespace OnlineEditorsExample var jss = new JavaScriptSerializer(); var body = jss.Deserialize>(fileData); - var referenceData = jss.Deserialize > (jss.Serialize(body["referenceData"])); - var instanceId = (string)referenceData["instanceId"]; - var fileKey = (string)referenceData["fileKey"]; + Dictionary referenceData = null; var fileName = ""; var userAddress = ""; - if (instanceId == _Default.GetServerUrl(false)) + if (body.ContainsKey("referenceData")) { - var fileKeyObj = jss.Deserialize>(fileKey); - userAddress = (string)fileKeyObj["userAddress"]; - if (userAddress == HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))) + referenceData = jss.Deserialize>(jss.Serialize(body["referenceData"])); + var instanceId = (string)referenceData["instanceId"]; + var fileKey = (string)referenceData["fileKey"]; + if (instanceId == _Default.GetServerUrl(false)) { - fileName = (string)fileKeyObj["fileName"]; + var fileKeyObj = jss.Deserialize>(fileKey); + userAddress = (string)fileKeyObj["userAddress"]; + if (userAddress == HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))) + { + fileName = (string)fileKeyObj["fileName"]; + } } } - if (fileName == "" && userAddress != "") + if (fileName != "") { try { var path = (string)body["path"]; path = Path.GetFileName(path); - if (File.Exists(_Default.StoragePath(path, userAddress))) + if (File.Exists(_Default.StoragePath(path, null))) { fileName = path; } } - catch { + catch + { context.Response.Write("{ \"error\": \"Path not found!\"}"); return; } @@ -484,7 +489,7 @@ namespace OnlineEditorsExample }) }, {"instanceId", _Default.GetServerUrl(false) } - } + } }, { "path", fileName } }; @@ -496,7 +501,6 @@ namespace OnlineEditorsExample } context.Response.Write(jss.Serialize(data).Replace(@"\u0026", "&")); - } } } \ No newline at end of file From 4f26ff64c6e1675012a3b25999abc14832ac5113 Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 21 Feb 2023 09:31:50 +0300 Subject: [PATCH 24/49] csharp-mvc: fix - search for filename by path --- .../csharp-mvc/WebEditor.ashx.cs | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index 28b1f31c..9e14add4 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -614,29 +614,33 @@ namespace OnlineEditorsExampleMVC var jss = new JavaScriptSerializer(); var body = jss.Deserialize>(fileData); - var referenceData = jss.Deserialize>(jss.Serialize(body["referenceData"])); - var instanceId = (string)referenceData["instanceId"]; - var fileKey = (string)referenceData["fileKey"]; + Dictionary referenceData = null; var fileName = ""; var userAddress = ""; - if (instanceId == _Default.GetServerUrl(false)) + if (body.ContainsKey("referenceData")) { - var fileKeyObj = jss.Deserialize>(fileKey); - userAddress = (string)fileKeyObj["userAddress"]; - if (userAddress == HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))) + referenceData = jss.Deserialize>(jss.Serialize(body["referenceData"])); + var instanceId = (string)referenceData["instanceId"]; + var fileKey = (string)referenceData["fileKey"]; + if (instanceId == _Default.GetServerUrl(false)) { - fileName = (string)fileKeyObj["fileName"]; + var fileKeyObj = jss.Deserialize>(fileKey); + userAddress = (string)fileKeyObj["userAddress"]; + if (userAddress == HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))) + { + fileName = (string)fileKeyObj["fileName"]; + } } } - if (fileName == "" && userAddress != "") + if (fileName != "") { try { var path = (string)body["path"]; path = Path.GetFileName(path); - if (File.Exists(_Default.StoragePath(path, userAddress))) + if (File.Exists(_Default.StoragePath(path, null))) { fileName = path; } From 2b6b48720e2269ffc6e431d58d5a7b50e3a1068f Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 21 Feb 2023 11:56:15 +0500 Subject: [PATCH 25/49] python: apache 2 license --- web/documentserver-example/python/LICENSE | 201 ++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 web/documentserver-example/python/LICENSE diff --git a/web/documentserver-example/python/LICENSE b/web/documentserver-example/python/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/web/documentserver-example/python/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 4eff2e7d89261b46c40c94fba87d9a9f2a928bcc Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 21 Feb 2023 11:49:42 +0300 Subject: [PATCH 26/49] ruby: fix - search for filename by path --- .../ruby/app/controllers/home_controller.rb | 86 +++++++++---------- .../ruby/app/models/file_model.rb | 7 +- 2 files changed, 41 insertions(+), 52 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 82c8d2e5..d40c3970 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -366,55 +366,49 @@ class HomeController < ApplicationController #ReferenceData def reference - begin - body = JSON.parse(request.body.read) + body = JSON.parse(request.body.read) + fileName = "" + + + if body.key?("referenceData") referenceData = body["referenceData"] - - if referenceData != nil - instanceId = referenceData["instanceId"] - if instanceId == DocumentHelper.get_server_url(false) - fileKey = JSON.parse(referenceData["fileKey"]) - userAddress = fileKey["userAddress"] - if userAddress == DocumentHelper.cur_user_host_address(nil) - fileName = fileKey["fileName"] - end + instanceId = referenceData["instanceId"] + if instanceId == DocumentHelper.get_server_url(false) + fileKey = JSON.parse(referenceData["fileKey"]) + userAddress = fileKey["userAddress"] + if userAddress == DocumentHelper.cur_user_host_address(nil) + fileName = fileKey["fileName"] end end - - if (!defined?(fileName) && defined?(userAddress)) - begin - path = File.basename(body["path"]) - if File.exists?(DocumentHelper.storage_path(path, nil)) - fileName = path - end - rescue => ex - render plain: '{ "error": "' + ex.message + '"}' - end - end - - if !defined?(fileName) - render plain: '{ "error": "File not found"}' - return - end - - data = { - :fileType => DocumentHelper.get_internal_extension(fileName), - :url => DocumentHelper.get_download_url(fileName), - :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName) : DocumentHelper.get_download_url(fileName,false), - :referenceData => { - :instanceId => DocumentHelper.get_server_url(false), - :fileKey => fileKey.to_json - }, - :path => fileName - } - - if JwtHelper.is_enabled - data["token"] = JwtHelper.encode(data) - end - - render plain: data.to_json - rescue => ex - render plain: '{ "error": "' + ex.message + '"}' end + + if fileName.empty? and body.key?("path") + path = File.basename(body["path"]) + if File.exist?(DocumentHelper.storage_path(path, nil)) + fileName = path + end + end + + if fileName.empty? + render plain: '{ "error": "File not found"}' + return + end + + data = { + :fileType => DocumentHelper.get_internal_extension(fileName), + :url => DocumentHelper.get_download_url(fileName), + :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName) : DocumentHelper.get_download_url(fileName,false), + :referenceData => { + :instanceId => DocumentHelper.get_server_url(false), + :fileKey => {:fileName => fileName,:userAddress => DocumentHelper.cur_user_host_address(nil)}.to_json + }, + :path => fileName + } + + if JwtHelper.is_enabled + data["token"] = JwtHelper.encode(data) + end + + render plain: data.to_json end end \ No newline at end of file diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 24e61d8a..3671b823 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -105,11 +105,6 @@ class FileModel } ] - fileKey = { - :fileName => @file_name, - :userAddress => DocumentHelper.cur_user_host_address(nil) - } - config = { :type => type(), :documentType => document_type, @@ -141,7 +136,7 @@ class FileModel }, :referenceData => { :instanceId => DocumentHelper.get_server_url(false), - :fileKey => !@user.id.eql?("uid-0") ? fileKey.to_json : nil + :fileKey => !@user.id.eql?("uid-0") ? {:fileName => @file_name,:userAddress => DocumentHelper.cur_user_host_address(nil)}.to_json : nil } }, :editorConfig => { From 21d1fd962fd4d902e31e42993054f0c77e0e3bea Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 21 Feb 2023 14:42:20 +0300 Subject: [PATCH 27/49] java: fix - search for filename by path --- .../main/java/controllers/IndexServlet.java | 44 ++++++++++++------- .../java/src/main/webapp/editor.jsp | 1 - 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index fff22938..422064cc 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -645,31 +645,39 @@ public class IndexServlet extends HttpServlet { scanner.useDelimiter("\\A"); String bodyString = scanner.hasNext() ? scanner.next() : ""; scanner.close(); - Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - - JSONParser parser = new JSONParser(); - JSONObject body = (JSONObject) parser.parse(bodyString); - JSONObject referenceDataObj = (JSONObject) body.get("referenceData"); - String instanceId = (String) referenceDataObj.get("instanceId"); String fileKeyValue = ""; String userAddress = ""; String fileName = ""; + boolean incorrectFileKey = false; - if (instanceId.equals(DocumentManager.getServerUrl(false))) { - JSONObject fileKey = (JSONObject) referenceDataObj.get("fileKey"); - fileKeyValue = gson.toJson(fileKey); - userAddress = (String) fileKey.get("userAddress"); - if (userAddress.equals(DocumentManager.curUserHostAddress(null))) { - fileName = (String) fileKey.get("fileName"); + JSONParser parser = new JSONParser(); + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + JSONObject body = (JSONObject) parser.parse(bodyString); + + if (body.containsKey("referenceData")) { + JSONObject referenceDataObj = (JSONObject) body.get("referenceData"); + String instanceId = (String) referenceDataObj.get("instanceId"); + + if (instanceId.equals(DocumentManager.getServerUrl(false))) { + try { + JSONObject fileKey = (JSONObject) parser.parse((String) referenceDataObj.get("fileKey")); + userAddress = (String) fileKey.get("userAddress"); + + if (userAddress.equals(DocumentManager.curUserHostAddress(null))) { + fileName = (String) fileKey.get("fileName"); + } + } catch (Exception e) { + incorrectFileKey = true; //data from DocEditor can give incorrect fileKey param in java Example + } } } - if (fileName.equals("") && !userAddress.equals("")) { + if (fileName.equals("")) { try { String path = (String) body.get("path"); path = FileUtility.getFileName(path); - File f = new File(DocumentManager.storagePath(path, userAddress)); + File f = new File(DocumentManager.storagePath(path, null)); if (f.exists()) { fileName = path; } @@ -684,16 +692,20 @@ public class IndexServlet extends HttpServlet { return; } + HashMap fileKey = new HashMap<>(); + fileKey.put("fileName", fileName); + fileKey.put("userAddress", DocumentManager.curUserHostAddress(null)); + HashMap referenceData = new HashMap<>(); referenceData.put("instanceId", DocumentManager.getServerUrl(false)); - referenceData.put("fileKey", fileKeyValue); + referenceData.put("fileKey", gson.toJson(fileKey)); HashMap data = new HashMap<>(); data.put("fileType", FileUtility.getFileExtension(fileName)); data.put("url", DocumentManager.getDownloadUrl(fileName, true)); data.put("directUrl", DocumentManager.getDownloadUrl(fileName, true)); data.put("referenceData", referenceData); - data.put("path", referenceData); + data.put("path", fileName); if (DocumentManager.tokenEnabled()) { String token = DocumentManager.createToken(data); diff --git a/web/documentserver-example/java/src/main/webapp/editor.jsp b/web/documentserver-example/java/src/main/webapp/editor.jsp index 813220c0..331f9430 100644 --- a/web/documentserver-example/java/src/main/webapp/editor.jsp +++ b/web/documentserver-example/java/src/main/webapp/editor.jsp @@ -162,7 +162,6 @@ }; var onRequestReferenceData = function(event) { // user refresh external data source - event.data.directUrl = !!config.document.directUrl; let xhr = new XMLHttpRequest(); xhr.open("POST", "IndexServlet?type=reference"); From 61d64e909b237701ab1e445fb11143103158462d Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 22 Feb 2023 12:22:41 +0300 Subject: [PATCH 28/49] java-spring: fix - search for filename by path --- .../controllers/FileController.java | 32 ++++++++++++------- .../models/filemodel/Document.java | 4 ++- .../DefaultDocumentConfigurer.java | 19 +++++++++++ .../wrappers/DefaultDocumentWrapper.java | 2 ++ 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index c1e5a0d2..96a7784c 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -454,23 +454,27 @@ public class FileController { @ResponseBody public String reference(@RequestBody final JSONObject body) { try { - JSONObject referenceDataObj = (JSONObject) body.get("referenceData"); + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - String instanceId = (String) referenceDataObj.get("instanceId"); - String fileKeyValue = ""; + String userAddress = ""; String fileName = ""; - if (instanceId.equals(storagePathBuilder.getServerUrl(false))) { - JSONObject fileKey = (JSONObject) referenceDataObj.get("fileKey"); - fileKeyValue = gson.toJson(fileKey); - userAddress = (String) fileKey.get("userAddress"); - if (userAddress.equals(InetAddress.getLocalHost().getHostAddress())) { - fileName = (String) fileKey.get("fileName"); + if (body.containsKey("referenceData")) { + JSONObject referenceDataObj = (JSONObject) body.get("referenceData"); + String instanceId = (String) referenceDataObj.get("instanceId"); + + if (instanceId.equals(storagePathBuilder.getServerUrl(false))) { + JSONObject fileKey = (JSONObject) referenceDataObj.get("fileKey"); + userAddress = (String) fileKey.get("userAddress"); + if (userAddress.equals(InetAddress.getLocalHost().getHostAddress())) { + fileName = (String) fileKey.get("fileName"); + } } } - if (fileName.equals("") && !userAddress.equals("")) { + + if (fileName.equals("")) { try { String path = (String) body.get("path"); path = fileUtility.getFileName(path); @@ -487,16 +491,20 @@ public class FileController { return "{ \"error\": \"File not found\"}"; } + HashMap fileKey = new HashMap<>(); + fileKey.put("fileName", fileName); + fileKey.put("userAddress", InetAddress.getLocalHost().getHostAddress()); + HashMap referenceData = new HashMap<>(); referenceData.put("instanceId", storagePathBuilder.getServerUrl(true)); - referenceData.put("fileKey", fileKeyValue); + referenceData.put("fileKey", fileKey); HashMap data = new HashMap<>(); data.put("fileType", fileUtility.getFileExtension(fileName)); data.put("url", documentManager.getDownloadUrl(fileName, true)); data.put("directUrl", documentManager.getDownloadUrl(fileName, true)); data.put("referenceData", referenceData); - data.put("path", referenceData); + data.put("path", fileName); if (jwtManager.tokenEnabled()) { String token = jwtManager.createToken(data); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Document.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Document.java index 45319043..b9a3d4de 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Document.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Document.java @@ -26,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import java.util.HashMap; + @Component @Scope("prototype") @Getter @@ -44,5 +46,5 @@ public class Document { // the parameters pertaining to the document (title, ur as file name when the document is downloaded */ private String url; // the absolute URL where the source viewed or edited document is stored private String directUrl; - private ReferenceData referenceData; + private HashMap referenceData; } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultDocumentConfigurer.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultDocumentConfigurer.java index 9f514111..d1203e56 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultDocumentConfigurer.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultDocumentConfigurer.java @@ -18,8 +18,10 @@ package com.onlyoffice.integration.services.configurers.implementations; +import com.google.gson.Gson; import com.onlyoffice.integration.documentserver.models.filemodel.Document; import com.onlyoffice.integration.documentserver.models.filemodel.Permission; +import com.onlyoffice.integration.documentserver.models.filemodel.ReferenceData; import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; import com.onlyoffice.integration.services.configurers.DocumentConfigurer; import com.onlyoffice.integration.services.configurers.wrappers.DefaultDocumentWrapper; @@ -31,6 +33,8 @@ import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; import java.io.File; +import java.net.InetAddress; +import java.util.HashMap; @Service @Primary @@ -52,6 +56,7 @@ public class DefaultDocumentConfigurer implements DocumentConfigurer fileKey = new HashMap<>(); + fileKey.put("fileName", fileName); + try { + fileKey.put("userAddress", InetAddress.getLocalHost().getHostAddress()); + } catch (Exception e) + { + e.printStackTrace(); + } + HashMap referenceData = new HashMap<>(); + referenceData.put("instanceId", storagePathBuilder.getServerUrl(true)); + referenceData.put("fileKey", gson.toJson(fileKey)); + document.setKey(key); // set the key to the document config document.setPermissions(permission); // set the permission parameters to the document config + document.setReferenceData(referenceData); } } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/wrappers/DefaultDocumentWrapper.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/wrappers/DefaultDocumentWrapper.java index 919e5e33..1940a437 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/wrappers/DefaultDocumentWrapper.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/wrappers/DefaultDocumentWrapper.java @@ -19,6 +19,7 @@ package com.onlyoffice.integration.services.configurers.wrappers; import com.onlyoffice.integration.documentserver.models.filemodel.Permission; +import com.onlyoffice.integration.documentserver.models.filemodel.ReferenceData; import lombok.Builder; import lombok.Getter; @@ -29,4 +30,5 @@ public class DefaultDocumentWrapper { private String fileName; private Boolean favorite; private Boolean isEnableDirectUrl; + private ReferenceData referenceData; } From c26a17f29ea36155e6274afec44b50ed2e598ad0 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 22 Feb 2023 14:01:21 +0300 Subject: [PATCH 29/49] php: "protect" permission is added --- web/documentserver-example/php/doceditor.php | 1 + web/documentserver-example/php/users.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/php/doceditor.php b/web/documentserver-example/php/doceditor.php index 0bc006c8..cc0e78d1 100755 --- a/web/documentserver-example/php/doceditor.php +++ b/web/documentserver-example/php/doceditor.php @@ -116,6 +116,7 @@ $config = [ "reviewGroups" => $user->reviewGroups, "commentGroups" => $user->commentGroups, "userInfoGroups" => $user->userInfoGroups, + "protect" => !in_array("protect", $user->deniedPermissions), ], ], "editorConfig" => [ diff --git a/web/documentserver-example/php/users.php b/web/documentserver-example/php/users.php index cc30ddfd..6ee75e99 100644 --- a/web/documentserver-example/php/users.php +++ b/web/documentserver-example/php/users.php @@ -167,7 +167,7 @@ $users = [ [], [], null, - [], + ["protect"], $descr_user_0, false ), From 78752275fdc3829554e1f6e9bb1534a9052b84e9 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 22 Feb 2023 14:20:00 +0300 Subject: [PATCH 30/49] python: "protect" permission is added --- web/documentserver-example/python/src/utils/users.py | 2 +- web/documentserver-example/python/src/views/actions.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index c3ed084b..9da6ed5c 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -98,7 +98,7 @@ USERS = [ False, ["copy", "download", "print"], descr_user_3, False), User('uid-0', None, None, '', None, {}, [], - None, [], descr_user_0, False) + None, ["protect"], descr_user_0, False) ] DEFAULT_USER = USERS[0] diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 83dea9e8..497a12e1 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -244,7 +244,8 @@ def edit(request): 'chat': user.id !='uid-0', 'reviewGroups': user.reviewGroups, 'commentGroups': user.commentGroups, - 'userInfoGroups': user.userInfoGroups + 'userInfoGroups': user.userInfoGroups, + 'protect': 'protect' not in user.deniedPermissions } }, 'editorConfig': { From 055f548056c3fb670d63c26d0604e5d61df30da9 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 22 Feb 2023 14:30:59 +0300 Subject: [PATCH 31/49] ruby: "protect" permission is added --- web/documentserver-example/ruby/app/models/file_model.rb | 3 ++- web/documentserver-example/ruby/app/models/users.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 92340a75..3deee8e8 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -132,7 +132,8 @@ class FileModel :chat => !@user.id.eql?("uid-0"), :reviewGroups => @user.reviewGroups, :commentGroups => @user.commentGroups, - :userInfoGroups => @user.userInfoGroups + :userInfoGroups => @user.userInfoGroups, + :protect => !@user.deniedPermissions.include?("protect") } }, :editorConfig => { diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 49a86851..fa45c779 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -100,7 +100,7 @@ class Users false, ["copy", "download", "print"], @@descr_user_3, false), User.new("uid-0", nil, nil, "", nil, {}, [], - nil, [], @@descr_user_0, false) + nil, ["protect"], @@descr_user_0, false) ] class << self From ea8b0c0fa34895a6b3454b24e4ef9b3fcf866404 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 22 Feb 2023 14:39:27 +0300 Subject: [PATCH 32/49] csharp: "protect" permission is added --- web/documentserver-example/csharp/DocEditor.aspx.cs | 3 ++- web/documentserver-example/csharp/Users.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs index cc69832b..a9091ed7 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -222,7 +222,8 @@ namespace OnlineEditorsExample { "chat", !user.id.Equals("uid-0") }, { "reviewGroups", user.reviewGroups }, { "commentGroups", user.commentGroups }, - { "userInfoGroups", user.userInfoGroups } + { "userInfoGroups", user.userInfoGroups }, + { "protect", !user.deniedPermissions.Contains("protect") } } } } diff --git a/web/documentserver-example/csharp/Users.cs b/web/documentserver-example/csharp/Users.cs index 4116c6eb..bb6a1629 100644 --- a/web/documentserver-example/csharp/Users.cs +++ b/web/documentserver-example/csharp/Users.cs @@ -130,7 +130,7 @@ namespace OnlineEditorsExample new Dictionary(), new List(), null, - new List(), + new List() { "protect" }, descr_user_0, false ) From 586d7767b47f0241bc80d306d12e63cb89278dc5 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 22 Feb 2023 14:42:21 +0300 Subject: [PATCH 33/49] csharp-mvc: "protect" permission is added --- web/documentserver-example/csharp-mvc/Helpers/Users.cs | 2 +- web/documentserver-example/csharp-mvc/Models/FileModel.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/Helpers/Users.cs b/web/documentserver-example/csharp-mvc/Helpers/Users.cs index 8980bc25..cca41b6a 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/Users.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/Users.cs @@ -131,7 +131,7 @@ namespace OnlineEditorsExampleMVC.Helpers new Dictionary(), new List(), null, - new List(), + new List() { "protect" }, descr_user_0, false ) diff --git a/web/documentserver-example/csharp-mvc/Models/FileModel.cs b/web/documentserver-example/csharp-mvc/Models/FileModel.cs index a2cd44aa..e07cdbfe 100755 --- a/web/documentserver-example/csharp-mvc/Models/FileModel.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileModel.cs @@ -154,7 +154,8 @@ namespace OnlineEditorsExampleMVC.Models { "chat", !user.id.Equals("uid-0") }, { "reviewGroups", user.reviewGroups }, { "commentGroups", user.commentGroups }, - { "userInfoGroups", user.userInfoGroups } + { "userInfoGroups", user.userInfoGroups }, + { "protect", !user.deniedPermissions.Contains("protect") } } } } From ebd252f42cb1bb8444b41cb9a56984a5b2acd29b Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 22 Feb 2023 14:53:24 +0300 Subject: [PATCH 34/49] java: "protect" permission is added --- .../java/src/main/java/entities/FileModel.java | 2 ++ .../java/src/main/java/helpers/Users.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/java/src/main/java/entities/FileModel.java b/web/documentserver-example/java/src/main/java/entities/FileModel.java index 4e420d5f..027f1462 100755 --- a/web/documentserver-example/java/src/main/java/entities/FileModel.java +++ b/web/documentserver-example/java/src/main/java/entities/FileModel.java @@ -371,6 +371,7 @@ public class FileModel { private final List reviewGroups; private final CommentGroups commentGroups; private final List userInfoGroups; + private final Boolean protect; //public Gson gson = new Gson(); // defines what can be done with a document @@ -391,6 +392,7 @@ public class FileModel { reviewGroups = user.getReviewGroups(); commentGroups = user.getCommentGroups(); userInfoGroups = user.getUserInfoGroups(); + protect = !user.getDeniedPermissions().contains("protect"); } } diff --git a/web/documentserver-example/java/src/main/java/helpers/Users.java b/web/documentserver-example/java/src/main/java/helpers/Users.java index 83b7c51f..76c42828 100755 --- a/web/documentserver-example/java/src/main/java/helpers/Users.java +++ b/web/documentserver-example/java/src/main/java/helpers/Users.java @@ -90,7 +90,7 @@ public final class Users { descriptionUserThird, false)); add(new User("uid-0", null, null, "", null, new CommentGroups(), new ArrayList(), - null, new ArrayList(), descriptionUserZero, false)); + null, Arrays.asList("protect"), descriptionUserZero, false)); }}; private Users() { } From d3d3121d51ee9b1f0dee2584aa9a932d022afd9b Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 22 Feb 2023 15:27:39 +0300 Subject: [PATCH 35/49] java-spring: "protect" permission is added --- .../java/com/onlyoffice/integration/ExampleData.java | 9 +++++---- .../integration/documentserver/models/enums/Action.java | 3 ++- .../documentserver/models/filemodel/Permission.java | 1 + .../com/onlyoffice/integration/entities/Permission.java | 1 + .../integration/services/PermissionServices.java | 4 +++- .../onlyoffice/integration/services/UserServices.java | 6 ++++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java index c8552146..1241b1de 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java @@ -92,22 +92,23 @@ public class ExampleData { userService.createUser("John Smith", "smith@example.com", descriptionUserFirst, "", List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), - List.of(FilterState.NULL.toString()), null, true); + List.of(FilterState.NULL.toString()), null, true, true); // create user 2 with the specified parameters userService.createUser("Mark Pottato", "pottato@example.com", descriptionUserSecond, "group-2", List.of("", "group-2"), List.of(FilterState.NULL.toString()), - List.of("group-2", ""), List.of("group-2"), List.of("group-2", ""), true, true); + List.of("group-2", ""), List.of("group-2"), List.of("group-2", ""), true, true, + true); // create user 3 with the specified parameters userService.createUser("Hamish Mitchell", "mitchell@example.com", descriptionUserThird, "group-3", List.of("group-2"), List.of("group-2", "group-3"), List.of("group-2"), - new ArrayList<>(), List.of("group-2"), false, true); + new ArrayList<>(), List.of("group-2"), false, true, true); // create user 0 with the specified parameters userService.createUser("Anonymous", null, descriptionUserZero, "", List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), - new ArrayList<>(), null, false); + new ArrayList<>(), null, false, false); } } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/enums/Action.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/enums/Action.java index 72437649..4399a247 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/enums/Action.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/enums/Action.java @@ -27,5 +27,6 @@ public enum Action { comment, chat, fillForms, - blockcontent + blockcontent, + protect } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Permission.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Permission.java index 4c074d31..c6c1fd16 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Permission.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Permission.java @@ -51,4 +51,5 @@ public class Permission extends AbstractModel { // the permission for the docum private CommentGroup commentGroups; // the groups whose comments the user can edit, remove and/or view @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = SerializerFilter.class) private List userInfoGroups; + private Boolean protect = true; } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/entities/Permission.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/entities/Permission.java index 7d535b90..96f3b30a 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/entities/Permission.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/entities/Permission.java @@ -52,4 +52,5 @@ public class Permission extends AbstractEntity { private List commentsRemoveGroups; @ManyToMany private List userInfoGroups; + private Boolean protect = true; } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/PermissionServices.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/PermissionServices.java index b474ab86..e6309867 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/PermissionServices.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/PermissionServices.java @@ -38,7 +38,8 @@ public class PermissionServices { final List commentEditGroups, final List commentRemoveGroups, final List userInfoGroups, - final Boolean chat) { + final Boolean chat, + final Boolean protect) { Permission permission = new Permission(); permission.setReviewGroups(reviewGroups); // define the groups whose changes the user can accept/reject @@ -48,6 +49,7 @@ public class PermissionServices { whose comments the user can remove */ permission.setUserInfoGroups(userInfoGroups); permission.setChat(chat); + permission.setProtect(protect); permissionRepository.save(permission); // save new permissions diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/UserServices.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/UserServices.java index e496cd90..53d0d5f6 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/UserServices.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/UserServices.java @@ -57,7 +57,8 @@ public class UserServices { final List editGroups, final List removeGroups, final List userInfoGroups, final Boolean favoriteDoc, - final Boolean chat) { + final Boolean chat, + final Boolean protect) { User newUser = new User(); newUser.setName(name); // set the user name newUser.setEmail(email); // set the user email @@ -81,7 +82,8 @@ public class UserServices { commentGroupsEdit, commentGroupsRemove, usInfoGroups, - chat); // specify permissions for the current user + chat, + protect); // specify permissions for the current user newUser.setPermissions(permission); userRepository.save(newUser); // save a new user From c2f653bbde7f11fc4b2aeb87246113c5acdb075d Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 22 Feb 2023 16:06:28 +0300 Subject: [PATCH 36/49] nodejs: "protect" permission is added --- web/documentserver-example/nodejs/app.js | 3 ++- web/documentserver-example/nodejs/helpers/users.js | 2 +- web/documentserver-example/nodejs/views/config.ejs | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 3ce5774c..22294f93 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -997,7 +997,8 @@ app.get("/editor", function (req, res) { // define a handler for editing docume plugins: JSON.stringify(plugins), actionData: actionData, fileKey: userid != "uid-0" ? JSON.stringify({ fileName: fileName, userAddress: req.docManager.curUserHostAddress()}) : null, - instanceId: userid != "uid-0" ? req.docManager.getInstanceId() : null + instanceId: userid != "uid-0" ? req.docManager.getInstanceId() : null, + protect: !user.deniedPermissions.includes("protect") }, history: history, historyData: historyData, diff --git a/web/documentserver-example/nodejs/helpers/users.js b/web/documentserver-example/nodejs/helpers/users.js index 60287752..ba4af1d7 100644 --- a/web/documentserver-example/nodejs/helpers/users.js +++ b/web/documentserver-example/nodejs/helpers/users.js @@ -85,7 +85,7 @@ var users = [ false, ["copy", "download", "print"], descr_user_3, false), // other group only new User("uid-0", null, null, null, null, {}, [], - null, [], descr_user_0, false), + null, ["protect"], descr_user_0, false), ]; function User(id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates) { diff --git a/web/documentserver-example/nodejs/views/config.ejs b/web/documentserver-example/nodejs/views/config.ejs index 64fe80bd..52c520b7 100755 --- a/web/documentserver-example/nodejs/views/config.ejs +++ b/web/documentserver-example/nodejs/views/config.ejs @@ -20,7 +20,8 @@ "review": <%- editor.review %>, "reviewGroups": <%- editor.reviewGroups %>, "commentGroups": <%- editor.commentGroups %>, - "userInfoGroups": <%- editor.userInfoGroups %> + "userInfoGroups": <%- editor.userInfoGroups %>, + "protect": <%- editor.protect %> }, "referenceData": { "fileKey": <%- JSON.stringify(editor.fileKey) %>, From 9c7b39bd5a71788aed75df7fd2e3c6648d362a2f Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 23 Feb 2023 17:43:09 +0500 Subject: [PATCH 37/49] protect field to information --- web/documentserver-example/csharp-mvc/Helpers/Users.cs | 1 + web/documentserver-example/csharp/Users.cs | 1 + .../src/main/java/com/onlyoffice/integration/ExampleData.java | 1 + web/documentserver-example/java/src/main/java/helpers/Users.java | 1 + web/documentserver-example/nodejs/helpers/users.js | 1 + web/documentserver-example/php/users.php | 1 + web/documentserver-example/python/src/utils/users.py | 1 + web/documentserver-example/ruby/app/models/users.rb | 1 + 8 files changed, 8 insertions(+) diff --git a/web/documentserver-example/csharp-mvc/Helpers/Users.cs b/web/documentserver-example/csharp-mvc/Helpers/Users.cs index cca41b6a..6960f058 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/Users.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/Users.cs @@ -69,6 +69,7 @@ namespace OnlineEditorsExampleMVC.Helpers "Can’t see anyone’s information", "Can't rename files from the editor", "Can't view chat", + "Can't protect file", "View file without collaboration", }; diff --git a/web/documentserver-example/csharp/Users.cs b/web/documentserver-example/csharp/Users.cs index bb6a1629..1dea57de 100644 --- a/web/documentserver-example/csharp/Users.cs +++ b/web/documentserver-example/csharp/Users.cs @@ -68,6 +68,7 @@ namespace OnlineEditorsExample "Can’t see anyone’s information", "Can't rename files from the editor", "Can't view chat", + "Can't protect file", "View file without collaboration", }; diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java index 1241b1de..6fe3c3ae 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java @@ -45,6 +45,7 @@ public class ExampleData { "Can’t see anyone’s information", "Can't rename files from the editor", "Can't view chat", + "Can't protect file", "View file without collaboration" ); diff --git a/web/documentserver-example/java/src/main/java/helpers/Users.java b/web/documentserver-example/java/src/main/java/helpers/Users.java index 76c42828..c1aa7551 100755 --- a/web/documentserver-example/java/src/main/java/helpers/Users.java +++ b/web/documentserver-example/java/src/main/java/helpers/Users.java @@ -72,6 +72,7 @@ public final class Users { add("Can’t see anyone’s information"); add("Can't rename files from the editor"); add("Can't view chat"); + add("Can't protect file"); add("View file without collaboration"); }}; diff --git a/web/documentserver-example/nodejs/helpers/users.js b/web/documentserver-example/nodejs/helpers/users.js index ba4af1d7..93b4f03d 100644 --- a/web/documentserver-example/nodejs/helpers/users.js +++ b/web/documentserver-example/nodejs/helpers/users.js @@ -61,6 +61,7 @@ var descr_user_0 = [ "Can’t see anyone’s information", "Can't rename files from the editor", "Can't view chat", + "Can't protect file", "View file without collaboration", //"Can’t submit forms" ]; diff --git a/web/documentserver-example/php/users.php b/web/documentserver-example/php/users.php index 6ee75e99..b6c0b754 100644 --- a/web/documentserver-example/php/users.php +++ b/web/documentserver-example/php/users.php @@ -107,6 +107,7 @@ $descr_user_0 = [ "Can’t see anyone’s information", "Can't rename files from the editor", "Can't view chat", + "Can't protect file", "View file without collaboration", ]; diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index 9da6ed5c..4c2ca76a 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -74,6 +74,7 @@ descr_user_0 = [ "Can’t see anyone’s information", "Can't rename files from the editor", "Can't view chat", + "Can't protect file", "View file without collaboration", ] diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index fa45c779..a6acbc46 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -75,6 +75,7 @@ class Users "Can’t see anyone’s information", "Can't rename files from the editor", "Can't view chat", + "Can't protect file", "View file without collaboration" ]; From 49953199d44ecbb803573c2165fa6c00385d5a80 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 23 Feb 2023 17:44:11 +0500 Subject: [PATCH 38/49] protect to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fdd4060..be701972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- anonymous can't protect file - separate setting for checking the token in requests - php: linter refactoring From 82bc0e649675d4630e4d99b22743f01fe9696c09 Mon Sep 17 00:00:00 2001 From: rivexe Date: Mon, 27 Feb 2023 09:25:32 +0300 Subject: [PATCH 39/49] csharp: unnecessary replace of symbols deleted. --- web/documentserver-example/csharp/WebEditor.ashx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index 1595977f..da955086 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -500,7 +500,7 @@ namespace OnlineEditorsExample data.Add("token", token); } - context.Response.Write(jss.Serialize(data).Replace(@"\u0026", "&")); + context.Response.Write(jss.Serialize(data)); } } } \ No newline at end of file From 060f28e404191fd4b6c412a3d7338ef1c39ac8d8 Mon Sep 17 00:00:00 2001 From: rivexe Date: Mon, 27 Feb 2023 09:30:44 +0300 Subject: [PATCH 40/49] csharp-mvc: unnecessary replace of symbols deleted --- web/documentserver-example/csharp-mvc/WebEditor.ashx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index 9e14add4..4c9c613f 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -681,7 +681,7 @@ namespace OnlineEditorsExampleMVC data.Add("token", token); } - context.Response.Write(jss.Serialize(data).Replace(@"\u0026", "&")); + context.Response.Write(jss.Serialize(data)); } } From 4fa2049adc2905d9b98ed25590e44e0e16edbe2b Mon Sep 17 00:00:00 2001 From: rivexe Date: Mon, 27 Feb 2023 10:08:47 +0300 Subject: [PATCH 41/49] csharp-mvc: names of helpers fixed + check of empty filename-string (logical error fixed) --- .../csharp-mvc/Models/FileModel.cs | 4 ++-- .../csharp-mvc/WebEditor.ashx.cs | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/Models/FileModel.cs b/web/documentserver-example/csharp-mvc/Models/FileModel.cs index 0c84b7c6..65791c0d 100755 --- a/web/documentserver-example/csharp-mvc/Models/FileModel.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileModel.cs @@ -144,9 +144,9 @@ namespace OnlineEditorsExampleMVC.Models { "fileKey", !user.id.Equals("uid-0") ? jss.Serialize(new Dictionary{ {"fileName", FileName}, - {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} + {"userAddress", HttpUtility.UrlEncode(DocManagerHelper.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} }) : null }, - {"instanceId", _Default.GetServerUrl(false) } + {"instanceId", DocManagerHelper.GetServerUrl(false) } } }, { diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index 4c9c613f..b5f7137b 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -623,24 +623,24 @@ namespace OnlineEditorsExampleMVC referenceData = jss.Deserialize>(jss.Serialize(body["referenceData"])); var instanceId = (string)referenceData["instanceId"]; var fileKey = (string)referenceData["fileKey"]; - if (instanceId == _Default.GetServerUrl(false)) + if (instanceId == DocManagerHelper.GetServerUrl(false)) { var fileKeyObj = jss.Deserialize>(fileKey); userAddress = (string)fileKeyObj["userAddress"]; - if (userAddress == HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))) + if (userAddress == HttpUtility.UrlEncode(DocManagerHelper.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))) { fileName = (string)fileKeyObj["fileName"]; } } } - if (fileName != "") + if (fileName == "") { try { var path = (string)body["path"]; path = Path.GetFileName(path); - if (File.Exists(_Default.StoragePath(path, null))) + if (File.Exists(DocManagerHelper.StoragePath(path, null))) { fileName = path; } @@ -660,16 +660,16 @@ namespace OnlineEditorsExampleMVC var data = new Dictionary() { { "fileType", (Path.GetExtension(fileName) ?? "").ToLower() }, - { "url", DocEditor.getDownloadUrl(fileName)}, - { "directUrl", DocEditor.getDownloadUrl(fileName) }, + { "url", DocManagerHelper.GetDownloadUrl(fileName)}, + { "directUrl", DocManagerHelper.GetDownloadUrl(fileName) }, { "referenceData", new Dictionary() { { "fileKey", jss.Serialize(new Dictionary{ {"fileName", fileName}, - {"userAddress", HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} + {"userAddress", HttpUtility.UrlEncode(DocManagerHelper.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))} }) }, - {"instanceId", _Default.GetServerUrl(false) } + {"instanceId", DocManagerHelper.GetServerUrl(false) } } }, { "path", fileName } @@ -685,5 +685,5 @@ namespace OnlineEditorsExampleMVC } } - } + } \ No newline at end of file From 61a8490d4f952a46ec1311de52cd5d95f16eb947 Mon Sep 17 00:00:00 2001 From: rivexe Date: Mon, 27 Feb 2023 10:10:37 +0300 Subject: [PATCH 42/49] csharp: check of empty filename-string (logical error fixed) --- web/documentserver-example/csharp/WebEditor.ashx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index da955086..c18e3e8f 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -453,7 +453,7 @@ namespace OnlineEditorsExample } } - if (fileName != "") + if (fileName == "") { try { From dcc7bdfcaee98bb5f7e41db82669e9a04bb93334 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 28 Feb 2023 00:07:58 +0500 Subject: [PATCH 43/49] nodejs: icons for mobile actions in wopi --- .../nodejs/public/images/wopi-mobileEdit.svg | 4 ++++ .../nodejs/public/images/wopi-mobileView.svg | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 web/documentserver-example/nodejs/public/images/wopi-mobileEdit.svg create mode 100644 web/documentserver-example/nodejs/public/images/wopi-mobileView.svg diff --git a/web/documentserver-example/nodejs/public/images/wopi-mobileEdit.svg b/web/documentserver-example/nodejs/public/images/wopi-mobileEdit.svg new file mode 100644 index 00000000..bdf96fb7 --- /dev/null +++ b/web/documentserver-example/nodejs/public/images/wopi-mobileEdit.svg @@ -0,0 +1,4 @@ + + + + diff --git a/web/documentserver-example/nodejs/public/images/wopi-mobileView.svg b/web/documentserver-example/nodejs/public/images/wopi-mobileView.svg new file mode 100644 index 00000000..15c9b172 --- /dev/null +++ b/web/documentserver-example/nodejs/public/images/wopi-mobileView.svg @@ -0,0 +1,4 @@ + + + + From bdca34355010ad75508458659a9d7d8a436aabe7 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 28 Feb 2023 12:26:45 +0500 Subject: [PATCH 44/49] Copyright 2023 --- web/documentserver-example/nodejs/views/index.ejs | 2 +- web/documentserver-example/nodejs/views/wopiIndex.ejs | 2 +- web/documentserver-example/python/templates/index.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/nodejs/views/index.ejs b/web/documentserver-example/nodejs/views/index.ejs index 9a9e4fe8..a8494e4b 100755 --- a/web/documentserver-example/nodejs/views/index.ejs +++ b/web/documentserver-example/nodejs/views/index.ejs @@ -307,7 +307,7 @@ Submit your request - © Ascensio Systems SIA 2021. All rights reserved. + © Ascensio Systems SIA 2023. All rights reserved. diff --git a/web/documentserver-example/nodejs/views/wopiIndex.ejs b/web/documentserver-example/nodejs/views/wopiIndex.ejs index 8545f06e..becd58da 100755 --- a/web/documentserver-example/nodejs/views/wopiIndex.ejs +++ b/web/documentserver-example/nodejs/views/wopiIndex.ejs @@ -244,7 +244,7 @@ Submit your request - © Ascensio Systems SIA 2021. All rights reserved. + © Ascensio Systems SIA 2023. All rights reserved. diff --git a/web/documentserver-example/python/templates/index.html b/web/documentserver-example/python/templates/index.html index 6a19bc96..cd754131 100644 --- a/web/documentserver-example/python/templates/index.html +++ b/web/documentserver-example/python/templates/index.html @@ -323,7 +323,7 @@ Submit your request - © Ascensio Systems SIA 2021. All rights reserved. + © Ascensio Systems SIA 2023. All rights reserved. From 251f48ee1ea5fefd7e258fbde6eefb809b89d43f Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 28 Feb 2023 17:40:37 +0500 Subject: [PATCH 45/49] nodejs: do not check oform param in ie11 --- web/documentserver-example/nodejs/views/editor.ejs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index 25069dba..5d739c21 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -232,7 +232,10 @@ config.events.onRequestSaveAs = onRequestSaveAs; } - if (new URL(window.location).searchParams.get("oform") == "false") { + try { + var oformParam = new URL(window.location).searchParams.get("oform"); + } catch (e) {} + if (oformParam == "false") { config.document.options = config.document.options || {}; config.document.options["oform"] = false; } From 4d4951f184466645a80c52cca4824ca97488d410 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Sat, 18 Feb 2023 14:09:50 +0500 Subject: [PATCH 46/49] referenceData to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index be701972..d1c9ae04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- referenceData - anonymous can't protect file - separate setting for checking the token in requests - php: linter refactoring From 76a2bfd9f9619986d9e116f23b6b2df9c6783cc2 Mon Sep 17 00:00:00 2001 From: Stepan Mayorov Date: Thu, 2 Mar 2023 12:04:21 +0300 Subject: [PATCH 47/49] Margin of icons in WOPI-template. New actions included. (#351) * nodejs: WOPI - margin of icons = 8px, media-queries changed. * nodejs: WOPI - margin of icons for new actions. --- .../nodejs/public/stylesheets/media-wopi.css | 49 ++++++++++++++++--- .../nodejs/public/stylesheets/stylesheet.css | 1 + 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/nodejs/public/stylesheets/media-wopi.css b/web/documentserver-example/nodejs/public/stylesheets/media-wopi.css index 24794254..637c585d 100644 --- a/web/documentserver-example/nodejs/public/stylesheets/media-wopi.css +++ b/web/documentserver-example/nodejs/public/stylesheets/media-wopi.css @@ -18,7 +18,7 @@ .tableRow td:first-child{ flex-grow: 1; - max-width: 100%; + max-width: 50%; } .downloadContentCells{ @@ -55,6 +55,9 @@ .tableHeaderCellRemove{ padding-left: 7px; } + .tableRow td:first-child { + max-width: 45%; + } } @media (max-width: 986px) and (min-width: 890px){ .tableHeaderCellRemove{ @@ -68,19 +71,23 @@ width: 24%; padding-right: 0; } + .tableRow td:first-child { + max-width: 40%; + } } @media (max-width: 890px) and (min-width: 769px){ .tableRow td:first-child{ - max-width: 50%; + max-width: 30%; } .contentCells-shift{ padding-right: 26px; } + .contentCells-wopi{ + width: unset; + } } @media (max-width: 769px) and (min-width: 593px){ - .tableRow td:first-child{ - max-width: 40%; - } + } @media (max-width: 769px) { .tableRow td{ @@ -88,7 +95,12 @@ border: none; } .tableRow td:last-child:after{ - width: 95%; + top: 65px; + width: 100%; + height: 1%; + } + .tableRow td:first-child{ + max-width: 100%; } } @media (max-width: 593px){ @@ -101,3 +113,28 @@ height: 1%; } } +@media (max-width: 769px) and (min-width: 320px){ + .contentCells-icon { + width: 1%; + } +} +@media (max-width: 508px) { + .downloadContentCells { + margin-left: unset; + } + .contentCells-wopi { + width: 100%; + } + .contentCells-icon { + width: 1%; + } + .contentCells-shift { + padding-right: 30px; + padding-left: 3px; + } + .tableRow td:last-child:after{ + top: 95px; + height: 1%; + width: 100%; + } +} diff --git a/web/documentserver-example/nodejs/public/stylesheets/stylesheet.css b/web/documentserver-example/nodejs/public/stylesheets/stylesheet.css index 494f57f7..30d16c52 100644 --- a/web/documentserver-example/nodejs/public/stylesheets/stylesheet.css +++ b/web/documentserver-example/nodejs/public/stylesheets/stylesheet.css @@ -605,6 +605,7 @@ footer table tr td:first-child { .contentCells-wopi a { text-decoration: none; + margin-right: 8px; } .select-user { From 7f371699b1b3676e28366e3753b7d72bcba000b7 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 2 Mar 2023 14:22:20 +0500 Subject: [PATCH 48/49] nodejs: remove empty media style --- .../nodejs/public/stylesheets/media-wopi.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/web/documentserver-example/nodejs/public/stylesheets/media-wopi.css b/web/documentserver-example/nodejs/public/stylesheets/media-wopi.css index 637c585d..745c51a6 100644 --- a/web/documentserver-example/nodejs/public/stylesheets/media-wopi.css +++ b/web/documentserver-example/nodejs/public/stylesheets/media-wopi.css @@ -85,9 +85,6 @@ .contentCells-wopi{ width: unset; } -} -@media (max-width: 769px) and (min-width: 593px){ - } @media (max-width: 769px) { .tableRow td{ From 830fa87e273593c2cd23c54e84266ec124f81234 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 2 Mar 2023 14:35:54 +0500 Subject: [PATCH 49/49] fix reload page with cached checkbox status in FireFox --- .../nodejs/public/javascripts/jscript.js | 12 ++++++------ web/documentserver-example/php/js/jscript.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/web/documentserver-example/nodejs/public/javascripts/jscript.js b/web/documentserver-example/nodejs/public/javascripts/jscript.js index 7ec8f7e5..bc1b6538 100644 --- a/web/documentserver-example/nodejs/public/javascripts/jscript.js +++ b/web/documentserver-example/nodejs/public/javascripts/jscript.js @@ -245,7 +245,7 @@ if (typeof jQuery != "undefined") { window.open(url, "_blank"); jq('#hiddenFileName').val(""); jq.unblockUI(); - document.location.reload(); + document.location.reload(true); }); jq(document).on("click", "#beginView:not(.disable)", function () { @@ -258,7 +258,7 @@ if (typeof jQuery != "undefined") { window.open(url, "_blank"); jq('#hiddenFileName').val(""); jq.unblockUI(); - document.location.reload(); + document.location.reload(true); }); jq(document).on("click", "#beginEmbedded:not(.disable)", function () { @@ -272,13 +272,13 @@ if (typeof jQuery != "undefined") { }); jq(document).on("click", ".reload-page", function () { - setTimeout(function () { document.location.reload(); }, 1000); + setTimeout(function () { document.location.reload(true); }, 1000); return true; }); jq(document).on("mouseup", ".reload-page", function (event) { if (event.which == 2) { - setTimeout(function () { document.location.reload(); }, 1000); + setTimeout(function () { document.location.reload(true); }, 1000); } return true; }); @@ -288,7 +288,7 @@ if (typeof jQuery != "undefined") { jq("#embeddedView").remove(); jq.unblockUI(); if (mustReload) { - document.location.reload(); + document.location.reload(true); } }); @@ -303,7 +303,7 @@ if (typeof jQuery != "undefined") { type: "delete", url: requestAddress, complete: function (data) { - document.location.reload(); + document.location.reload(true); } }); }); diff --git a/web/documentserver-example/php/js/jscript.js b/web/documentserver-example/php/js/jscript.js index bfb7fb66..49e5ad25 100644 --- a/web/documentserver-example/php/js/jscript.js +++ b/web/documentserver-example/php/js/jscript.js @@ -251,7 +251,7 @@ if (typeof jQuery != "undefined") { window.open(url, "_blank"); jq('#hiddenFileName').val(""); jq.unblockUI(); - document.location.reload(); + document.location.reload(true); }); jq(document).on("click", "#beginView:not(.disable)", function () { @@ -260,7 +260,7 @@ if (typeof jQuery != "undefined") { window.open(url, "_blank"); jq('#hiddenFileName').val(""); jq.unblockUI(); - document.location.reload(); + document.location.reload(true); }); jq(document).on("click", "#beginEmbedded:not(.disable)", function () { @@ -274,13 +274,13 @@ if (typeof jQuery != "undefined") { }); jq(document).on("click", ".reload-page", function () { - setTimeout(function () { document.location.reload(); }, 1000); + setTimeout(function () { document.location.reload(true); }, 1000); return true; }); jq(document).on("mouseup", ".reload-page", function (event) { if (event.which == 2) { - setTimeout(function () { document.location.reload(); }, 1000); + setTimeout(function () { document.location.reload(true); }, 1000); } return true; }); @@ -290,7 +290,7 @@ if (typeof jQuery != "undefined") { jq("#embeddedView").attr("src", ""); jq.unblockUI(); if (mustReload) { - document.location.reload(); + document.location.reload(true); } }); @@ -305,7 +305,7 @@ if (typeof jQuery != "undefined") { type: "get", url: requestAddress, complete: function (data) { - document.location.reload(); + document.location.reload(true); } }); });