Commit graph

2073 commits

Author SHA1 Message Date
Miklos Vajna
4d6ca688f9 wsd, convert-to: allow specifying filter options as JSON
For example, to skip exporting the first page of a document:

curl -k -F "data=@3page.odg" -F "format=pdf" -F "options={\"PageRange\":{\"type\":\"string\",\"value\":\"2-\"}}" https://localhost:9980/cool/convert-to > out.pdf

https://gerrit.libreoffice.org/c/core/+/128849 has more examples.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I6c4ce25bc580dac041f2865f74c856780d6fe137
2022-01-27 13:33:24 +01:00
Henry Castro
d056c872f5 wsd: fix missing port number
use Uri::getAuthority():
"Returns the authority part (userInfo, host and port) of the URI. "
.

Change-Id: I8c63a4c00cc1ad199f6f0cfd15f4e42fac4e7aaa
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-01-26 16:46:06 +01:00
Henry Castro
ee67cd4f44 wsd: use getHost to allow CSP frame-src
It will be used to update server check versions

Change-Id: I3acadb575bdcc99daed4c68881d3f35da999a22c
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-01-26 16:46:06 +01:00
Ashod Nakashian
9e5b9d6d37 wsd: support PDF comment saving during unload with test
PDFs are view_comment type documents where
editing is not supported, but adding comments
are. This means that we do get ModifiedStatus=true
but we never get ModifiedStatus=false after
.uno:Save. This is because the save command is
handled in a special way in Core by invoking
save-as instead, which doesn't reset the
ModifiedStatus.

The issue with this was that DocBroker was
stuck on trying to save the document
before unloading, thinking it was modified
due to the stuck ModifiedStatus. Here,
we change the definition of isPossiblyModified()
to ignore the ModifiedStatus for such documents.
Instead, we rely on the last save being successful
and that no new user input exists past the last
save request.

In addition, we now have a new Cypress test
that reproduced the failure without the fix
and now passes with the fix.

Change-Id: Ida9d486ac93a588b9007c5e4583d8bf3c090a62d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-26 15:33:15 +05:30
stellarpower
b05b8e77cf Add more detail to error logs.
We get a syntax error message in the logs - but have no indication as
 to what in the config file caused this issue. Bringing back both more
 detail to the browser and logging the extended details.

Signed-off-by: stellarpower <5004545+stellarpower@users.noreply.github.com>
Change-Id: Ib8ddb20a1968f879558e59f50579ee4b18db0f09
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-01-26 09:09:56 +00:00
Andras Timar
6d771bb3b6 Writer document is a better example for framed.doc.html
because the Python macro examples on the top of the page
operate on Writer documwents, and have no effect on Calc documents.

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ia4f9b28c25689cb2ed9037ffd24086d7fb8c3cf9
2022-01-25 20:25:43 +01:00
Pranam Lashkari
c5f2c5e174 theme: added config flag to switch between integration and cool themes
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I679328e29f2e2297491c73249632627d01a1bf42
2022-01-25 12:09:01 +05:30
Ashod Nakashian
a3bb76de2d wsd: handle no-storage when shutting down
When we reject a connection (possibly due to
authorization failure) we will not have a
storage instance to use.

Change-Id: I049c990317e4a78d0e89bc906f1ee48b365cf3c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-22 17:29:46 +00:00
Yunusemre Şentürk
a41995accd Admin: make time output thread secure
Change-Id: I3927ef9989de2217dee6c4b3034c9ffbd8fb184d
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
2022-01-21 16:52:20 +01:00
Yunusemre Şentürk
801b67c353 Admin: force un-conditional logging when docstats enabled
Change-Id: Iea0a75927b495735787496468ab39d5314992a50
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
2022-01-21 10:17:46 +00:00
Yunusemre Şentürk
2314c40873 Admin: introduce docstats subsection in logging in config
Change-Id: Icccc9d842703b3159965f67be2bf16404d50bad6
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
2022-01-17 16:28:08 +00:00
Ashod Nakashian
fa24c70242 wsd: do not load a new view when unloading
Recovering from an unloading state has a lot of
corner-cases that make it exceedingly tricky to
handle correctly. Luckily, if we reject new
connections, the client will retry connecting
(or at least it can) and that gives very
reliable results.

Change-Id: I3c06c878cb7a333dd49e153096ce01b356e9815d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-17 14:08:51 +01:00
Ashod Nakashian
bb85464d58 wsd: dump the state of the sessions of DocBroker
Change-Id: I98b287e1cbbcd463e76885672f1520b93c25751e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-17 14:08:51 +01:00
Szymon Kłos
a3c5c71107 RTL: Serve html with correct RTL settings
In case of RTL users we want to switch UI to that mode
early so we don't see flipping in the browser.
Setup correct setting at the serving html step.
Using that approach we don't need to extend LOK API.

We detect that using "lang" parameter passed in the request.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Iaa2962b01f218cae68a6dfd168bff4dbdae94c8a
2022-01-11 21:40:54 +03:00
Ashod Nakashian
e0e988c56c wsd: improve logging and doc state dumping
Change-Id: I62ae4cc8dd52861ce550217fb5fa96405cbe4eed
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 644ca92d289d77d4e14a6a473ed55daedbb125d7)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
ff43f8626f wsd: stop DocBroker when loading fails
Change-Id: I2bc6a9c367ca280e1748ee356e456a92ea04354b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit f926f31764777a212afc49e84308ac3d35367db9)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
32e71e45bc wsd: more frequent polling while unloading documents
And always use the stop() helper so that we properly
log the request to stop.

Change-Id: Iee3be5d8591bbb2febe651815741d9ad9ff5d977
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit ab954b9a34813d143b1d409ae80e7531bec625ed)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
70665b328f wsd: do not create client sessions on docs marked to destroy
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 3eb310d7609e98572959fece196d9bc00147c2ff)

Change-Id: Ic1faa042975816bd15ccc4f5667eeccfb0cf73d7
2022-01-11 09:28:03 +01:00
Ashod Nakashian
f95ff8205a wsd: test: fail when modified docs are unsaved
Change-Id: I444948ce96ff512491fe72f55a7b5abfcf1dab4e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 11dad9c87a979eee0fac9c85ea3387174da61760)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
feb01facfa wsd: do not count disconnecting sessions as active
This fixes failures in UnitCopyPaste and
TileCacheTests::testWireIDFilteringOnWSDSide where
the documents are closed while isModified() is true.

Change-Id: I6de683530df9b7987ad87897e9ce70b5fc3d3a15
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 65105263fbed89d787ac59ca77f64896bacf6832)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
65d5a4f1a5 wsd: test: add slow save and upload test
Change-Id: I5c7e706a1ded7774c9da4545218ba9fa29fc9d81
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 29c26c9afee593c20bc72a668ba0c3d5634aa35b)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
036bc60c24 wsd: save and wait until document isn't modified
We make sure that we always check for last-minute
modifications before stopping DocBroker. This covers
the cases where there are modifications that we need
to save and/or saved data that needs uploading.

This save, upload, and stop logic is now in a helper
that cleanly handles this exit-time check.

Change-Id: Ibee0e7769a396b205de955f26700ebcb27d5ac95
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 69f9d86c8b8a477b5a0cf1910eb1b7498eaceeac)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
77d5816cfc wsd: remove DocBroker from Admin last
Change-Id: Ia77b8ce5aacb9ac1dadd1251f78e40da953e7b92
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit caf5ac9c23a612836185475f4efc4c9c0249e3b4)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
b96e8b7c77 wsd: correct use the exit code from UnitWSD
Relevant for catching test failures, which
went unnoticed if the failure wasn't asserted.
E.g. when a test times out.

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

Change-Id: Ic6e5b5aa4344a3048f508a6bec2be7c5a6522f33
2022-01-11 09:28:03 +01:00
Ashod Nakashian
777858e617 wsd: add hsts header with config
Change-Id: I16955edd09cf68e995294055ea2cb3f458b3ba38
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-10 21:26:38 +01:00
Szymon Kłos
07003f88e9 Handle JSON exception when parsing commands fixes #3916
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I9bd78ded46d1b5cd4816a106b138583e540f0712
2022-01-09 13:15:36 -05:00
Yunusemre Şentürk
23e9f086e2 Admin: add log info about adding a document.
Change-Id: Ia440662d341803c56a810563a76269835469bb2e
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
2022-01-08 10:59:15 +00:00
Gleb Popov
4d64f2b466 Create a link to the master UDS file inside the jail when we aren't using abstract sockets.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I021b906ef545f4d3238f4c61650ced8da15b6374
2022-01-08 10:41:02 +00:00
Rash419
d0dc8eb9df wsd: fix: remove unnecessary condition
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ibc5338b34713233c540e0de938dbb76b88398ef5
2022-01-05 07:51:12 -05:00
Rash419
b7f7c518eb wsd: consider possibly-modified docs when handling conflicts
When the storage returns modified-in-storage or conflict status
to an upload attempt, we prompt the user to handle the conflict
when the document is modified. Previously, we only prompted
when we had the modified flag set, ignoring the possibility of
having a race with the modified flag, in case the document was
just modified, or potentially modified.

We now prompt the user even when the document is potentially
modified, giving the user the opportunity to decide what to do.

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I699aaed92d41f76a8eb9de6bdb65608099802663
2021-12-31 05:38:33 -05:00
Pranam Lashkari
75f37bb1df freemium: added option to make freemium user read only
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I4dadb535e722cbeaacf177b30247899795d048f9
2021-12-20 12:03:51 +01:00
Miklos Vajna
15e08d3709 common: introduce COOLProtocol::getNonNegTokenInteger()
To simplify code that wants to extract a non-negative number from a
token value. See
<https://github.com/CollaboraOnline/online/pull/3788#pullrequestreview-826099897>.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I389dfa1a2838e501fc308dbfd7927b142a361922
2021-12-17 02:52:37 -05:00
Tomaž Vajngerl
b9545f932c support for a custom path to NSS certdb files for sign/encrypt
The path of the NSS certdb is defined in the coolwsd.xml config
file and if the config file is set and contains the certdb files,
then the db files are copied to the jail into /tmp/certdb folder.
Also the /tmp/certdb path is set to LO_CERTIFICATE_DATABASE_PATH
env. var, which is then used as the default certdb in LibreOffice
when LOKit starts up.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I72e8f28f27a0306fef9319bc6212cd99cb3f8212
2021-12-15 06:00:55 -05:00
Pranam Lashkari
63b6d8a9d2 Quarantine: fixed quarantining when jail mounting is disabled
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I9159c6fe33d66f64e56e084a203af74629e330c6
2021-12-15 08:32:19 +01:00
Michael Meeks
35fac326be trace: emit loadTile as an async event.
Also create pseudo-threads, so we can dis-entangle async tile
loading from other event emissions.

Change-Id: I08dcd4e0f5ade741565ce3d827ec22004e1fae83
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-12-13 21:34:56 +00:00
Luboš Luňák
1dfb6d3866 handle properly "EMPTY" invalidatetiles message (T32137)
ChildSession::loKitCallback() may generate a message in the format
"invalidatetiles: EMPTY, 0". Handle it properly in tests.

Signed-off-by: Luboš Luňák <l.lunak@centrum.cz>
Change-Id: If8009be3c4ce031466ed304df7028848a8ab960f
2021-12-13 22:08:25 +01:00
Gabriel Masei
9c4bfaaff1 add pdf version option for conversion
Signed-off-by: Gabriel Masei <gabriel.masei@1and1.ro>
Change-Id: I8a9a05498649dfea80ec425671326aa0c62d4917
2021-12-13 15:27:16 +02:00
Szymon Kłos
f3d2aa4be0 Use correct formatting for string variables
- when reading from config use correct type so SyntaxException
  is thrown when we type non-number into uint field
- handle SyntaxException and send 500 so user will get response
  (previously we left request without response until timeout)
- log about incorrect value in the config
- simplify repeated bool -> string conversion after config read

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I1c50de263ffdb1d97eb9381754bc7cf3bd05dbfa
2021-12-11 21:58:34 +01:00
Miklos Vajna
e2515a7b15 TileCache: improve parsing in parseInvalidateMsg()
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I373f85e68964610fe88cb6fa057c548b9a50fb51
2021-12-02 08:21:49 +01:00
Andras Timar
b40a72877a quarantine: add the original file name to the quarantined file name
Instead of
1638118271_12013_%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F289_ocvq040ushf2
we would get
1638118271_12013_%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F289_ocvq040ushf2_bad.docx
I find it more useful.

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I50918908173adeb68964b2aa542592b57ec82020
2021-11-29 13:37:19 +01:00
Miklos Vajna
e5ef35f716 WopiStorage: log what is the final suggested target for save-as
unit-wopi-saveas sometimes fails on me with sanitizers. The reason is
still not yet clear (the test is quite stable without them), but at
least try to find out if the suggested target is already wrong when we
put them to the HTTP header or it goes wrong later.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I25f65fd6e211022aa93c699cdaef49eb8978fdee
2021-11-25 11:30:28 +01:00
Pranam Lashkari
de703d6537 quarantine: quarantine file on exit too
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I1c5efa5d0e339ed2225969ad6680c73c9fe474d0
2021-11-25 09:59:11 +02:00
Ashod Nakashian
38b9a8ab55 wsd: cache misses are not errors
Change-Id: I2e33825ad4f301cc0746a3cc3a226a2161878778
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-11-24 20:11:07 +01:00
Ashod Nakashian
e4195cf592 wsd: allocate temporary buffer dynamically
Change-Id: Ic1fda50016a141c30fb710c3356292ce4d6617d7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-11-24 20:11:07 +01:00
Ashod Nakashian
587d160146 wsd: Termination flag requires having ShutdownRequested
Certain parts of the code assume ShutdownRequested is set
when relying on the Termination flag. This is because
they serve as degrees not as independent flags.

The Termination flag is basically a more impatient
ShutdownRequested flag. It is used to forcefully
and immediately terminate. It is not designed to be
used independently from ShutdownRequested.

This pair is a good candidate for unifying as a single enum.

Change-Id: I8e3913a1959868197d8c5a059e89cbdbc6cef070
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-11-23 09:31:46 +01:00
Pranam Lashkari
4aeaafee98 quarantine: quarantine file on loading
additionals:
make sure quarantine does not fail on the exit

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I8843ba7e72dc3703c1168b57c9927598bfa5d1f7
2021-11-22 17:31:53 +05:30
Jan Holesovsky
b4f588ea3c Add a value "default" for the user interface
To be able to override it by a new package version, if necessary.

Also, when explicitly configuring the "classic" or "notebookbar", make
it override what is provide in UiMode.

Signed-off-by: Jan Holesovsky <kendy@collabora.com>
Change-Id: I4b9764b32ce712d8bfd46ef90d9c8538fcaf921b
2021-11-19 16:08:44 +00:00
Aron Budea
14d28ca8b6 Make Notebookbar the default
Remove all occurrences of USER_INTERFACE_MODE configure
variable.

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I398d97fa975a0c52391547d2e791ff17e7effde6
2021-11-19 16:08:44 +00:00
Rash419
f815ff459b wsd: fix: don't use hardcoded PostMessageOrigin
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I72da1c8e3cfea0d4984c80b6dddd3e39af020bee
2021-11-19 14:08:16 +01:00
Andras Timar
b6182877a8 backward compatibility: /lool/convert-to endpoint
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I8a3930a01a18be32bee657142f872ba58383594d
2021-11-19 13:27:27 +01:00