Commit graph

1968 commits

Author SHA1 Message Date
Michael Meeks
81ea2266dd prevent division by zero
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ibce3908b4d2c849548bece4e5819aa74dc1992d2
2021-10-25 17:00:02 +01:00
Hugo Peixoto
b2abb5e4aa Use tokens.equals() instead of tokens[] ==
This prevents additional strings from being allocated.

Signed-off-by: Hugo Peixoto <hugo.peixoto@gmail.com>
Change-Id: I84b1e5cf4d11bf8512febe068b3097770b63dc5c
2021-10-21 13:36:57 +02:00
Pranam Lashkari
f88a38a4e7 LOK: unifying the Freemium and uno command hiding APIs part 2
* replace vector with unordered_set
* avoid sending multiple blocking messages

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I2f714e4f2797ade4ac9d5b4f824855bba31031c4
2021-10-21 12:28:13 +03:00
Pranam Lashkari
88601440d0 introduce way to hide/restrict uno commands
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I1225190a67f726832e5b38a7c3f690b51c1385f3
2021-10-21 12:28:13 +03:00
Pranam Lashkari
f02a0a1447 freemium: renamed Freemium namespace to CommandControl
also renamed freemium files accordingly

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Id33b8a1d1a2a8725bfa6e7b7c562430ea126993c
2021-10-21 12:28:13 +03:00
Hugo Peixoto
7bf0ead625 Optimize startsWith calls on StringVector elements
There was a pattern of calling Util::startsWith on StringVector
elements:

- Util::startsWith(tokens[0], "boo")
- Util::startsWith(tokens.getParam(token), "boo")

These two expressions would cause a new string to be allocated and
immediately released. To optimize this, a StringVector::startsWith
method is introduced.

This method works by calling compare directly on the underlying
StringVector string, avoiding creating a temporary string.

Signed-off-by: Hugo Peixoto <hugo.peixoto@gmail.com>
Change-Id: I6f27d5bb13783f39c7d4ce0644a11e57b0071244
2021-10-15 13:58:26 +02:00
Pedro Pinto Silva
352d1d1f40 Allow one more url source for images
By adding this img-src to the content-security-policy it
makes possible updating images from a dialog without requiring
updating Collabora Online

Signed-off-by: Pedro Pinto Silva <pedro.silva@collabora.com>
Change-Id: I3ca8934c3e6eb0ee78a36a483f45eaf5649c84d5
2021-10-14 19:15:07 +01:00
Mert Tumer
73ea638d1d Include X-WOPI-Lock header to rename
bug is described here: #3208
Missing Lock header according to the wopi specs on rename
operation

Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: I6c73f4f1a0a057935a6885cea274ce66c73365d4
2021-10-13 09:17:42 -04:00
Pranam Lashkari
8dd0b1e2db make theme specifying possible through richdocuments
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I3e6e837464069330975cb377ec0126c5d61477ef
2021-10-11 19:45:20 +05:30
Michael Meeks
b043b6213d Move LOOLWebSocket into test/ - where it can be slowly removed.
Change-Id: I388690261d323377648a1502b927e73f862ad802
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-10-11 13:40:20 +01:00
Michael Meeks
a2055d2023 Move StressSocketHandler into Replay.hpp and share with wsd's fuzzing.
Change-Id: I01e0fd0b666651101055b1e78ec6c10e721d114b
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-10-11 13:40:20 +01:00
Michael Meeks
2cf4466d56 trace: hard filter out tileprocessed.
This makes up most of the trace, and we have to simulate it anyway.

Change-Id: I3820e1d2281e696c119edb9ce989fda5ca4170e6
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-10-11 13:40:20 +01:00
Ashod Nakashian
88d5491108 wsd: allow shutting down during startup
During startup we wait for extended time until
a child process is up and running. In case this
takes a long time, or indeed if forking permanently
fails, we simply don't respond to shutdown requests.

This patch makes it possible to wait for about 20
seconds at a time for a child. This way on average
we will exit the process within about 10 seconds,
assuming we are blocked waiting for a child that
will never spawn.

Change-Id: I4409cbc60aa3c7bd30970d4638c820bc581b65ba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 6ed8b4bb1a6532d947a6bb00f936183767b54a80)
2021-10-06 12:28:06 -04:00
Ashod Nakashian
31913d56c2 wsd: avoid misbehaving library cleanup
We cleanup all the relevant objects and instances
before exiting the wsd process, however some libraries
may still misbehave and deadlock during this final
cleanup stage. Notably, Poco has been observed to
deadlock during cleaning up the SSL context static
instance (used for the singleton) by waiting on
its internal mutex indefinitely.

Here we exit forcefully after cleaning up.

Change-Id: I76621c1de7f9a4ff918624b3019b9869c08787c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit f776d87cf595bab084e53202777251a38e482147)
2021-10-06 12:28:06 -04:00
Ashod Nakashian
40e884d6e8 wsd: log discovery.xml response at trace level
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit f3cd2fbe735cad064bb0942382e6fa6608ddcb7a)

Change-Id: Iff51a3aca22837bb1f992ec2b64a1dc9ed7adf64
2021-10-06 12:28:06 -04:00
Michael Meeks
7ecf145707 WaE: avoid reference to temporary std::string.
Change-Id: Id13b3e3986db9f1c6fb66eb8d3c3f3e4942e3e06
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-10-04 10:08:58 +02:00
Miklos Vajna
df30e0e921 wsd: fix crash-on-shutdown in LOOLWSD::doHousekeeping()
wsd/LOOLWSD.cpp:1996:28: runtime error: member call on null pointer of type 'SocketPoll'
    #0 0xcd8799 in LOOLWSD::doHousekeeping() wsd/LOOLWSD.cpp:1996:28

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I3f5f8ad0d8a09a0f4244a32897c59d8a772a8d17
2021-09-30 09:37:18 +02:00
Ashod Nakashian
6dec522a65 wsd: sanitizeURI from to RequestDetails
Change-Id: I8693bd6a36be4c67b62be4b5a997dd227460fbd1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-09-26 17:02:01 -04:00
Ashod Nakashian
965e5cb37d wsd: verify that the last-editing-session can save
The last-editing-session could still be valid, but
waiting disconnection, in which case the kit might
have already discarded it, and so saving would
fail (silently, and thereby leaving docbroker
waiting for the save response).

To avoid this, we always validate the
last-editing-session before using, and not just
when setting it.

Change-Id: I60cd219d8e5a9945396110c8f8d194e87f81afba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit e1fc6adbfef7ee0678c7a563fd6142c32f2da4a6)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
b82b18e8c9 wsd: autosave using the last editing session
Change-Id: I556b7b49b2d1abc0e61ea7ecaa8e5f9406c408f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit b3738719a3b7301688faecfd721a97180eab0020)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
ff1ff12663 wsd: each view handles its own url params
Change-Id: I0c6b9b86c970b1f45e7fa34d030f08c6f256d082
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit d4aa0a0f73eef5a90a14a2297f3050c1dba95a2d)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
d395f521df wsd: log stopping-although-modified as warning
This log entry can be misleading on its own.
When shutting down, the modified flag is not reset,
and that in itself is not a cause for concern.
So this log entry is seen much more often than we
expect. If we truely fail to save/upload, there
will be other errors that will be the tell-tale
signs of a serious issue. So it's reasonable to
downgrade this error to a warning (and watch for
other errors).

Change-Id: Ic879c3fbac887ed5b64bdd1a31aa38bcfd863850
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 7db86b3eb2cdc2a44023e7b7491e1ee202146ef5)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
2b95acb153 wsd: close the upload socket if exit-save
When we are uploading before exit we don't
want the upload socket to linger, because
that would keep the SocketPoll alive for
longer than necessary, holding up the DocBroker.
Instead, we flag the socket for closure, right
after that single request, via HTTP headers.

This allows for very fast unloading of the
DocBroker right after uploading.

Change-Id: I926763383093d2d2dfb10ed41293b1f5d54d090b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 4e132606d1849f82991c46d641c50794d632233c)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
c4fb58df61 wsd: allow new views while unloading
Unloading duration depends on the time to save
and upload the document, during which a new view
might be opened. We now allow aborting the unloading
and resume reusing the document as-is.

Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 8f299eb2cdfe0ef869a8c90fbc602a93ba2fcb73)

Change-Id: I7bc485177929c0d1c9ef12b02672db493ac402c9
2021-09-26 17:02:01 -04:00
Andras Timar
0b1f5f6def prevent division by zero
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I9f9523336ddcbe24906787cfc3210f3471768ea8
2021-09-20 09:06:12 -04:00
Mert Tumer
b12d91de67 renamefile: Respond with reload instead
This way it will reload the document without getting
additional errors like "this is embaressing.."
and not timed out on large files due to retrying for a limited
time.

Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: Ied341200ca21e1b7243daaf62813bc9ed69fecd3
2021-09-17 15:26:15 +03:00
Michael Meeks
930f8e2ca7 Export traces with offset timestamps to assist editing.
Change-Id: Ia9354826fb454e77ad6d2cf3714e43e6e3d06d26
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-09-16 09:06:16 +01:00
Ashod Nakashian
0e6a8cbfae wsd: improved dehexifying of URLs
Change-Id: Ib51e2e61432a7ac634d5b8577f75b57507b0ad60
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 90516342d154434c3a7ad3d245b00a16b8bb5716)
2021-09-13 09:40:09 -04:00
Ashod Nakashian
a7a204f16e wsd: configuration setting to control embedded-url hexifying
Change-Id: I7ed65af7341aa7dec3c9ad8d5cd503c34c355571
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 8f4316b45b1aad7a041e8b02d92e5ef10d63b2b3)
2021-09-13 09:40:09 -04:00
Ashod Nakashian
e363273e22 leaflet: support hexifying the body of the lool URI
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit cfa7972289e9c71b56c81722aedc14189f842475)

Change-Id: Iebf214a1bba76dd44fe2c160a0749675aa5b140a
2021-09-13 09:40:09 -04:00
Ashod Nakashian
6ae7864b5e wsd: hexified URL support
Change-Id: I44c46da58e0f807354aaa201ef44d3ecf50f9a07
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 6b5cbce94c41883c7f11c28f4277083798318bf7)
2021-09-13 09:40:09 -04:00
Tomaž Vajngerl
b31eb2ab92 New POST service to render a search result + unit and integ. tests
This adds a new service render-search-result, which renders an
image of the position where, the search fund a hit. The search
result contains the information in which object or paragraph,
which is just the node id and node type from the document model.

The service takes the document and the search result (xml file)
as the input and returns a PNG image as the output.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>

Change-Id: Iffc158c5b0a3c9a63f8d05830314c9bc1616b3b1
Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
2021-09-13 10:36:15 +02:00
Michael Meeks
ef8d648c33 trace: turns out timestamps are micro not nano-seconds, rename API.
Change-Id: I0be1eddab3d67045e74cf89992973abf041beee4
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-09-10 22:45:29 +01:00
Rash419
ea4d455f3a Admin Console: add wopihost name in the dashboard
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I8ce68653200bb16877f6ced57fc77f6291b375a8
2021-09-09 10:13:40 +05:30
Mert Tumer
70f573f3b2 Implemented an option to pass PostMessageOrigin
External apps load loolwsd inside the iframe
and loolwsd makes postmessages to parent window.
We receive the postMessageOrigin from checkfileInfo yet
we still send some messages before we even go to the WOPI Api
in that case, if parent window runs on a different domain, we
end up with CORS blocking by the browser. To prevent that we can
allow safely passing the origin inside the first post like access_token
and sanitize it with Poco::URI::encode.

Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: I5724f2d103603a599d45b7f61da81fb30834ef0e
2021-09-07 10:36:07 +02:00
Pranam Lashkari
daef96dcb3 freemium: corrected typos
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: If21f4471b3ad4b20f049e2e9f2330e31989ead0b
2021-09-01 09:44:19 +02:00
Michael Meeks
d1ae5a8fb7 Valgrind support for tracing the forkit & kits.
Change-Id: Ie9dd69598bd408ae1994d8cdd6f886224890ad23
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-09-01 07:14:44 +01:00
Henry Castro
8d694bdf97 wsd: log warn if proof keys not found
"default installs currently don't use proof keys"

Change-Id: I43b6c5ed6633b35e58ec3e1b1cc222756a9a47d8
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-08-27 15:01:58 -04:00
Tor Lillqvist
3e0e9fbe7d Fix typo
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I6edf03cb46f80a1f88448718d9a2bba110ecaeb3
2021-08-23 09:39:24 +03:00
Thomas Koch
48f91a2aa4 use Request.has instead of .find and .end
Signed-off-by: Thomas Koch <thomas@koch.ro>
Change-Id: Ia0aa95e556186a27e3122c0cf00ca5cad80a0f3a
2021-08-12 14:38:26 +02:00
Henry Castro
57d454436b wsd: fix url redirect
Signed-off-by: Henry Castro <hcastro@collabora.com>
Change-Id: I09fda6618c35147b12f8e25204290a7d61cd766b
2021-08-06 17:21:18 +02:00
Henry Castro
9266fa5793 add option --with-feedback-location
Change-Id: I2f5b1556f0b976e9c3cb1f78383d2d05e6aef892
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-08-06 17:21:18 +02:00
Henry Castro
c8e2d25d24 add initial feedback option
Change-Id: I9357f556474e5ada881e27983c95f7527b284efc
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-08-06 17:21:18 +02:00
Ashod Nakashian
d8621b950b wsd: better response when disconnecting
Return proper HTTP code when disconnecting and log
to make the communication more effective.

Change-Id: I4da9d5a7fe4c09d6fcd44b1f31b439180d7012bd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-28 13:00:45 +02:00
Szymon Kłos
27e95bbe7e Wait for async save result on DocumentBroker stop
When async save was started but we want to stop DocumentBroker
- we shouldn't kill the socket which listens to save result.
Because when we kill socket we will destroy DocumentBroker
before saving is completed, this allows for a minimal time
to connect again to the document and receive old content
from the WOPI storage. When we wait for async save result
we will keep DocumentBroker alive and next session can be
connected and receive correct content.

fixes: https://github.com/CollaboraOnline/online/issues/2747

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I5505a5ccc1f3d6928c723bddfea16bf5c5798d1e
2021-07-28 13:00:45 +02:00
Szymon Kłos
38731d5818 Allow pasting into document even when DisableCopy is active
From our API description:
DisableCopy
Disables copying from the document in libreoffice online backend.
Pasting into the document would still be possible.

Change-Id: I1f7e272ad3b04208b534eff990fed895951b4751
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
2021-07-28 13:00:45 +02:00
Tor Lillqvist
522431a82e We generate 'S' and 'F' "Async" Trace Events in loleaflet, not 'b' and 'e'
"Async" here refers a specific kind of data in the Trace Event JSON
format, not asynchrony in general.

Actually, we don't have code that would generate such yet in
loleaflet. Just the createAsyncTraceEvent function in Socket.js. Quite
possibly the "Complete" events (a.k.a. ProfileZones) are all we need.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I611ccd4b964bcacdd1050893f70dbdb813ee3c34
2021-07-21 13:26:23 +03:00
Michael Meeks
cd56efe900 cleanup: don't assume that the web-server poll is still alive.
Since a99edb5d29 this gets a different lifecycle, and is often
joined and gone by the time we get to cleanup.

Change-Id: Ic21ca837d484a9a853c7f8f683e876406b00a943
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-07-21 10:03:13 +01:00
Pranam Lashkari
e02e1df76d Introduce Freemium options
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Ib6b68ff74839cf84f2d8c8cfb7d380be9209f923
2021-07-20 14:41:18 +05:30
Ashod Nakashian
4c87cc36ff wsd: Close socket hard when necessary
Also clear its input buffer explicitly.

Change-Id: I8badbb96d98eaf10433a65fcfd13b0d6d5893594
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>

Ignore input in a somewhat gentler way.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I758302dc3bb1aa87f9fbfa726f73f4b9339e08c2
2021-07-19 17:31:55 +01:00