[Libreoffice-commits] online.git: test/WhiteBoxTests.cpp wsd/RequestDetails.cpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jun 2 18:02:17 UTC 2020
test/WhiteBoxTests.cpp | 41 +++++++++++++++--------------------------
wsd/RequestDetails.cpp | 4 ++--
2 files changed, 17 insertions(+), 28 deletions(-)
New commits:
commit 1ee57ba1d043df8681793b15f08e3a7359fcccad
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon May 25 07:51:04 2020 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Tue Jun 2 20:01:59 2020 +0200
wsd: proxy: correctly parse single-char fields in the URI
...instead of skipping them.
And add tests to defend the fix.
Change-Id: I8585cc3592841c8ad16d3804dc09a2a3b3a3bb71
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95291
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp
index a97451172..e8290cd2f 100644
--- a/test/WhiteBoxTests.cpp
+++ b/test/WhiteBoxTests.cpp
@@ -940,7 +940,9 @@ void WhiteBoxTests::testRequestDetails_local()
= "http://localhost/nextcloud/apps/richdocuments/proxy.php?req=";
{
- static const std::string URI = "/lool/file%3A%2F%2F%2Fhome%2Fash%2Fprj%2Flo%2Fonline%2Ftest%2Fdata%2Fhello-world.odt/ws/open/open/0";
+ static const std::string URI = "/lool/"
+ "file%3A%2F%2F%2Fhome%2Fash%2Fprj%2Flo%2Fonline%2Ftest%"
+ "2Fdata%2Fhello-world.odt/ws/open/open/0";
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, URI,
Poco::Net::HTTPMessage::HTTP_1_1);
@@ -960,7 +962,7 @@ void WhiteBoxTests::testRequestDetails_local()
LOK_ASSERT_EQUAL(docUri, details.getDocumentURI());
- LOK_ASSERT_EQUAL(static_cast<std::size_t>(5), details.size());
+ LOK_ASSERT_EQUAL(static_cast<std::size_t>(6), details.size());
LOK_ASSERT_EQUAL(std::string("lool"), details[0]);
LOK_ASSERT(details.equals(0, "lool"));
LOK_ASSERT_EQUAL(
@@ -970,18 +972,13 @@ void WhiteBoxTests::testRequestDetails_local()
LOK_ASSERT_EQUAL(std::string("ws"), details[2]);
LOK_ASSERT_EQUAL(std::string("open"), details[3]);
LOK_ASSERT_EQUAL(std::string("open"), details[4]);
+ LOK_ASSERT_EQUAL(std::string("0"), details[5]);
}
{
- static const std::string URI
- = "/lool/"
- "http%3A%2F%2Flocalhost%2Fowncloud%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%"
- "2F165_ocgdpzbkm39u%3Faccess_token%3DODhIXdJdbsVYQoKKCuaYofyzrovxD3MQ%26access_token_"
- "ttl%"
- "3D0%26reuse_cookies%3DXCookieName%253DXCookieValue%253ASuperCookieName%253DBAZINGA/"
- "ws?WOPISrc=http%3A%2F%2Flocalhost%2Fowncloud%2Findex.php%2Fapps%2Frichdocuments%"
- "2Fwopi%"
- "2Ffiles%2F165_ocgdpzbkm39u&compat=/ws/1c99a7bcdbf3209782d7eb38512e6564/write/2";
+ static const std::string URI = "/lool/"
+ "file%3A%2F%2F%2Fhome%2Fash%2Fprj%2Flo%2Fonline%2Ftest%"
+ "2Fdata%2Fhello-world.odt/ws//write/2";
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, URI,
Poco::Net::HTTPMessage::HTTP_1_1);
@@ -997,12 +994,7 @@ void WhiteBoxTests::testRequestDetails_local()
LOK_ASSERT_EQUAL(false, details.isWebSocket());
LOK_ASSERT_EQUAL(true, details.isGet());
- const std::string docUri
- = "http://localhost/owncloud/index.php/apps/richdocuments/wopi/files/"
- "165_ocgdpzbkm39u?access_token=ODhIXdJdbsVYQoKKCuaYofyzrovxD3MQ&access_token_ttl=0&"
- "reuse_cookies=XCookieName%3DXCookieValue%3ASuperCookieName%3DBAZINGA/"
- "ws?WOPISrc=http://localhost/owncloud/index.php/apps/richdocuments/wopi/files/"
- "165_ocgdpzbkm39u&compat=";
+ const std::string docUri = "file:///home/ash/prj/lo/online/test/data/hello-world.odt";
LOK_ASSERT_EQUAL(docUri, details.getDocumentURI());
@@ -1010,16 +1002,12 @@ void WhiteBoxTests::testRequestDetails_local()
LOK_ASSERT_EQUAL(std::string("lool"), details[0]);
LOK_ASSERT(details.equals(0, "lool"));
LOK_ASSERT_EQUAL(
- std::string("http%3A%2F%2Flocalhost%2Fowncloud%2Findex.php%2Fapps%2Frichdocuments%"
- "2Fwopi%2Ffiles%2F165_ocgdpzbkm39u%3Faccess_token%"
- "3DODhIXdJdbsVYQoKKCuaYofyzrovxD3MQ%26access_token_ttl%3D0%26reuse_cookies%"
- "3DXCookieName%253DXCookieValue%253ASuperCookieName%253DBAZINGA/"
- "ws?WOPISrc=http%3A%2F%2Flocalhost%2Fowncloud%2Findex.php%2Fapps%"
- "2Frichdocuments%2Fwopi%2Ffiles%2F165_ocgdpzbkm39u&compat="),
+ std::string(
+ "file%3A%2F%2F%2Fhome%2Fash%2Fprj%2Flo%2Fonline%2Ftest%2Fdata%2Fhello-world.odt"),
details[1]);
LOK_ASSERT_EQUAL(std::string("ws"), details[2]);
- LOK_ASSERT_EQUAL(std::string("1c99a7bcdbf3209782d7eb38512e6564"), details[3]);
- LOK_ASSERT_EQUAL(std::string("write"), details[4]);
+ LOK_ASSERT_EQUAL(std::string("write"), details[3]);
+ LOK_ASSERT_EQUAL(std::string("2"), details[4]);
}
}
@@ -1134,7 +1122,7 @@ void WhiteBoxTests::testRequestDetails()
LOK_ASSERT_EQUAL(docUri, details.getDocumentURI());
- LOK_ASSERT_EQUAL(static_cast<std::size_t>(5), details.size());
+ LOK_ASSERT_EQUAL(static_cast<std::size_t>(6), details.size());
LOK_ASSERT_EQUAL(std::string("lool"), details[0]);
LOK_ASSERT(details.equals(0, "lool"));
LOK_ASSERT_EQUAL(
@@ -1148,6 +1136,7 @@ void WhiteBoxTests::testRequestDetails()
LOK_ASSERT_EQUAL(std::string("ws"), details[2]);
LOK_ASSERT_EQUAL(std::string("1c99a7bcdbf3209782d7eb38512e6564"), details[3]);
LOK_ASSERT_EQUAL(std::string("write"), details[4]);
+ LOK_ASSERT_EQUAL(std::string("2"), details[5]);
}
}
diff --git a/wsd/RequestDetails.cpp b/wsd/RequestDetails.cpp
index b97f0fdff..ce8e51bd1 100644
--- a/wsd/RequestDetails.cpp
+++ b/wsd/RequestDetails.cpp
@@ -63,12 +63,12 @@ RequestDetails::RequestDetails(Poco::Net::HTTPRequest &request, const std::strin
}
}
- if (i - start > 1) // ignore empty
+ if (i - start > 0) // ignore empty
tokens.emplace_back(start, i - start);
start = i + 1;
}
}
- if (i - start > 1) // ignore empty
+ if (i - start > 0) // ignore empty
tokens.emplace_back(start, i - start);
_pathSegs = StringVector(_uriString, std::move(tokens));
}
More information about the Libreoffice-commits
mailing list