loleaflet/src/control/Toolbar.js | 13 ++++++++- wsd/FileServer.cpp | 54 +++++++++++++++++++-------------------- wsd/FileServer.hpp | 5 ++- 3 files changed, 43 insertions(+), 29 deletions(-)
New commits: commit 594348b6fee74fdcb95f15247562ce485a66350f Author: George Wood <[email protected]> AuthorDate: Tue Jul 24 12:19:52 2018 +0100 Commit: Michael Meeks <[email protected]> CommitDate: Tue Jul 24 12:27:35 2018 +0100 enables debug mode to be turned on from the about screen by pressing d. Also fixes focus issue with map after closing dialog. diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js index 8d1cebcf5..6c7360df9 100644 --- a/loleaflet/src/control/Toolbar.js +++ b/loleaflet/src/control/Toolbar.js @@ -1,3 +1,4 @@ +/* -*- js-indent-level: 8 -*- */ /* * Toolbar handler */ @@ -186,6 +187,7 @@ L.Map.include({ contentCSS: {width: w + 'px'}, buttons: {}, afterOpen: function($vexContent) { + map.enable(false); // Display help according to document opened if (map.getDocType() === 'text') { document.getElementById('text-shortcuts').style.display='block'; @@ -197,7 +199,7 @@ L.Map.include({ document.getElementById('presentation-shortcuts').style.display='block'; } - // Lets transalte + // Lets translate var i, max; var translatableContent = $vexContent.find('h1'); for (i = 0, max = translatableContent.length; i < max; i++) { @@ -225,6 +227,7 @@ L.Map.include({ }, beforeClose: function () { map.focus(); + map.enable(true); } }); }); @@ -240,6 +243,11 @@ L.Map.include({ content.find('#product-string').text(productString.replace('%productName', productName)); var w = window.innerWidth / 2; var map = this; + var handler = function(event) { + if (event.keyCode === 68) { + map._docLayer.toggleTileDebugMode(); + } + }; vex.open({ content: content, showCloseButton: true, @@ -249,6 +257,7 @@ L.Map.include({ buttons: {}, afterOpen: function($vexContent) { map.enable(false); + $(window).bind('keyup.vex', handler); // workaround for https://github.com/HubSpot/vex/issues/43 $('.vex-overlay').css({ 'pointer-events': 'none'}); $('.vex').click(function() { @@ -259,7 +268,9 @@ L.Map.include({ }); }, beforeClose: function () { + $(window).unbind('keyup.vex', handler) map.enable(true); + map.focus(); } }); } commit 73b8da4ab009248badbf041fb2d63a40c3ebad9d Author: George Wood <[email protected]> AuthorDate: Mon Jul 23 13:37:34 2018 +0100 Commit: Michael Meeks <[email protected]> CommitDate: Tue Jul 24 12:27:35 2018 +0100 Cleanup error reporting. diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index 6af1be5d7..6b7ba63bd 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -413,48 +413,43 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M catch (const Poco::Net::NotAuthenticatedException& exc) { LOG_ERR("FileServerRequestHandler::NotAuthenticated: " << exc.displayText()); - - // Unauthorized. - std::ostringstream oss; - oss << "HTTP/1.1 401\r\n" - << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" - << "Content-Length: 0\r\n" - << "WWW-Authenticate: Basic realm=\"online\"\r\n" - << "\r\n"; - socket->send(oss.str()); + sendError(401, request, socket, "", "", "WWW-authenticate: Basic realm=\"online\"\r\n"); } catch (const Poco::FileAccessDeniedException& exc) { LOG_ERR("FileServerRequestHandler: " << exc.displayText()); - - // TODO return some 403 page? - std::ostringstream oss; - oss << "HTTP/1.1 403\r\n" - << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" - << "Content-Length: 0\r\n" - << "\r\n"; - socket->send(oss.str()); + sendError(403, request, socket, "403 - Access denied!", + "You are unable to access"); } catch (const Poco::FileNotFoundException& exc) { LOG_WRN("FileServerRequestHandler: " << exc.displayText()); - Poco::URI requestUri(request.getURI()); - std::string path(requestUri.getPath()); + sendError(404, request, socket, "404 - file not found!", + "There seems to be a problem locating"); + } +} - // 404 not found - std::ostringstream oss; - oss << "HTTP/1.1 404\r\n" - << "Content-Type: text/html charset=UTF-8\r\n" - << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" - << "\r\n" - << "<h1>Error 404 - page not found!</h1>" - << "<p>There appears to be an error locating " << path << ".</p>" +void FileServerRequestHandler::sendError(int errorCode, const Poco::Net::HTTPRequest& request, + const std::shared_ptr<StreamSocket>& socket, + std::string shortMessage, std::string longMessage, + std::string extraHeader) +{ + Poco::URI requestUri(request.getURI()); + std::string path(requestUri.getPath()); + std::ostringstream oss; + oss << "HTTP/1.1 " << errorCode << "\r\n" + << "Content-Type: text/html charset=UTF-8\r\n" + << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" + << extraHeader + << "\r\n"; + if (!shortMessage.empty()) + { + oss << "<h1>Error: " << shortMessage << "</h1>" + << "<p>" << longMessage << " " << path << "</p>" << "<p>Please contact your system administrator.</p>"; - socket->send(oss.str()); } + socket->send(oss.str()); } void FileServerRequestHandler::readDirToHash(const std::string &basePath, const std::string &path) diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp index 8bcc662c7..62647b4c0 100644 --- a/wsd/FileServer.hpp +++ b/wsd/FileServer.hpp @@ -41,7 +41,10 @@ public: static const std::string *getUncompressedFile(const std::string &path); private: - static std::map<std::string, std::pair<std::string, std::string>> FileHash; + static std::map<std::string, std::pair<std::string, std::string>> FileHash; + static void sendError(int errorCode, const Poco::Net::HTTPRequest& request, + const std::shared_ptr<StreamSocket>& socket, std::string shortMessage, + std::string longMessage, std::string extraHeader = ""); }; #endif commit e8235e50c8d1fb2489f5de62dcf609b9fba1eba4 Author: George Wood <[email protected]> AuthorDate: Mon Jul 23 11:28:43 2018 +0100 Commit: Michael Meeks <[email protected]> CommitDate: Tue Jul 24 12:27:35 2018 +0100 A more attractive 404 page. diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index 5f721f920..6af1be5d7 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -440,14 +440,19 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M catch (const Poco::FileNotFoundException& exc) { LOG_WRN("FileServerRequestHandler: " << exc.displayText()); + Poco::URI requestUri(request.getURI()); + std::string path(requestUri.getPath()); // 404 not found std::ostringstream oss; oss << "HTTP/1.1 404\r\n" + << "Content-Type: text/html charset=UTF-8\r\n" << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" - << "Content-Length: 0\r\n" - << "\r\n"; + << "\r\n" + << "<h1>Error 404 - page not found!</h1>" + << "<p>There appears to be an error locating " << path << ".</p>" + << "<p>Please contact your system administrator.</p>"; socket->send(oss.str()); } } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
