Commit graph

138 commits

Author SHA1 Message Date
Miklos Vajna
547f9ea731 Rework StringVector to have a single underlying string
This is meant to reduce lots of small allocations and instead have
pointers into the single string for the various tokens instead.

This has a few requirements, though:

1) It's no longer OK to modify the tokens, changing their length would
invalidate the start/length of other tokens. Rework
DocumentBroker::load() to avoid such mutation.

2) The iterators no longer expose zero-terminated strings, so
Poco::cat() doesn't work anymore: add an own cat() instead and use that
in e.g. ChildSession. The own cat() has the benefit that it won't read
past the end of the array if the begin index is out of bounds to add
more safety.

(This nicely works towards killing Poco usage in general.)

3) If zero-terminated strings for all individual tokens is needed, a
copy has to be made, as done in spawnProcess().

(For all of these requirements, the build fails if there are problems.)

Change-Id: Iea40e4400e630b2d669f5c72aea85cb40edf9a2c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89711
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-02-28 18:31:37 +01:00
Miklos Vajna
b8bd1990aa Rework LOOLProtocol::tokenize() to return a StringVector object
The bulk of this commit just changes std::vector<std::string> to
StringVector when we deal with tokens from a websocket message.

The less boring part of it is the new StringVector class, which is a
wrapper around std::vector<std::string>, and provides the same API,
except that operator[] returns a string, not a string&, and this allows
returning an empty string in case that prevents reading past the end of
the underlying array.

This means in case client code forgets to check size() before invoking
operator[], we don't crash. (See the ~3 previous commits which fixed
such crashes.)

Later the ctor could be changed to take a single underlying string to
avoid lots of tiny allocations, that's not yet done in this commit.

Change-Id: I8a6082143a8ac0b65824f574b32104d7889c184f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89687
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-02-28 16:07:56 +01:00
Ashod Nakashian
ddd3108767 wsd: logging improvements and formatting
Some multi-line log entries were missing
because we didn't flush.

Change-Id: Iabf9e6f1ffee707ff51b831a12c7990f35bb7913
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89196
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-02-23 21:46:55 +01:00
Mike Kaganski
098c0a5752 Check that absolute URI is passed to addWopiProof
Change-Id: I28385f330064645dc2c30a3c3180df2a297b2e53
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89021
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-02-19 15:35:26 +01:00
Mike Kaganski
c55afd2575 Don't drop trace log on error
Change-Id: I4839b02f01156e433de095395f1cb034e9aa9745
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88716
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-02-18 17:30:35 +01:00
Mike Kaganski
99f0480460 Proof: URI must be absolute and converted to uppercase
Also access token is already passes decoded to GetProofHeaders,
so don't decode it second time.

Change-Id: I7c4404462a9dd9f53e4e82684b1fcae1aeecee73
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88736
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-02-18 17:30:19 +01:00
Ashod Nakashian
da0f3a950a wsd: per-user cookies
Cookies may be passed from the client to the storage,
in which case each user may have its own unique set
of cookies. These cookies are now preserved in the
ClientSession, which is per connection, and are then
passed to the storage to use when communicating with
the WOPI-like backend.

(cherry picked from commit 6022faf3cc9b622b490c3f8ca91efbff8e542414)

Change-Id: Ic2e13fa541a5ee01b7383939bbbf7d46ea75684b
2020-01-28 18:10:14 +01:00
Pranam Lashkari
a019c93d90 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@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-01-22 23:23:51 +01:00
Michael Meeks
0599db3576 copyFile: de-poco-ize and handle EINTR and short writes.
Change-Id: I2046881c786a9f31f45c53f282de9ddd9a9cebcf
2020-01-21 15:07:54 +00:00
Miklos Vajna
2c9e1319d9 Fix a -Werror,-Wrange-loop-analysis warning
wsd/Storage.cpp:451:21: error: loop variable 'header' of type 'const std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >' creates a copy from type 'const std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >' [-Werror,-Wrange-loop-analysis]

Change-Id: I90a57333b0807f3457d5b1082097426a3bf9678d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87055
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-01-20 10:08:09 +01:00
Ashod Nakashian
af58a9e761 wsd: whitespace
Change-Id: Id8185dab66f95676be2db8908d0f12c5284174fb
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86321
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2020-01-07 11:47:04 +01:00
Miklos Vajna
d0fee8c6ad These can be made const
Change-Id: I952a7566176bda727f8c2e9618d41bfb7bb1240f
Reviewed-on: https://gerrit.libreoffice.org/85197
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-12-16 09:24:08 +01:00
Ashod Nakashian
86a80a4cca wsd: handle http forbidden response from wopi put
Change-Id: I597e949cd1bea612400d623f30ea260036253e89
Reviewed-on: https://gerrit.libreoffice.org/84360
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-12-03 16:02:16 +01:00
Tor Lillqvist
29b603a34f Fix build for MOBILEAPP
No Admin.hpp needed (which would cause a conflicting definitions of a
class called Document when compiling Kit.cpp).

No locks "supported" in the way the code expects for WOPI-like things.

Change-Id: Ie43311af054f2940576ce9b2b13520f24887628e
Reviewed-on: https://gerrit.libreoffice.org/84018
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2019-11-29 12:12:30 +01:00
Michael Meeks
0d97efbfcc locking: renew lock after timeout.
Change-Id: I6191ee34239b978292aeb6795be74312a954e240
2019-11-27 19:17:27 +00:00
mert
8ca7391f05 Added an option to override watermark texts
in loolwsd.xml. If set, watermarks will be the same
as entered for all the views instead of per view
watermarks sent in CheckFileInfo

Change-Id: I0943520423abc2567f44920f8679057b3cfbf01f
Reviewed-on: https://gerrit.libreoffice.org/83666
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-11-25 13:10:05 +01:00
Gabriel Masei
2164f5207c Add REST endpoint for admin metrics.
Change-Id: I701485631931334d27594c4907cb770f9888e5bf
Reviewed-on: https://gerrit.libreoffice.org/82492
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-11-25 13:06:01 +01:00
Michael Meeks
3dbee6745b Log an error, and return failure on unhandled responses to save.
Change-Id: Ib241a88e53a11276b3837f49ea6d964d706919a4
2019-11-21 18:44:38 +00:00
Michael Meeks
994f8993d9 Add proof for locking calls (and mend the build).
Change-Id: I4cbaf682a14316750a676a14d986ecf59045581d
2019-11-21 14:34:36 +00:00
Michael Meeks
cabd30a1b8 Initial wopi-like locking implementation.
Change-Id: I3e16cfc40dbd29a24016b09e62afc9ec488300c7
2019-11-21 14:24:58 +00:00
Mike Kaganski
a986aabeb1 Initial implementation of proof-key
Change-Id: I7ab79218ca2af268dd4573cb64c6353dc71b5f03
Reviewed-on: https://gerrit.libreoffice.org/82232
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
2019-11-21 12:56:53 +01:00
Michael Meeks
d4b71cb73d Share code for reuse_cookies handling.
Change-Id: I9e4d66f14b46284c8d4f33173f028f0bcea34be2
2019-11-20 15:41:06 +00:00
Michael Meeks
68d81dae49 Read and store SupportsLocks property.
Change-Id: Ic405dfa5f6e759937094835f41787fa2cbe29f49
2019-11-20 15:41:06 +00:00
Lionel Elie Mamane
1fbf148f09 modernise TLS setup
Some machines (e.g. Debian 10) by default will refuse DH groups
shorter than 2048 bits.

Change-Id: I3505bc392775d7c92069a8f705f574338666a8e7
Reviewed-on: https://gerrit.libreoffice.org/83300
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2019-11-20 13:48:07 +01:00
Ashod Nakashian
8c4edb5087 Reuse cookies from the browser
Reviewed-on: https://gerrit.libreoffice.org/78195
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
(cherry picked from commit 8deecf4ea6966c059458bdc71e365be426238e09)

Change-Id: I96bbdd3e71bc9d0ecfddea7debc0ebcc303a49ae
Reviewed-on: https://gerrit.libreoffice.org/81558
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-10-28 10:45:14 +01:00
merttumer
1e63a02be4 Added reuse cookie option for wopi client
Signed-off-by: merttumer <mert.tumer@collabora.com>
(cherry picked from commit 9b8aa96a18ce2eda11b5e51b2df5bb0d8cd822d2)

Reviewed-on: https://gerrit.libreoffice.org/78194
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
(cherry picked from commit 3ab7e500d83ed814a2d1ba1043df828b1b6c865f)

Change-Id: I61577189f461ef94523af13b3734d84a20a11222
Reviewed-on: https://gerrit.libreoffice.org/81557
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-10-28 10:45:04 +01:00
Michael Meeks
2f534842cd fallback to ssl.enable for storage.ssl.enable for back-compat.
Implements TODO from 5d57f5aef3

Change-Id: I32bc4cc2b875a4ec44bc8d254af7b03c8016e887
2019-10-25 10:57:24 +01:00
Andras Timar
1dc6bd9dfb typo fix: comuncation -> communication
Change-Id: Iefe88baa6ac5d2201dc3fb4e4604498898a30ba6
2019-10-09 14:23:35 +02:00
Andras Timar
df0dd16445 Fix the SSL termination case
Follow up commit of d597f22dac

Change-Id: I41ca46a93f4b82c6fea6489dbd4c0e3390ba652f
2019-10-09 12:17:33 +02:00
Gabriel Masei
d597f22dac Add minimal TLS support for communication with storage
Change-Id: Iafd9946a4240063c07f5c519b8af30b52e23d3e8
Reviewed-on: https://gerrit.libreoffice.org/80373
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-10-08 18:57:36 +02:00
Ashod Nakashian
9c21408112 wsd: close iconv after converting
Change-Id: Idc0894362d0839449f7b1e1ae8c52c3ddb1dff45
Reviewed-on: https://gerrit.libreoffice.org/79352
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-09-22 20:25:04 +02:00
Tor Lillqvist
80ddb46392 Fix portability problems after 22f1656e08
It is std::chrono::system_clock that has to_time_t.
std::chrono::steady_clock does not have to_time_t.

std::chrono::high_resolution_clock is either the same as system_clock
(in libstdc++, on Linux) or steady_clock (libc++, on iOS).

(This change does not fix the actual bugs in the code, just makes it
compile for iOS. The new ISO8601 fractional time code is not unit
tested at the moment. The testTime() function is not part of the test
suite in WhiteBoxTests.cpp. If it is made part of it, it reveals
problems in the code (and/or in the unit test code).)

Change-Id: Id33342bc8b26465632f3d21d6ec2f3c975ae3681
Reviewed-on: https://gerrit.libreoffice.org/78550
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-09-03 13:50:27 +02:00
Ashod Nakashian
3dcc68e6f1 Pass Extended Data in Action_Save from the client to the WOPI host
Clients often need to communicate with their wopi hosts when
invoking Action_Save to provide more context when storing the
document in question. Action_Save now support passing arbitrary
string as ExtendedData entry that can be used by client to
pass any context or otherwise flags to the WOPI host, which
will receive it via the X-LOOL-WOPI-ExtendedData custom header.

See reference.html for more details.

Change-Id: I1814d1f3d984a553ffa60cec13d23b014ba59eb3
Reviewed-on: https://gerrit.libreoffice.org/74135
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2019-09-03 01:53:12 -04:00
Ashod Nakashian
36b5109d21 wsd: cosmetic formatting
Change-Id: I552b2468432ce6ed52c50e22b6f19d8055c5dbb1
2019-09-03 01:53:12 -04:00
DarkByt31
22f1656e08 tdf#107038 Poco::Timestamp replacement with std::chrono
Added functions to get file timestamp and to convert
chrono timestamp in ISO8601 fraction format and some
test cases.

Change-Id: I58961a31f7262b367cff9f33cffdec7571a2f8f7
2019-09-02 15:50:37 -04:00
Ashod Nakashian
226c2fe71c wsd: unify anonymization flags under one
This simplifies the anonymization configuration
as virtually always they are all either enabled
together, or not at all.

Change-Id: I6fe60f5287fc5d71cd7a6ac3268eac67e5e6e9fb
Reviewed-on: https://gerrit.libreoffice.org/70033
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/71090
2019-08-17 03:42:19 +02:00
Henry Castro
760864870f wsd: introduce "TemplateSource" WOPI property
Change-Id: I9df1d5d0d4be7fe10ee15c40c36195c86ccf857e
Reviewed-on: https://gerrit.libreoffice.org/76190
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2019-07-24 12:10:15 +02:00
Jan Holesovsky
3c45a0abab Introduce Download_As postmessage & a CheckFileInfo entry to enables that.
The Download_As is emitted when the user chooses 'Print' or 'Show
slideshow' or 'Download As [some type'] and the integration indicates
via DownloadAsPostMessage in the CheckFileInfo that it wants to handle
the downloading of pdf for printing or svg for slideshows or experted
document.

This is particularly useful in situations when the integration cannot
rely on browser's support for downloading like in mobile apps that use
the Online in a WebView.

Change-Id: Iefdf214937c0c0dafd7462340a1c5e88df94e716
Reviewed-on: https://gerrit.libreoffice.org/73449
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2019-06-04 14:54:36 +02:00
merttumer
0dbf9bcf27 Added RenameFile Support for WOPI
This patch concerns rename file operation when the integration
supports it
Signed-off-by: merttumer <mert.tumer@collabora.com>

Change-Id: Ibb4f615b91dda2491bfcd4d4738198d69eca4e6f
Reviewed-on: https://gerrit.libreoffice.org/71587
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Signed-off-by: merttumer <mert.tumer@collabora.com>
2019-05-13 22:29:40 +03:00
Jan Holesovsky
f76b36193d android: #if(n)def MOBILEAPP -> #if (!)MOBILEAPP for better reliability.
Change-Id: I5f9c9420b6c83601db1c8fdba4ae5a10b17b2107
2019-02-12 12:20:11 +01:00
Jan Holesovsky
f2fcf49b3b checkfileinfo: TemplateSaveAs to trigger PutRelativeFile...
...as the first thing after load.

Change-Id: I8c372ebe0228682d4f1d7cb89fe80ea59455c5bb
2018-12-20 12:40:35 +01:00
Szymon Kłos
e2b464b237 WOPI: Extend HideUserList property
Added "mobile" | "tablet" | "desktop" values support.
"," is used as a delimiter

Change-Id: Idfa4670f229725dfedfb2d55b622263cbcfd6fc2
2018-12-15 14:55:35 +01:00
Szymon Kłos
f626618882 WOPI: Added HideUserList to CheckFileInfo
Change-Id: Id0f9597d52fb339162a9ce4f622aa39694d1a25e
2018-12-15 14:50:30 +01:00
Samuel Mehrbrodt
2e9af9da16 Add custom http header when saving before document is cleaned up from memory
Change-Id: I3ac417d83a79a665ae6575097835542f43d40cef
Reviewed-on: https://gerrit.libreoffice.org/64499
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2018-12-05 11:50:59 +01:00
Miklos Vajna
ae3fec55d4 StorageBase::FileInfo: make members private
Which shows that the _size member was unused.

Change-Id: Ic6e74659050b86cd9057971ec21623fad75f0c39
2018-11-29 08:43:02 +01:00
Tor Lillqvist
b9694c305b Adapt after ed9c756c9e
Change-Id: Ide7ab1544039d11d478c30cc8fd9c09b1d1f6894
2018-11-28 12:41:43 +02:00
Miklos Vajna
ed9c756c9e StorageBase: make members private
Rename getUri() to getUriString(), so getUri() can expose a const
reference to _uri.

Change-Id: I0cd0faf08ba31bdf6a605be657e7ca2cf5fb33a6
2018-11-28 09:07:35 +01:00
Tor Lillqvist
34eb014e2b Drop the spaces from "Local Host #0" xauthor parameter
That "name" will be passed as the xauthor parameter in a message like:

child-01b9 load url=file:///.../x.odt?permission=edit jail=file:///.../x.odt xjail=file:///.../x.odt authorid=localhost1 xauthorid=localhost1 author=Local%20Host%20#1 xauthor=Local Host #1 readonly=0 lang=en-US

and that is parsed into space-separated tokens. Which leads to warning
messages like:

WRN  Unexpected doc options token [Host]. Skipping.| common/Session.cpp:94
WRN  Unexpected doc options token [#1]. Skipping.| common/Session.cpp:94

So use "LocalHost#0" etc instead.

Change-Id: I01ce8c4fb8309a7a9d3395e4fd874e469475d44c
2018-11-06 23:16:43 +02:00
Henry Castro
665863b50a wsd: wopi: introduce a "EnableShare" entry in the CheckFileInfo
Change-Id: Ia47d7e8f5c8cd8ae1eb314467c664b27b50e7fd3
2018-10-31 18:12:07 +01:00
Henry Castro
8643128180 wsd: wopi: introduce a "EnableInsertRemoteImage" entry in the CheckFileInfo
Change-Id: I66e5f12fbd49509ce8e82ea07ae7a2cc75ddc665
2018-10-31 18:12:07 +01:00