common/Authorization.cpp | 6 +++++- test/WhiteBoxTests.cpp | 4 ++++ wsd/Storage.cpp | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-)
New commits: commit a019c93d90e08aceb8b645e6cf963e6256fb38c6 Author: Pranam Lashkari <[email protected]> AuthorDate: Mon Dec 23 19:15:38 2019 +0530 Commit: Michael Meeks <[email protected]> CommitDate: Wed Jan 22 23:23:51 2020 +0100 Resolved: Server crash when link opened in new tab When trying to open a link normally from help->Online help nothing happens but the popup is closed. When trying to open a like forcefully in new tab from help->online help it crashes the server. Change-Id: I7e0944ebe521002625a84e155e379ed7e25d2309 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/85466 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Meeks <[email protected]> diff --git a/common/Authorization.cpp b/common/Authorization.cpp index dce34abb0..138f98889 100644 --- a/common/Authorization.cpp +++ b/common/Authorization.cpp @@ -11,6 +11,8 @@ #include "Authorization.hpp" #include "Protocol.hpp" +#include "Log.hpp" +#include <Exceptions.hpp> #include <cstdlib> #include <cassert> @@ -77,7 +79,9 @@ void Authorization::authorizeRequest(Poco::Net::HTTPRequest& request) const break; } default: - assert(false); + // assert(false); + throw BadRequestException("Invalid HTTP request type"); + break; } } diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp index 9fc452622..9ccb733ec 100644 --- a/test/WhiteBoxTests.cpp +++ b/test/WhiteBoxTests.cpp @@ -634,6 +634,10 @@ void WhiteBoxTests::testAuthorization() auth5.authorizeRequest(req5); CPPUNIT_ASSERT_EQUAL(std::string("Basic huh=="), req5.get("Authorization")); CPPUNIT_ASSERT_EQUAL(std::string("else"), req5.get("X-Something-More")); + + Authorization auth6(Authorization::Type::None, "Authorization: basic huh=="); + Poco::Net::HTTPRequest req6; + CPPUNIT_ASSERT_THROW(auth6.authorizeRequest(req6), BadRequestException); } void WhiteBoxTests::testJson() diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp index 8c8a8ddd8..ab2ad71c6 100644 --- a/wsd/Storage.cpp +++ b/wsd/Storage.cpp @@ -550,6 +550,10 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au pexc.displayText() << (pexc.nested() ? " (" + pexc.nested()->displayText() + ")" : "")); throw; } + catch (const BadRequestException& exc) + { + LOG_ERR("Cannot get file info from WOPI storage uri [" << uriAnonym << "]. Error: Failed HTPP request authorization"); + } // Parse the response. std::string filename; @@ -770,6 +774,10 @@ bool WopiStorage::updateLockState(const Authorization &auth, LockContext &lockCt LOG_ERR("Cannot " << wopiLog << " uri [" << uriAnonym << "]. Error: " << pexc.displayText() << (pexc.nested() ? " (" + pexc.nested()->displayText() + ")" : "")); } + catch (const BadRequestException& exc) + { + LOG_ERR("Cannot " << wopiLog << " uri [" << uriAnonym << "]. Error: Failed HTPP request authorization"); + } return false; } @@ -860,6 +868,10 @@ std::string WopiStorage::loadStorageFileToLocal(const Authorization& auth, LockC pexc.displayText() << (pexc.nested() ? " (" + pexc.nested()->displayText() + ")" : "")); throw; } + catch (const BadRequestException& exc) + { + LOG_ERR("Cannot load document from WOPI storage uri [" + uriAnonym + "]. Error: Failed HTPP request authorization"); + } return ""; } @@ -1086,6 +1098,10 @@ StorageBase::SaveResult WopiStorage::saveLocalFileToStorage(const Authorization& pexc.displayText() << (pexc.nested() ? " (" + pexc.nested()->displayText() + ")" : "")); saveResult.setResult(StorageBase::SaveResult::FAILED); } + catch (const BadRequestException& exc) + { + LOG_ERR("Cannot save file to WOPI storage uri [" + uriAnonym + "]. Error: Failed HTPP request authorization"); + } return saveResult; } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
