[Libreoffice-commits] online.git: wsd/Storage.cpp

2020-07-01 Thread Mike Kaganski (via logerrit)
 wsd/Storage.cpp |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 6de63613fb7ec00370caa7e3efce4405b688279e
Author: Mike Kaganski 
AuthorDate: Wed Jul 1 01:29:58 2020 +0300
Commit: Mike Kaganski 
CommitDate: Wed Jul 1 08:09:34 2020 +0200

Improve logging failed lock request using X-WOPI-LockFailureReason

Change-Id: Ia521422d033861cd002e7eb2123ccc18e9cd0071
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97555
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index bcd428ce7..0d616f23c 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -819,8 +819,11 @@ bool WopiStorage::updateLockState(const Authorization& 
auth, const std::string&
 }
 else
 {
+std::string sMoreInfo = response.get("X-WOPI-LockFailureReason", 
"");
+if (!sMoreInfo.empty())
+sMoreInfo = ", failure reason: \"" + sMoreInfo + "\"";
 LOG_WRN("Un-successful " << wopiLog << " with status " << 
response.getStatus() <<
-" and response: " << responseString);
+sMoreInfo << " and response: " << responseString);
 }
 }
 catch (const Poco::Exception& pexc)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2020-06-30 Thread Ashod Nakashian (via logerrit)
 wsd/Storage.cpp |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

New commits:
commit 77aa8161807d3e934c9bad48d6494fe9ca029277
Author: Ashod Nakashian 
AuthorDate: Sat Jun 20 14:07:13 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 07:35:53 2020 +0200

wsd: log the response from WOPI CheckFileInfo separately

Change-Id: I8af28a7332903e6ed36dfba6bbd6bfbb5ebbd4db
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96828
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index fbda5edb8..6c5a14878 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -587,15 +587,17 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 std::istream& rs = psession->receiveResponse(response);
 callDuration = (std::chrono::steady_clock::now() - startTime);
 
-if (logger.enabled())
+Log::StreamLogger logRes = Log::trace();
+if (logRes.enabled())
 {
-logger << "WOPI::CheckFileInfo response header for URI [" << 
uriAnonym << "]:\n";
+logRes << "WOPI::CheckFileInfo response header for URI [" << 
uriAnonym
+   << "]: " << response.getStatus() << '\n';
 for (const auto& pair : response)
 {
-logger << '\t' << pair.first << ": " << pair.second << " / ";
+logRes << '\t' << pair.first << ": " << pair.second << " / ";
 }
 
-LOG_END(logger, true);
+LOG_END(logRes, true);
 }
 
 if (response.getStatus() != Poco::Net::HTTPResponse::HTTP_OK)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2020-06-30 Thread Mike Kaganski (via logerrit)
 wsd/Storage.cpp |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 64950bcc4e9afeeaec1725342c6fec67d245dffd
Author: Mike Kaganski 
AuthorDate: Tue Jun 30 16:37:40 2020 +0300
Commit: Mike Kaganski 
CommitDate: Tue Jun 30 15:58:42 2020 +0200

IIS requires content-length for POST requests

Without the content-length, LOCK requests result in 411 response with
the message: "The request must be chunked or have a content length".

Ref: https://forums.iis.net/t/1119456.aspx

Change-Id: Ieceb2bcf478c5f6baf97ee6b89d37622da168df5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97524
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Mike Kaganski 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 61823d67e..fbda5edb8 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -795,6 +795,9 @@ bool WopiStorage::updateLockState(const Authorization& 
auth, const std::string&
 if (!getExtendedData().empty())
 request.set("X-LOOL-WOPI-ExtendedData", getExtendedData());
 
+// IIS requires content-length for POST requests: see 
https://forums.iis.net/t/1119456.aspx
+request.setContentLength(0);
+
 psession->sendRequest(request);
 Poco::Net::HTTPResponse response;
 std::istream& rs = psession->receiveResponse(response);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp wsd/Storage.hpp

2020-06-20 Thread Ashod Nakashian (via logerrit)
 wsd/Storage.cpp |   71 
 wsd/Storage.hpp |6 
 2 files changed, 42 insertions(+), 35 deletions(-)

New commits:
commit 2c73b622d75ee6fa62b7d74e1548cda877201af8
Author: Ashod Nakashian 
AuthorDate: Sun Jun 14 12:44:10 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Sat Jun 20 16:33:20 2020 +0200

wsd: extract WOPI HTTP request construction

This hoists the common parts of the HTTPRequest
for all WOPI requests to avoid errors when changing them.

Change-Id: Ia02ef657a43b7a7d2fc13be3da012836fa0d7650
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96372
Tested-by: Jenkins CollaboraOffice 
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 1da4eaf74..61823d67e 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -529,6 +529,23 @@ void LockContext::dumpState(std::ostream& os) const
 
 #if !MOBILEAPP
 
+void WopiStorage::initHttpRequest(Poco::Net::HTTPRequest& request, const 
Poco::URI& uri,
+  const Authorization& auth, const 
std::string& cookies) const
+{
+request.set("User-Agent", WOPI_AGENT_STRING);
+
+auth.authorizeRequest(request);
+
+addStorageDebugCookie(request);
+
+// TODO: Avoid repeated parsing.
+std::map params = GetQueryParams(uri);
+addWopiProof(request, uri, params["access_token"]);
+
+if (_reuseCookies)
+addStorageReuseCookie(request, cookies);
+}
+
 std::unique_ptr WopiStorage::getWOPIFileInfo(const 
Authorization& auth,
 const 
std::string& cookies,
 
LockContext& lockCtx)
@@ -537,7 +554,6 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 Poco::URI uriObject(getUri());
 auth.authorizeURI(uriObject);
 const std::string uriAnonym = LOOLWSD::anonymizeUrl(uriObject.toString());
-std::map params = GetQueryParams(uriObject);
 
 LOG_DBG("Getting info for wopi uri [" << uriAnonym << "].");
 
@@ -545,13 +561,11 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 std::chrono::duration callDuration(0);
 try
 {
-Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
-request.set("User-Agent", WOPI_AGENT_STRING);
-auth.authorizeRequest(request);
-addStorageDebugCookie(request);
-if (_reuseCookies)
-addStorageReuseCookie(request, cookies);
-addWopiProof(request, uriObject, params["access_token"]);
+Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET,
+   uriObject.getPathAndQuery(),
+   Poco::Net::HTTPMessage::HTTP_1_1);
+initHttpRequest(request, uriObject, auth, cookies);
+
 const auto startTime = std::chrono::steady_clock::now();
 
 std::unique_ptr 
psession(getHTTPClientSession(uriObject));
@@ -760,8 +774,6 @@ bool WopiStorage::updateLockState(const Authorization& 
auth, const std::string&
 Poco::URI uriObject(getUri());
 auth.authorizeURI(uriObject);
 
-std::map params = GetQueryParams(uriObject);
-
 Poco::URI uriObjectAnonym(getUri());
 uriObjectAnonym.setPath(LOOLWSD::anonymizeUrl(uriObjectAnonym.getPath()));
 const std::string uriAnonym = uriObjectAnonym.toString();
@@ -773,18 +785,15 @@ bool WopiStorage::updateLockState(const Authorization& 
auth, const std::string&
 {
 std::unique_ptr 
psession(getHTTPClientSession(uriObject));
 
-Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, 
uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
-request.set("User-Agent", WOPI_AGENT_STRING);
-auth.authorizeRequest(request);
+Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST,
+   uriObject.getPathAndQuery(),
+   Poco::Net::HTTPMessage::HTTP_1_1);
+initHttpRequest(request, uriObject, auth, cookies);
 
 request.set("X-WOPI-Override", lock ? "LOCK" : "UNLOCK");
 request.set("X-WOPI-Lock", lockCtx._lockToken);
 if (!getExtendedData().empty())
 request.set("X-LOOL-WOPI-ExtendedData", getExtendedData());
-addStorageDebugCookie(request);
-if (_reuseCookies)
-addStorageReuseCookie(request, cookies);
-addWopiProof(request, uriObject, params["access_token"]);
 
 psession->sendRequest(request);
 Poco::Net::HTTPResponse response;
@@ -833,8 +842,6 @@ std::string WopiStorage::loadStorageFileToLocal(const 
Authorization& auth,
 uriObject.setPath(uriObject.getPath() + "/contents");
 auth.authorizeURI(uriObject);
 
-std::map params = GetQueryParams(uriObject);
-
 

[Libreoffice-commits] online.git: wsd/Storage.cpp wsd/Storage.hpp

2020-06-11 Thread Michael Meeks (via logerrit)
 wsd/Storage.cpp |  239 ++--
 wsd/Storage.hpp |   95 +-
 2 files changed, 120 insertions(+), 214 deletions(-)

New commits:
commit 33a5813d84f24910c36adc3615b0d017f13f6e4d
Author: Michael Meeks 
AuthorDate: Thu Jun 11 15:54:27 2020 +0100
Commit: Michael Meeks 
CommitDate: Thu Jun 11 17:38:32 2020 +0200

WOPI: pure re-factor, remove rampant duplication.

Dung out lots of pointless intermediate variables, and overly
verbose code. Vertical space is not a renewable resource.

Most variables had a consistent pattern, except these:

caller var  c'tor parameter member name

Change-Id: I7910b713b8c4f6950b1e7be9c3a8e4eb4f54e249
--
userId  userid  _userId
userNameusername_username
canWriteuserCanWrite_userCanWriter
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96129
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 95046acac..3960544c2 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -12,6 +12,7 @@
 #include "Storage.hpp"
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -602,40 +603,6 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 LOG_ERR("Cannot get file info from WOPI storage uri [" << uriAnonym << 
"]. Error:  Failed HTPP request authorization");
 }
 
-// Parse the response.
-std::string filename;
-size_t size = 0;
-std::string ownerId;
-std::string userId;
-std::string userName;
-std::string obfuscatedUserId;
-std::string userExtraInfo;
-std::string watermarkText;
-std::string templateSaveAs;
-std::string templateSource;
-bool canWrite = false;
-bool enableOwnerTermination = false;
-std::string postMessageOrigin;
-bool hidePrintOption = false;
-bool hideSaveOption = false;
-bool hideExportOption = false;
-bool disablePrint = false;
-bool disableExport = false;
-bool disableCopy = false;
-bool disableInactiveMessages = false;
-bool downloadAsPostMessage = false;
-std::string lastModifiedTime;
-bool userCanNotWriteRelative = true;
-bool enableInsertRemoteImage = false;
-bool enableShare = false;
-bool supportsLocks = false;
-bool supportsRename = false;
-bool userCanRename = false;
-std::string hideUserList("false");
-WOPIFileInfo::TriState disableChangeTrackingRecord = 
WOPIFileInfo::TriState::Unset;
-WOPIFileInfo::TriState disableChangeTrackingShow = 
WOPIFileInfo::TriState::Unset;
-WOPIFileInfo::TriState hideChangeTrackingControls = 
WOPIFileInfo::TriState::Unset;
-
 Poco::JSON::Object::Ptr object;
 if (JsonUtil::parseJSON(wopiResponse, object))
 {
@@ -644,88 +611,26 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 else
 LOG_DBG("WOPI::CheckFileInfo (" << callDuration.count() * 1000. << 
" ms): " << wopiResponse);
 
-JsonUtil::findJSONValue(object, "BaseFileName", filename);
+size_t size = 0;
+std::string filename, ownerId, lastModifiedTime;
+
+JsonUtil::findJSONValue(object, "Size", size);
 JsonUtil::findJSONValue(object, "OwnerId", ownerId);
-JsonUtil::findJSONValue(object, "UserId", userId);
-JsonUtil::findJSONValue(object, "UserFriendlyName", userName);
-JsonUtil::findJSONValue(object, "TemplateSaveAs", templateSaveAs);
-JsonUtil::findJSONValue(object, "TemplateSource", templateSource);
+JsonUtil::findJSONValue(object, "BaseFileName", filename);
+JsonUtil::findJSONValue(object, "LastModifiedTime", lastModifiedTime);
+
+const std::chrono::system_clock::time_point modifiedTime = 
Util::iso8601ToTimestamp(lastModifiedTime, "LastModifiedTime");
+FileInfo fileInfo = FileInfo({filename, ownerId, modifiedTime, size});
+setFileInfo(fileInfo);
 
-// Anonymize key values.
 if (LOOLWSD::AnonymizeUserData)
-{
 Util::mapAnonymized(Util::getFilenameFromURL(filename), 
Util::getFilenameFromURL(getUri().toString()));
 
-JsonUtil::findJSONValue(object, "ObfuscatedUserId", 
obfuscatedUserId, false);
-if (!obfuscatedUserId.empty())
-{
-Util::mapAnonymized(ownerId, obfuscatedUserId);
-Util::mapAnonymized(userId, obfuscatedUserId);
-Util::mapAnonymized(userName, obfuscatedUserId);
-}
-
-// Set anonymized version of the above fields before logging.
-// Note: anonymization caches the result, so we don't need to 
store here.
-if (LOOLWSD::AnonymizeUserData)
-object->set("BaseFileName", LOOLWSD::anonymizeUrl(filename));
-
-// 

[Libreoffice-commits] online.git: wsd/Storage.cpp wsd/Storage.hpp

2020-06-08 Thread Samuel Mehrbrodt (via logerrit)
 wsd/Storage.cpp |2 +-
 wsd/Storage.hpp |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 043e3c5238ded940a109f51bc170eaf83dde5670
Author: Samuel Mehrbrodt 
AuthorDate: Mon Jun 8 15:26:09 2020 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Mon Jun 8 15:39:00 2020 +0200

Rename: getIsAutosave -> isAutosave

Change-Id: I30b8d52ff33c2ae270b44a1670bacc4a48af4495
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95807
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 7e262b1cd..95046acac 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -970,7 +970,7 @@ WopiStorage::saveLocalFileToStorage(const Authorization& 
auth, const std::string
 if (lockCtx._supportsLocks)
 request.set("X-WOPI-Lock", lockCtx._lockToken);
 request.set("X-LOOL-WOPI-IsModifiedByUser", isUserModified()? 
"true": "false");
-request.set("X-LOOL-WOPI-IsAutosave", getIsAutosave()? "true": 
"false");
+request.set("X-LOOL-WOPI-IsAutosave", isAutosave()? "true": 
"false");
 request.set("X-LOOL-WOPI-IsExitSave", isExitSave()? "true": 
"false");
 if (!getExtendedData().empty())
 request.set("X-LOOL-WOPI-ExtendedData", getExtendedData());
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index e5ea41101..e7fa612b9 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -203,7 +203,7 @@ public:
 
 /// To be able to set the WOPI 'is autosave/is exitsave?' headers 
appropriately.
 void setIsAutosave(bool isAutosave) { _isAutosave = isAutosave; }
-bool getIsAutosave() const { return _isAutosave; }
+bool isAutosave() const { return _isAutosave; }
 void setIsExitSave(bool exitSave) { _isExitSave = exitSave; }
 bool isExitSave() const { return _isExitSave; }
 void setExtendedData(const std::string& extendedData) { _extendedData = 
extendedData; }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2020-05-05 Thread Jan Holesovsky (via logerrit)
 wsd/Storage.cpp |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 168b3ed04682c6767d4e85563239f58e2c1e908b
Author: Jan Holesovsky 
AuthorDate: Tue May 5 15:25:25 2020 +0200
Commit: Jan Holesovsky 
CommitDate: Tue May 5 17:08:30 2020 +0200

nocaps: Fix WOPI load.

Change-Id: I538be45897902e9d8ff63d85b1e486767dacbb2d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93484
Tested-by: Jan Holesovsky 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index f010894c4..adaaa79fe 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -907,7 +907,10 @@ std::string WopiStorage::loadStorageFileToLocal(const 
Authorization& auth,
 setLoaded(true);
 
 // Now return the jailed path.
-return Poco::Path(getJailPath(), 
getFileInfo().getFilename()).toString();
+if (LOOLWSD::NoCapsForKit)
+return getRootFilePath();
+else
+return Poco::Path(getJailPath(), 
getFileInfo().getFilename()).toString();
 }
 }
 catch (const Poco::Exception& pexc)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2020-02-19 Thread Mike Kaganski (via logerrit)
 wsd/Storage.cpp |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 098c0a5752488909c5b676b5d1fccf52a7515207
Author: Mike Kaganski 
AuthorDate: Wed Feb 19 16:38:47 2020 +0300
Commit: Mike Kaganski 
CommitDate: Wed Feb 19 15:35:26 2020 +0100

Check that absolute URI is passed to addWopiProof

Change-Id: I28385f330064645dc2c30a3c3180df2a297b2e53
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89021
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Mike Kaganski 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index ac347071e..e0487f817 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -452,10 +452,11 @@ static void addStorageReuseCookie(Poco::Net::HTTPRequest& 
request, const std::st
 }
 
 // access_token must be decoded
-void addWopiProof(Poco::Net::HTTPRequest& request, const std::string& uri,
+void addWopiProof(Poco::Net::HTTPRequest& request, const Poco::URI& uri,
   const std::string& access_token)
 {
-for (const auto& header : GetProofHeaders(access_token, uri))
+assert(!uri.isRelative());
+for (const auto& header : GetProofHeaders(access_token, uri.toString()))
 request.set(header.first, header.second);
 }
 
@@ -527,7 +528,7 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 addStorageDebugCookie(request);
 if (_reuseCookies)
 addStorageReuseCookie(request, cookies);
-addWopiProof(request, uriObject.toString(), params["access_token"]);
+addWopiProof(request, uriObject, params["access_token"]);
 const auto startTime = std::chrono::steady_clock::now();
 
 std::unique_ptr 
psession(getHTTPClientSession(uriObject));
@@ -759,7 +760,7 @@ bool WopiStorage::updateLockState(const Authorization& 
auth, const std::string&
 addStorageDebugCookie(request);
 if (_reuseCookies)
 addStorageReuseCookie(request, cookies);
-addWopiProof(request, uriObject.toString(), params["access_token"]);
+addWopiProof(request, uriObject, params["access_token"]);
 
 psession->sendRequest(request);
 Poco::Net::HTTPResponse response;
@@ -838,7 +839,7 @@ std::string WopiStorage::loadStorageFileToLocal(const 
Authorization& auth,
 addStorageDebugCookie(request);
 if (_reuseCookies)
 addStorageReuseCookie(request, cookies);
-addWopiProof(request, uriObject.toString(), params["access_token"]);
+addWopiProof(request, uriObject, params["access_token"]);
 psession->sendRequest(request);
 
 Poco::Net::HTTPResponse response;
@@ -997,7 +998,7 @@ WopiStorage::saveLocalFileToStorage(const Authorization& 
auth, const std::string
 addStorageDebugCookie(request);
 if (_reuseCookies)
 addStorageReuseCookie(request, cookies);
-addWopiProof(request, uriObject.toString(), params["access_token"]);
+addWopiProof(request, uriObject, params["access_token"]);
 std::ostream& os = psession->sendRequest(request);
 
 std::ifstream ifs(filePath);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2020-02-18 Thread Mike Kaganski (via logerrit)
 wsd/Storage.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit c55afd25756351a86d44fc878ebd7ed13ab620fa
Author: Mike Kaganski 
AuthorDate: Fri Feb 14 17:15:22 2020 +0300
Commit: Mike Kaganski 
CommitDate: Tue Feb 18 17:30:35 2020 +0100

Don't drop trace log on error

Change-Id: I4839b02f01156e433de095395f1cb034e9aa9745
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88716
Reviewed-by: Michael Meeks 
Tested-by: Jenkins CollaboraOffice 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index b470ba433..ac347071e 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -547,6 +547,7 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 }
 
 LOG_END(logger, true);
+logger.flush();
 }
 
 if (response.getStatus() != Poco::Net::HTTPResponse::HTTP_OK)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2020-01-20 Thread Miklos Vajna (via logerrit)
 wsd/Storage.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2c9e1319d9ae27989c51f5c4eb33ef861722d80c
Author: Miklos Vajna 
AuthorDate: Mon Jan 20 09:26:01 2020 +0100
Commit: Miklos Vajna 
CommitDate: Mon Jan 20 10:08:09 2020 +0100

Fix a -Werror,-Wrange-loop-analysis warning

wsd/Storage.cpp:451:21: error: loop variable 'header' of type 'const 
std::pair, std::__cxx11::basic_string >' 
creates a copy from type 'const std::pair, 
std::__cxx11::basic_string >' [-Werror,-Wrange-loop-analysis]

Change-Id: I90a57333b0807f3457d5b1082097426a3bf9678d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87055
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index e1efa864c..0be7c7c7b 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -448,7 +448,7 @@ static void addStorageReuseCookie(Poco::Net::HTTPRequest& 
request, const std::st
 
 void addWopiProof(Poco::Net::HTTPRequest& request, const std::string& 
access_token)
 {
-for (const auto header : GetProofHeaders(access_token, request.getURI()))
+for (const auto& header : GetProofHeaders(access_token, request.getURI()))
 request.set(header.first, header.second);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2020-01-07 Thread Ashod Nakashian (via logerrit)
 wsd/Storage.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit af58a9e761a00ea1a23ca294b80e11229cfa00f1
Author: Ashod Nakashian 
AuthorDate: Tue Dec 17 09:41:34 2019 -0500
Commit: Jan Holesovsky 
CommitDate: Tue Jan 7 11:47:04 2020 +0100

wsd: whitespace

Change-Id: Id8185dab66f95676be2db8908d0f12c5284174fb
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86321
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 51c6969f7..e1efa864c 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -642,7 +642,7 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 object->remove("BaseFileName");
 object->remove("TemplateSaveAs");
 object->remove("TemplateSource");
- object->remove("OwnerId");
+object->remove("OwnerId");
 object->remove("UserId");
 object->remove("UserFriendlyName");
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2019-12-03 Thread Ashod Nakashian (via logerrit)
 wsd/Storage.cpp |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 86a80a4ccaf129ce6c4afa60fe861506cbd0530c
Author: Ashod Nakashian 
AuthorDate: Mon Dec 2 08:09:24 2019 -0500
Commit: Ashod Nakashian 
CommitDate: Tue Dec 3 16:02:16 2019 +0100

wsd: handle http forbidden response from wopi put

Change-Id: I597e949cd1bea612400d623f30ea260036253e89
Reviewed-on: https://gerrit.libreoffice.org/84360
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 484751352..f14954a6e 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -1054,7 +1054,8 @@ StorageBase::SaveResult 
WopiStorage::saveLocalFileToStorage(const Authorization&
 {
 saveResult.setResult(StorageBase::SaveResult::DISKFULL);
 }
-else if (response.getStatus() == 
Poco::Net::HTTPResponse::HTTP_UNAUTHORIZED)
+else if (response.getStatus() == 
Poco::Net::HTTPResponse::HTTP_UNAUTHORIZED ||
+ response.getStatus() == 
Poco::Net::HTTPResponse::HTTP_FORBIDDEN)
 {
 saveResult.setResult(StorageBase::SaveResult::UNAUTHORIZED);
 }
@@ -1077,6 +1078,7 @@ StorageBase::SaveResult 
WopiStorage::saveLocalFileToStorage(const Authorization&
 }
 else
 {
+// Internal server error, and other failures.
 LOG_ERR("Unexpected response to " << wopiLog << " : " << 
response.getStatus() <<
 "Cannot save file to WOPI storage uri [" << uriAnonym << 
"]. Error: ");
 saveResult.setResult(StorageBase::SaveResult::FAILED);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: wsd/Storage.cpp

2019-11-21 Thread Michael Meeks (via logerrit)
 wsd/Storage.cpp |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 3dbee6745b63d04afa5d2ce007ca06025f1181a5
Author: Michael Meeks 
AuthorDate: Thu Nov 21 18:43:46 2019 +
Commit: Michael Meeks 
CommitDate: Thu Nov 21 18:44:38 2019 +

Log an error, and return failure on unhandled responses to save.

Change-Id: Ib241a88e53a11276b3837f49ea6d964d706919a4

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index d751f2f27..cc380ae7d 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -1041,6 +1041,12 @@ StorageBase::SaveResult 
WopiStorage::saveLocalFileToStorage(const Authorization&
 LOG_WRN("Invalid or missing JSON in " << wopiLog << " 
HTTP_CONFLICT response.");
 }
 }
+else
+{
+LOG_ERR("Unexpected response to " << wopiLog << " : " << 
response.getStatus() <<
+"Cannot save file to WOPI storage uri [" << uriAnonym << 
"]. Error: ");
+saveResult.setResult(StorageBase::SaveResult::FAILED);
+}
 }
 catch (const Poco::Exception& pexc)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: wsd/Storage.cpp

2019-11-21 Thread Michael Meeks (via logerrit)
 wsd/Storage.cpp |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 994f8993d9d1d6fdc9f7b48fa0efcc0f4bb1ec15
Author: Michael Meeks 
AuthorDate: Thu Nov 21 14:34:36 2019 +
Commit: Michael Meeks 
CommitDate: Thu Nov 21 14:34:36 2019 +

Add proof for locking calls (and mend the build).

Change-Id: I4cbaf682a14316750a676a14d986ecf59045581d

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index c68a5752f..d751f2f27 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -690,7 +690,7 @@ bool WopiStorage::updateLockState(const Authorization 
, LockContext 
 Poco::URI uriObject(getUri());
 auth.authorizeURI(uriObject);
 
-std::string reuseStorageCookies = getReuseCookies(uriObject);
+std::map params = GetQueryParams(uriObject);
 
 Poco::URI uriObjectAnonym(getUri());
 uriObjectAnonym.setPath(LOOLWSD::anonymizeUrl(uriObjectAnonym.getPath()));
@@ -713,7 +713,8 @@ bool WopiStorage::updateLockState(const Authorization 
, LockContext 
 request.set("X-LOOL-WOPI-ExtendedData", getExtendedData());
 addStorageDebugCookie(request);
 if (_reuseCookies)
-addStorageReuseCookie(request, reuseStorageCookies);
+addStorageReuseCookie(request, params["reuse_cookies"]);
+addWopiProof(request, params["access_token"]);
 
 psession->sendRequest(request);
 Poco::Net::HTTPResponse response;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: wsd/Storage.cpp

2019-10-09 Thread Andras Timar (via logerrit)
 wsd/Storage.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1dc6bd9dfb04bccbe4e5656a2ea39f60d3ebf4dc
Author: Andras Timar 
AuthorDate: Wed Oct 9 14:22:57 2019 +0200
Commit: Andras Timar 
CommitDate: Wed Oct 9 14:23:35 2019 +0200

typo fix: comuncation -> communication

Change-Id: Iefe88baa6ac5d2201dc3fb4e4604498898a30ba6

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index ab6e51cfc..9590c88ff 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -389,7 +389,7 @@ StorageBase::SaveResult 
LocalStorage::saveLocalFileToStorage(const Authorization
 
 Poco::Net::HTTPClientSession* StorageBase::getHTTPClientSession(const 
Poco::URI& uri)
  {
-// We decoupled the Wopi communication from client communcation because
+// We decoupled the Wopi communication from client communication because
 // the Wopi communication must have an independent policy.
 // So, we will use here only Storage settings.
 return (SSLEnabled || LOOLWSD::isSSLTermination())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: wsd/Storage.cpp

2019-10-09 Thread Andras Timar (via logerrit)
 wsd/Storage.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit df0dd1644579dbf767f573fc172da8962a4cc232
Author: Andras Timar 
AuthorDate: Wed Oct 9 12:17:33 2019 +0200
Commit: Andras Timar 
CommitDate: Wed Oct 9 12:17:33 2019 +0200

Fix the SSL termination case

Follow up commit of d597f22dac9042c3917d3b105adc810b6900d52c

Change-Id: I41ca46a93f4b82c6fea6489dbd4c0e3390ba652f

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 49e804b89..ab6e51cfc 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -392,12 +392,12 @@ Poco::Net::HTTPClientSession* 
StorageBase::getHTTPClientSession(const Poco::URI&
 // We decoupled the Wopi communication from client communcation because
 // the Wopi communication must have an independent policy.
 // So, we will use here only Storage settings.
-return (SSLEnabled)
+return (SSLEnabled || LOOLWSD::isSSLTermination())
  ? new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort(),
  
Poco::Net::SSLManager::instance().defaultClientContext())
  : new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
  }
- 
+
 namespace
 {
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: wsd/Storage.cpp

2019-09-22 Thread Ashod Nakashian (via logerrit)
 wsd/Storage.cpp |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 9c21408112a48aaded3e27e1257e54f1d8e53364
Author: Ashod Nakashian 
AuthorDate: Sat Sep 21 21:49:58 2019 -0400
Commit: Ashod Nakashian 
CommitDate: Sun Sep 22 20:25:04 2019 +0200

wsd: close iconv after converting

Change-Id: Idc0894362d0839449f7b1e1ae8c52c3ddb1dff45
Reviewed-on: https://gerrit.libreoffice.org/79352
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 992f4a0d3..c96bd208f 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -733,9 +733,10 @@ StorageBase::SaveResult 
WopiStorage::saveLocalFileToStorage(const Authorization&
 {
 // the suggested target has to be in UTF-7; default to extension
 // only when the conversion fails
-std::string suggestedTarget = "." + 
Poco::Path(saveAsFilename).getExtension();
+std::string suggestedTarget = '.' + 
Poco::Path(saveAsFilename).getExtension();
 
-iconv_t cd = iconv_open("UTF-7", "UTF-8");
+//TODO: Perhaps we should cache this descriptor and reuse, as 
iconv_open might be expensive.
+const iconv_t cd = iconv_open("UTF-7", "UTF-8");
 if (cd == (iconv_t) -1)
 LOG_ERR("Failed to initialize iconv for UTF-7 conversion, 
using '" << suggestedTarget << "'.");
 else
@@ -756,6 +757,8 @@ StorageBase::SaveResult 
WopiStorage::saveLocalFileToStorage(const Authorization&
 suggestedTarget = std::string([0], buffer.size() - 
out_left);
 LOG_TRC("Converted '" << saveAsFilename << "' to UTF-7 as 
'" << suggestedTarget << "'.");
 }
+
+iconv_close(cd);
 }
 
 if (isRename)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: wsd/Storage.cpp

2018-11-28 Thread Libreoffice Gerrit user
 wsd/Storage.cpp |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit b9694c305b07ff52b5659d5d4b7a0e6ecbea5487
Author: Tor Lillqvist 
AuthorDate: Wed Nov 28 12:40:52 2018 +0200
Commit: Tor Lillqvist 
CommitDate: Wed Nov 28 12:41:43 2018 +0200

Adapt after ed9c756c9ed9150f361340a2eb4dade9ec405935

Change-Id: Ide7ab1544039d11d478c30cc8fd9c09b1d1f6894

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index a42534eaa..7ed86bc3c 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -328,10 +328,10 @@ std::string LocalStorage::loadStorageFileToLocal(const 
Authorization& /*auth*/)
 #else // MOBILEAPP
 
 // In the mobile app we use no jail
-_jailedFilePath = _uri.getPath();
-_isLoaded = true;
+setRootFilePath(getUri().getPath());
+setLoaded(true);
 
-return _jailedFilePath;
+return getRootFilePath();
 #endif
 
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2018-11-06 Thread Libreoffice Gerrit user
 wsd/Storage.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 34eb014e2b57e21557d1345a31f93877b212af28
Author: Tor Lillqvist 
AuthorDate: Tue Nov 6 23:10:21 2018 +0200
Commit: Tor Lillqvist 
CommitDate: Tue Nov 6 23:16:43 2018 +0200

Drop the spaces from "Local Host #0" xauthor parameter

That "name" will be passed as the xauthor parameter in a message like:

child-01b9 load url=file:///.../x.odt?permission=edit 
jail=file:///.../x.odt xjail=file:///.../x.odt authorid=localhost1 
xauthorid=localhost1 author=Local%20Host%20#1 xauthor=Local Host #1 readonly=0 
lang=en-US

and that is parsed into space-separated tokens. Which leads to warning
messages like:

WRN  Unexpected doc options token [Host]. Skipping.| common/Session.cpp:94
WRN  Unexpected doc options token [#1]. Skipping.| common/Session.cpp:94

So use "LocalHost#0" etc instead.

Change-Id: I01ce8c4fb8309a7a9d3395e4fd874e469475d44c

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 3abcc12fa..a3f86e743 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -269,7 +269,7 @@ std::unique_ptr 
LocalStorage::getLocalFileInfo()
 _fileInfo = FileInfo({filename, "localhost", lastModified, size});
 
 // Set automatic userid and username
-return std::unique_ptr(new 
LocalFileInfo({"localhost" + std::to_string(LastLocalStorageId), "Local Host #" 
+ std::to_string(LastLocalStorageId++)}));
+return std::unique_ptr(new 
LocalFileInfo({"localhost" + std::to_string(LastLocalStorageId), "LocalHost#" + 
std::to_string(LastLocalStorageId++)}));
 }
 
 std::string LocalStorage::loadStorageFileToLocal(const Authorization& /*auth*/)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2018-03-23 Thread Pranav Kant
 wsd/Storage.cpp |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 6bb38614bdc6b37867bdd179eb18eecae4109452
Author: Pranav Kant 
Date:   Fri Mar 23 16:46:18 2018 +0530

Some helpful logging

Change-Id: I75e5e6cbbecf1e1af94a6710ecab4ced5637f14f

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 5ff0dc822..f25220894 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -268,7 +268,8 @@ std::string LocalStorage::loadStorageFileToLocal(const 
Authorization& /*auth*/)
 if (!Poco::File(_jailedFilePath).exists() && link(publicFilePath.c_str(), 
_jailedFilePath.c_str()) == -1)
 {
 // Failed
-LOG_WRN("link(\"" << publicFilePath << "\", \"" << _jailedFilePath << 
"\") failed. Will copy.");
+LOG_WRN("link(\"" << publicFilePath << "\", \"" << _jailedFilePath << 
"\") failed. Will copy. "
+"Linking error: " << errno << " " << strerror(errno));
 }
 
 try
@@ -303,7 +304,7 @@ StorageBase::SaveResult 
LocalStorage::saveLocalFileToStorage(const Authorization
 {
 try
 {
-LOG_TRC("Saving local file to local file storage " << _isCopy << " for 
" << _jailedFilePath);
+LOG_TRC("Saving local file to local file storage (isCopy: " << _isCopy 
<< ") for " << _jailedFilePath);
 // Copy the file back.
 if (_isCopy && Poco::File(_jailedFilePath).exists())
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2018-02-14 Thread Andras Timar
 wsd/Storage.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit baa3e09bdefb49d3aa3c3fddf11cd5a888d8f00b
Author: Andras Timar 
Date:   Wed Feb 14 12:29:50 2018 +0100

Typo: remove -> remote

Change-Id: I6214f569d6a0302c5a5a69a18150122a371e0d03

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index fef0c2b7..c2f3664d 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -115,7 +115,7 @@ void StorageBase::initialize()
 // Init client
 Poco::Net::Context::Params sslClientParams;
 
-// TODO: Be more strict and setup SSL key/certs for remove server and us
+// TODO: Be more strict and setup SSL key/certs for remote server and us
 sslClientParams.verificationMode = Poco::Net::Context::VERIFY_NONE;
 
 Poco::SharedPtr 
consoleClientHandler = new Poco::Net::KeyConsoleHandler(false);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2018-02-10 Thread Michael Meeks
 wsd/Storage.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d2f23dd8c232662fedded948109d0f747ca93b05
Author: Michael Meeks 
Date:   Thu Feb 1 12:49:28 2018 +

Helpful error on non-matched WOPI host.

Change-Id: Ib752148be0acbf15cd8b737b71414313d05f6aca

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 5698d24c..fef0c2b7 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -222,7 +222,7 @@ std::unique_ptr StorageBase::create(const 
Poco::URI& uri, const std
 {
 return std::unique_ptr(new WopiStorage(uri, jailRoot, 
jailPath));
 }
-
+LOG_ERR("No acceptable WOPI hosts found matching the target host [" << 
targetHost << "] in config.");
 throw UnauthorizedRequestException("No acceptable WOPI hosts found 
matching the target host [" + targetHost + "] in config.");
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2018-01-18 Thread Pranav Kant
 wsd/Storage.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 0547507b671e14b550e2f782cc993ef15010a023
Author: Pranav Kant 
Date:   Thu Jan 18 20:50:35 2018 +0530

wsd: Fix incorrect file size reported

Close/flush the file after copying into it so that we can calculate the 
exact
filesize later on.

Change-Id: I30aca9d0ac3702394a4465c30c61954a726eec39

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index d5c8db6b..1227c7fe 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -638,6 +638,7 @@ std::string WopiStorage::loadStorageFileToLocal(const 
Authorization& auth)
 std::copy(std::istreambuf_iterator(rs),
   std::istreambuf_iterator(),
   std::ostreambuf_iterator(ofs));
+ofs.close();
 LOG_INF("WOPI::GetFile downloaded " << 
getFileSize(_jailedFilePath) << " bytes from [" << uriObject.toString() <<
 "] -> " << _jailedFilePath << " in " << diff.count() << 
"s");
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2017-10-31 Thread Tor Lillqvist
 wsd/Storage.cpp |4 
 1 file changed, 4 deletions(-)

New commits:
commit 12aaff7d1ae356e7bd734aaffc459e641b682ee3
Author: Tor Lillqvist 
Date:   Tue Oct 31 12:09:47 2017 +0200

Bin some superfluous vertical whitespace

Change-Id: I770342c34c87e38597d5eb3695c432af69273ce1

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 95a489cb..1f402287 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -308,8 +308,6 @@ StorageBase::SaveResult 
LocalStorage::saveLocalFileToStorage(const Authorization
 {
 LOG_INF("Copying " << _jailedFilePath << " to " << _uri.getPath());
 Poco::File(_jailedFilePath).copyTo(_uri.getPath());
-
-
 }
 
 // update its fileinfo object. This is used later to check if someone 
else changed the
@@ -478,8 +476,6 @@ Poco::Timestamp iso8601ToTimestamp(const std::string& 
iso8601Time)
 return timestamp;
 }
 
-
-
 } // anonymous namespace
 
 std::unique_ptr WopiStorage::getWOPIFileInfo(const 
Authorization& auth)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2017-08-22 Thread Pranav Kant
 wsd/Storage.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit da4fe86b829a06c128e637c5fab34f16402d2956
Author: Pranav Kant 
Date:   Tue Aug 22 19:49:20 2017 +0530

wsd: Do not throw when cannot save local file out of jail

Change-Id: Ie155823536694facb8bfcfe49f6386a7fc845689

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index db047aba..c571ecb1 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -320,7 +320,7 @@ StorageBase::SaveResult 
LocalStorage::saveLocalFileToStorage(const Authorization
 {
 LOG_ERR("copyTo(\"" << _jailedFilePath << "\", \"" << _uri.getPath() <<
 "\") failed: " << exc.displayText());
-throw;
+return StorageBase::SaveResult::FAILED;
 }
 
 return StorageBase::SaveResult::OK;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2017-07-06 Thread Miklos Vajna
 wsd/Storage.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 01bf6ab344594402e4797a3d0767d0326b742c88
Author: Miklos Vajna 
Date:   Thu Jul 6 11:17:19 2017 +0200

wsd: use the more effective overload accepting a character in Storage

I guess checking for "{" in parseJSON() happens for performance reasons,
but then it's a good idea to also avoid constructing a temporary string
for no reason.

Change-Id: I285ba0ed615054fc014796f7d8971a2b9783b075

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 52fa5e1d..23a2dfdf 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -412,7 +412,7 @@ void getWOPIValue(const Poco::JSON::Object::Ptr , 
const std::string& key,
 bool parseJSON(const std::string& json, Poco::JSON::Object::Ptr& object)
 {
 bool success = false;
-const auto index = json.find_first_of("{");
+const auto index = json.find_first_of('{');
 if (index != std::string::npos)
 {
 const std::string stringJSON = json.substr(index);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2017-07-06 Thread Aditya Dewan
 wsd/Storage.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c29815f42c8907803960e47de5652602c5955a1d
Author: Aditya Dewan 
Date:   Sun Jul 2 02:00:14 2017 +0530

Assign unique editorId to localhost users

Change-Id: I1c8949fa7acca1b11b35b48629cc20a1170d8caa
Reviewed-on: https://gerrit.libreoffice.org/39442
Reviewed-by: pranavk 
Tested-by: pranavk 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 6f185085..52fa5e1d 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -228,7 +228,7 @@ std::unique_ptr 
LocalStorage::getLocalFileInfo()
 _fileInfo = FileInfo({filename, "localhost", lastModified, size});
 
 // Set automatic userid and username
-return std::unique_ptr(new 
LocalFileInfo({"localhost", std::string("Local Host #") + 
std::to_string(LastLocalStorageId++)}));
+return std::unique_ptr(new 
LocalFileInfo({"localhost" + std::to_string(LastLocalStorageId), "Local Host #" 
+ std::to_string(LastLocalStorageId++)}));
 }
 
 std::string LocalStorage::loadStorageFileToLocal(const std::string& 
/*accessToken*/)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2017-05-19 Thread Pranav Kant
 wsd/Storage.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit aed840ea04ce2e7ae120698f50e78268b542db12
Author: Pranav Kant 
Date:   Fri May 19 21:04:03 2017 +0530

Didn't mean to truncate this string literal

Otherwise getStatus() returns an integer which increments the char*

Change-Id: I189addb60a02de14085b1501c75362b13dcb3ae2

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index e259836b..6e8c1dff 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -464,7 +464,7 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const st
 
 if (response.getStatus() != Poco::Net::HTTPResponse::HTTP_OK)
 {
-LOG_ERR("WOPI::CheckFileInfo failed with " + response.getStatus() 
+ response.getReason());
+LOG_ERR("WOPI::CheckFileInfo failed with " << response.getStatus() 
<< ' ' << response.getReason());
 throw StorageConnectionException("WOPI::CheckFileInfo failed");
 }
 
@@ -590,7 +590,7 @@ std::string WopiStorage::loadStorageFileToLocal(const 
std::string& accessToken)
 
 if (response.getStatus() != Poco::Net::HTTPResponse::HTTP_OK)
 {
-LOG_ERR("WOPI::GetFile failed with " + response.getStatus() + 
response.getReason());
+LOG_ERR("WOPI::GetFile failed with " << response.getStatus() << ' 
' << response.getReason());
 throw StorageConnectionException("WOPI::GetFile failed");
 }
 else // Successful
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2017-05-17 Thread Pranav Kant
 wsd/Storage.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 1717bfbc0b89ad3e4a00a4a65bc8fa1d8b7492b8
Author: Pranav Kant 
Date:   Wed May 17 16:43:24 2017 +0530

Silence -Werror=unused-parameter in non-debug builds

Change-Id: Ib4c91e52d4ac78b3bafe3d078e41c79b50ca87a8

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 521479a2..0c31e53c 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -441,6 +441,7 @@ void setQueryParameter(Poco::URI& uriObject, const 
std::string& key, const std::
 
 void addStorageDebugCookie(Poco::Net::HTTPRequest& request)
 {
+(void) request;
 #if ENABLE_DEBUG
 if (std::getenv("LOOL_STORAGE_COOKIE"))
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2017-04-27 Thread Michael Meeks
 wsd/Storage.cpp |   26 ++
 1 file changed, 26 insertions(+)

New commits:
commit 68b844eb5c3b980355300897fcdf18838d9af7dc
Author: Michael Meeks 
Date:   Thu Apr 27 18:47:35 2017 +0100

Initialize Poco's SSL-ness; the WOPI Storage code still uses it.

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index a125c1d7..f0f525eb 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -31,6 +31,12 @@
 #include 
 #include 
 
+// For residual Poco SSL usage.
+#include 
+#include 
+#include 
+#include 
+
 #include "Auth.hpp"
 #include "Common.hpp"
 #include "Exceptions.hpp"
@@ -98,6 +104,24 @@ void StorageBase::initialize()
 }
 }
 }
+
+#if ENABLE_SSL
+// FIXME: should use our own SSL socket implementation here.
+Poco::Crypto::initializeCrypto();
+Poco::Net::initializeSSL();
+
+// Init client
+Poco::Net::Context::Params sslClientParams;
+
+// TODO: Be more strict and setup SSL key/certs for remove server and us
+sslClientParams.verificationMode = Poco::Net::Context::VERIFY_NONE;
+
+Poco::SharedPtr 
consoleClientHandler = new Poco::Net::KeyConsoleHandler(false);
+Poco::SharedPtr 
invalidClientCertHandler = new Poco::Net::AcceptCertificateHandler(false);
+
+Poco::Net::Context::Ptr sslClientContext = new 
Poco::Net::Context(Poco::Net::Context::CLIENT_USE, sslClientParams);
+Poco::Net::SSLManager::instance().initializeClient(consoleClientHandler, 
invalidClientCertHandler, sslClientContext);
+#endif
 }
 
 bool isLocalhost(const std::string& targetHost)
@@ -283,6 +307,8 @@ namespace {
 inline
 Poco::Net::HTTPClientSession* getHTTPClientSession(const Poco::URI& uri)
 {
+// FIXME: if we're configured for http - we can still use an https:// wopi
+// host surely; of course - the converse is not true / sensible.
 return (LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination())
 ? new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort(),
 
Poco::Net::SSLManager::instance().defaultClientContext())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp wsd/Storage.hpp

2016-12-31 Thread Ashod Nakashian
 wsd/Storage.cpp |   54 ++
 wsd/Storage.hpp |   17 +
 2 files changed, 43 insertions(+), 28 deletions(-)

New commits:
commit aef5af8114b335dd3da840258c009729c73f2511
Author: Ashod Nakashian 
Date:   Thu Dec 22 16:41:05 2016 -0500

wsd: Storage logs updated

Change-Id: Ib3083e833fdc2891ab0c89231bf2ec3e81285803
Reviewed-on: https://gerrit.libreoffice.org/32560
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 9c0f0ef..d7a7119 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -108,14 +108,14 @@ bool isLocalhost(const std::string& targetHost)
 }
 catch (const Poco::Exception& exc)
 {
-Log::warn("Poco::Net::DNS::resolveOne(\"" + targetHost + "\") failed: 
" + exc.displayText());
+LOG_WRN("Poco::Net::DNS::resolveOne(\"" << targetHost << "\") failed: 
" << exc.displayText());
 try
 {
 targetAddress = Poco::Net::IPAddress(targetHost).toString();
 }
 catch (const Poco::Exception& exc1)
 {
-Log::warn("Poco::Net::IPAddress(\"" + targetHost + "\") failed: " 
+ exc1.displayText());
+LOG_WRN("Poco::Net::IPAddress(\"" << targetHost << "\") failed: " 
<< exc1.displayText());
 }
 }
 
@@ -192,7 +192,7 @@ std::atomic LocalStorage::LastLocalStorageId;
 std::unique_ptr 
LocalStorage::getLocalFileInfo(const Poco::URI& uriPublic)
 {
 const auto path = Poco::Path(uriPublic.getPath());
-Log::debug("Getting info for local uri [" + uriPublic.toString() + "], 
path [" + path.toString() + "].");
+LOG_DBG("Getting info for local uri [" << uriPublic.toString() << "], path 
[" << path.toString() << "].");
 
 const auto& filename = path.getFileName();
 const auto file = Poco::File(path);
@@ -213,7 +213,7 @@ std::string LocalStorage::loadStorageFileToLocal()
 const auto filename = Poco::Path(_uri.getPath()).getFileName();
 _jailedFilePath = Poco::Path(rootPath, filename).toString();
 LOG_INF("Public URI [" << _uri.getPath() <<
-"] jailed to [" + _jailedFilePath + "].");
+"] jailed to [" << _jailedFilePath << "].");
 
 // Despite the talk about URIs it seems that _uri is actually just a 
pathname here
 const auto publicFilePath = _uri.getPath();
@@ -227,7 +227,7 @@ std::string LocalStorage::loadStorageFileToLocal()
 if (!Poco::File(_jailedFilePath).exists() && link(publicFilePath.c_str(), 
_jailedFilePath.c_str()) == -1)
 {
 // Failed
-Log::warn("link(\"" + publicFilePath + "\", \"" + _jailedFilePath + 
"\") failed. Will copy.");
+LOG_WRN("link(\"" << publicFilePath << "\", \"" << _jailedFilePath << 
"\") failed. Will copy.");
 }
 
 try
@@ -242,7 +242,7 @@ std::string LocalStorage::loadStorageFileToLocal()
 }
 catch (const Poco::Exception& exc)
 {
-Log::error("copyTo(\"" + publicFilePath + "\", \"" + _jailedFilePath + 
"\") failed: " + exc.displayText());
+LOG_ERR("copyTo(\"" << publicFilePath << "\", \"" << _jailedFilePath 
<< "\") failed: " << exc.displayText());
 throw;
 }
 
@@ -357,7 +357,7 @@ void getWOPIValue(const Poco::JSON::Object::Ptr , 
const std::string& key,
 
 std::unique_ptr WopiStorage::getWOPIFileInfo(const 
Poco::URI& uriPublic)
 {
-LOG_DBG("Getting info for wopi uri [" + uriPublic.toString() + "].");
+LOG_DBG("Getting info for wopi uri [" << uriPublic.toString() << "].");
 
 std::string resMsg;
 const auto startTime = std::chrono::steady_clock::now();
@@ -374,13 +374,17 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Po
 std::istream& rs = psession->receiveResponse(response);
 callDuration = (std::chrono::steady_clock::now() - startTime);
 
-auto logger = Log::trace();
-logger << "WOPI::CheckFileInfo header for URI [" << 
uriPublic.toString() << "]:\n";
-for (auto& pair : response)
+if (Log::traceEnabled())
 {
-logger << '\t' + pair.first + ": " + pair.second << " / ";
+auto logger = Log::trace();
+logger << "WOPI::CheckFileInfo header for URI [" << 
uriPublic.toString() << "]:\n";
+for (const auto& pair : response)
+{
+logger << '\t' << pair.first << ": " << pair.second << " / ";
+}
+
+logger << Log::end;
 }
-logger << Log::end;
 
 Poco::StreamCopier::copyToString(rs, resMsg);
 }
@@ -408,7 +412,7 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Po
 bool disableCopy = false;
 std::string lastModifiedTime;
 
-LOG_DBG("WOPI::CheckFileInfo returned: " + resMsg + ". Call duration: " + 
std::to_string(callDuration.count()) + "s");
+LOG_DBG("WOPI::CheckFileInfo returned: " << resMsg << ". Call duration: " 
<< 

[Libreoffice-commits] online.git: wsd/Storage.cpp

2016-12-23 Thread Pranav Kant
 wsd/Storage.cpp |  165 +++-
 1 file changed, 94 insertions(+), 71 deletions(-)

New commits:
commit ad373c879b85ae4eb684aa88b4a884467e90
Author: Pranav Kant 
Date:   Fri Dec 23 13:23:50 2016 +0530

storage: catch exceptions explicitly when interacting with WOPI host

... and print error in the logs. So that if there is some problem
in the setup and we are not able to interact with WOPI host for some
reason, we print it in the error logs clearly.

Convert to new style logging - LOG_XXX macros.

Change-Id: I53ce4f61136ffd256b0eae8712dc7f22a620e2bf

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 7734ee5..33790b1 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -357,27 +357,40 @@ void getWOPIValue(const Poco::JSON::Object::Ptr , 
const std::string& key,
 
 std::unique_ptr WopiStorage::getWOPIFileInfo(const 
Poco::URI& uriPublic)
 {
-Log::debug("Getting info for wopi uri [" + uriPublic.toString() + "].");
+LOG_DBG("Getting info for wopi uri [" + uriPublic.toString() + "].");
 
+std::string resMsg;
 const auto startTime = std::chrono::steady_clock::now();
-std::unique_ptr 
psession(getHTTPClientSession(uriPublic));
+std::chrono::duration callDuration(0);
+try
+{
+std::unique_ptr 
psession(getHTTPClientSession(uriPublic));
+
+Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
uriPublic.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
+request.set("User-Agent", "LOOLWSD WOPI Agent");
+psession->sendRequest(request);
 
-Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
uriPublic.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
-request.set("User-Agent", "LOOLWSD WOPI Agent");
-psession->sendRequest(request);
+Poco::Net::HTTPResponse response;
+std::istream& rs = psession->receiveResponse(response);
+callDuration = (std::chrono::steady_clock::now() - startTime);
 
-Poco::Net::HTTPResponse response;
+auto logger = Log::trace();
+logger << "WOPI::CheckFileInfo header for URI [" << 
uriPublic.toString() << "]:\n";
+for (auto& pair : response)
+{
+logger << '\t' + pair.first + ": " + pair.second << " / ";
+}
+logger << Log::end;
 
-std::istream& rs = psession->receiveResponse(response);
-auto logger = Log::trace();
-logger << "WOPI::CheckFileInfo header for URI [" << uriPublic.toString() 
<< "]:\n";
-for (auto& pair : response)
+Poco::StreamCopier::copyToString(rs, resMsg);
+}
+catch(const Poco::Exception& pexc)
 {
-logger << '\t' + pair.first + ": " + pair.second << " / ";
+LOG_ERR("Cannot get file info from WOPI storage uri [" + 
uriPublic.toString() + "]. Error: " << pexc.displayText() <<
+(pexc.nested() ? " (" + pexc.nested()->displayText() + ")" : 
""));
+throw;
 }
 
-logger << Log::end;
-
 // Parse the response.
 std::string filename;
 size_t size = 0;
@@ -394,12 +407,8 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Po
 bool disableExport = false;
 bool disableCopy = false;
 std::string lastModifiedTime;
-std::string resMsg;
-Poco::StreamCopier::copyToString(rs, resMsg);
 
-const auto endTime = std::chrono::steady_clock::now();
-const std::chrono::duration callDuration = (endTime - startTime);
-Log::debug("WOPI::CheckFileInfo returned: " + resMsg + ". Call duration: " 
+ std::to_string(callDuration.count()) + "s");
+LOG_DBG("WOPI::CheckFileInfo returned: " + resMsg + ". Call duration: " + 
std::to_string(callDuration.count()) + "s");
 const auto index = resMsg.find_first_of('{');
 if (index != std::string::npos)
 {
@@ -424,7 +433,7 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Po
 getWOPIValue(object, "LastModifiedTime", lastModifiedTime);
 }
 else
-Log::error("WOPI::CheckFileInfo is missing JSON payload");
+LOG_ERR("WOPI::CheckFileInfo is missing JSON payload");
 
 Poco::Timestamp modifiedTime = Poco::Timestamp::fromEpochTime(0);
 if (lastModifiedTime != "")
@@ -457,39 +466,46 @@ std::string WopiStorage::loadStorageFileToLocal()
 // Add it here to get the payload instead of file info.
 Poco::URI uriObject(_uri);
 uriObject.setPath(uriObject.getPath() + "/contents");
-Log::debug("Wopi requesting: " + uriObject.toString());
+LOG_DBG("Wopi requesting: " + uriObject.toString());
 
 const auto startTime = std::chrono::steady_clock::now();
-std::unique_ptr 
psession(getHTTPClientSession(uriObject));
+try
+{
+std::unique_ptr 
psession(getHTTPClientSession(uriObject));
 
-Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
-request.set("User-Agent", "LOOLWSD WOPI 

[Libreoffice-commits] online.git: wsd/Storage.cpp

2016-12-16 Thread Tor Lillqvist
 wsd/Storage.cpp |   29 ++---
 1 file changed, 26 insertions(+), 3 deletions(-)

New commits:
commit 20f8c8d65a8830f6b4ab806b128182f592cce255
Author: Tor Lillqvist 
Date:   Fri Dec 16 15:19:27 2016 +0200

Use also the LastModifiedTime property from the WOPI CheckFileInfo response

If not present, set the FileInfo _modifiedTime to the UNIX epoch.

Change-Id: I2e805d34e426368e5319cb9321159c21fe8ae9e0

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 585711f..d0e1fca 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -15,10 +15,12 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -26,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "Auth.hpp"
 #include "Common.hpp"
@@ -393,6 +396,7 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Po
 bool disablePrint = false;
 bool disableExport = false;
 bool disableCopy = false;
+std::string lastModifiedTime;
 std::string resMsg;
 Poco::StreamCopier::copyToString(rs, resMsg);
 
@@ -420,14 +424,33 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Po
 getWOPIValue(object, "DisablePrint", disablePrint);
 getWOPIValue(object, "DisableExport", disableExport);
 getWOPIValue(object, "DisableCopy", disableCopy);
+getWOPIValue(object, "LastModifiedTime", lastModifiedTime);
 }
 else
 Log::error("WOPI::CheckFileInfo is missing JSON payload");
 
 if (!_fileInfo.isValid())
 {
-// WOPI doesn't support file last modified time.
-_fileInfo = FileInfo({filename, ownerId, Poco::Timestamp(), size});
+Poco::Timestamp modifiedTime = Poco::Timestamp::fromEpochTime(0);
+if (lastModifiedTime != "")
+{
+Poco::DateTime dateTime;
+int timeZoneDifferential;
+bool valid = false;
+try
+{
+
Poco::DateTimeParser::parse(Poco::DateTimeFormat::ISO8601_FRAC_FORMAT, 
lastModifiedTime, dateTime, timeZoneDifferential);
+valid = true;
+}
+catch (const Poco::SyntaxException& exc)
+{
+LOG_WRN("LastModifiedTime property [" + lastModifiedTime + "] 
was invalid format: " << exc.displayText() <<
+(exc.nested() ? " (" + exc.nested()->displayText() + 
")" : ""));
+}
+if (valid)
+modifiedTime = dateTime.timestamp();
+}
+_fileInfo = FileInfo({filename, ownerId, modifiedTime, size});
 }
 
 return std::unique_ptr(new 
WOPIFileInfo({userId, userName, canWrite, postMessageOrigin, hidePrintOption, 
hideSaveOption, hideExportOption, enableOwnerTermination, disablePrint, 
disableExport, disableCopy, callDuration}));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: wsd/Storage.cpp

2016-12-08 Thread Miklos Vajna
 wsd/Storage.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit cb8564b17f7767b56f2a57c8c5a064ad86928fad
Author: Miklos Vajna 
Date:   Thu Dec 8 09:33:24 2016 +0100

Storage: make sure matrix is initialized before read

Change-Id: I967ab34c0f0430900b4be4424fa4493386c96c33

diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 21800ae..a2ca75b 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -283,6 +283,7 @@ Poco::Net::HTTPClientSession* getHTTPClientSession(const 
Poco::URI& uri)
 
 int getLevenshteinDist(const std::string& string1, const std::string& string2) 
{
 int matrix[string1.size() + 1][string2.size() + 1];
+std::memset(matrix, 0, sizeof(matrix[0][0]) * (string1.size() + 1) * 
(string2.size() + 1));
 
 for (size_t i = 0; i < string1.size() + 1; i++)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits