[Libreoffice-commits] online.git: common/Authorization.cpp test/WhiteBoxTests.cpp wsd/Storage.cpp
Pranam Lashkari (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jan 22 22:24:09 UTC 2020
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 <lpranam at collabora.com>
AuthorDate: Mon Dec 23 19:15:38 2019 +0530
Commit: Michael Meeks <michael.meeks at collabora.com>
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 <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
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;
}
More information about the Libreoffice-commits
mailing list