wsd/RequestDetails.cpp |   22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

New commits:
commit 3309d597e9c165a0d80e3a2d6849e1ad31ee3257
Author:     Ashod Nakashian <[email protected]>
AuthorDate: Mon May 18 17:42:20 2020 -0400
Commit:     Jan Holesovsky <[email protected]>
CommitDate: Tue May 19 15:17:12 2020 +0200

    wsd: correctly parse wopi URLs in RequestDetails
    
    Wopi URLs have their own /ws marker, which
    is confused with the one used with the RichProxy.
    Without correctly identifying the one belonging
    to the original URL and the one for the Proxy
    logic, we end up mis-parsing and Wopi documents
    don't load via RichProxy.
    
    Change-Id: I7874e2aed9d5ac7de734f3db01f2820c5bbc5098
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94470
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Jan Holesovsky <[email protected]>

diff --git a/wsd/RequestDetails.cpp b/wsd/RequestDetails.cpp
index f2127b83f..5249b8470 100644
--- a/wsd/RequestDetails.cpp
+++ b/wsd/RequestDetails.cpp
@@ -39,13 +39,29 @@ RequestDetails::RequestDetails(Poco::Net::HTTPRequest 
&request)
 #endif
 
     std::vector<StringToken> tokens;
-    if (_uriString.size() > 0)
+    const auto len = _uriString.size();
+    if (len > 0)
     {
-        size_t i, start;
-        for (i = start = 0; i < _uriString.size(); ++i)
+        std::size_t i, start;
+        for (i = start = 0; i < len; ++i)
         {
             if (_uriString[i] == '/' || _uriString[i] == '?')
             {
+                if (_uriString[i] == '/')
+                {
+                    // Wopi also uses /ws? in the URL, which
+                    // we need to avoid confusing with the
+                    // trailing /ws/<command>/<sessionId>/<serial>.
+                    // E.g. /ws?WOPISrc=
+                    if (i + 3 < len && _uriString[i + 1] == 'w' && 
_uriString[i + 2] == 's'
+                        && _uriString[i + 3] == '?')
+                    {
+                        // Skip over '/ws?'
+                        i += 4;
+                        continue;
+                    }
+                }
+
                 if (i - start > 1) // ignore empty
                     tokens.emplace_back(start, i - start);
                 start = i + 1;
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to