Commit graph

130 commits

Author SHA1 Message Date
Michael Meeks
14e3a20e18 DocumentManagerInterface - remove un-helpful abstract base.
This added 200+ lines of code, made things harder to
understand, and was used only in a single test that can be
covered in another way.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I4ed8d1d52d533f8b24be7dd5e12dbb7702ef1a80
2024-04-29 10:56:54 +02:00
Michael Meeks
08e17a0388 Simplify Document creation, and coupling to KitWebSocket.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Iec7dfd3d33de2ae548ca73081d50361958672e4a
2024-04-29 10:56:54 +02:00
Michael Meeks
e27a095775 bgsave: initial implementation (gated on COOL_BGSAVE=1)
Initial background save implementation from the Kit perspective.

To do a background save we:

   1. join known threads - we can't fork with >1 thread.
   2. check all is well: one thread, nothing unusual...
   3. create a socketpair to communicate with the child
   4. fork
   5. child: cleanup duplicated sockets
   6. child: setup LOK to not damage our shared file-system
   7. child: save
   8. child: report status back to parent & _Exit

There is still a substantial TODO, but this can be built on.

Change-Id: Ibf2c492372e2b5133932773e230ad05e18521794
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-04-05 17:34:43 +01:00
Aron Budea
3b8f3d07f6 Replace Util::startsWith/endsWith w/ C++20 equivalent
Replace a few cases of Util::toString(...), too.

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I53c5dbbdf2f60710e94add9dd137aa9becb7bd3e
2024-02-22 08:08:32 +01:00
Miklos Vajna
c41cfb1999 test: fix -Werror,-Winconsistent-missing-override in WhiteBoxTests
WhiteBoxTests.cpp:660:10: error: 'updateActivityHeader' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
    void updateActivityHeader() const
         ^
../kit/ChildSession.hpp:89:18: note: overridden virtual function is here
    virtual void updateActivityHeader() const = 0;
                 ^

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I12f21fd9fbe0ba77d2196bfcd1cbdb5ef07e5d06
2024-02-07 15:10:07 +00:00
Michael Meeks
29fa4a40a1 signal activity dumping: enrich with session details and state.
Cue up some basic state for being signal safe dumped on crash/abort.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ibc6713aef2a0e7b878b178b05f0e13c8d40b47fc
2024-02-06 19:29:28 +00:00
Miklos Vajna
33310613cd wsd: fix reading past the end of the clipboard in postProcessCopyPayload()
Add a way to search with an offset in findInVector() and then we can
avoid strstr() which assumes a null-terminated input, which may not be
the case.

	READ of size 55 at 0x606000068a56 thread T8 (docbroker_001)
	    #0 0x55d0d6718a5a in StrstrCheck(void*, char*, char const*, char const*) /home/abuild/rpmbuild/BUILD/llvm-15.0.7.src/build/../projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:652:5
	    #1 0x55d0d6718882 in __interceptor_strstr /home/abuild/rpmbuild/BUILD/llvm-15.0.7.src/build/../projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:669:5
	    #2 0x55d0d71872c9 in ClientSession::postProcessCopyPayload(std::shared_ptr<Message> const&)::$_4::operator()(std::vector<char, std::allocator<char>>&) const /home/vmiklos/git/collaboraonline/online-23.05-san/wsd/ClientSession.cpp:1631:31

During unit-uno-command.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Id42669d912bab4746d9f7d99a192c4c3f1d175f7
2024-01-23 08:38:26 +00:00
Michael Meeks
5bd1f1d0e8 convert-to: be more tolerant of unusual filenames.
But re-write them anyway to be more sensible.

Change-Id: Ie146f4f84b539ab7e826a1c1b947497acde7e384
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-01-15 11:57:55 +01:00
Michael Meeks
7183a3d3de spdx: improve machine and human readability of headers.
Change-Id: Ice934380029bf27054e830fffc07a5d037d1430f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Ashod Nakashian
968ab3e529 wsd: test: move File-Serve whitebox tests to own file
Change-Id: I4e659f28636cc78beca3c05ed7f23ef714d32063
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 08:58:39 +02:00
Cosmin Humeniuc
5fcdf5bf6d test for not to cut in the middle of a UTF-8 multibyte sequence
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Id13995ff7e775105882c726144f39aadaef76e64
2023-08-25 08:41:46 +02:00
Caolán McNamara
ce56852851 clarify the meaning of the len arg to getAbbreviatedMessage
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4bdcc8d2fbd5a2ee74b6743b369196825eeb4fb0
2023-08-25 08:41:46 +02:00
Jaume Pujantell
63473360b1 save-as preserves document password
Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: Ibaa00fbe4e83c8e4edfe2a70ede861f9adbd20bf
2023-08-03 11:09:35 +01:00
Michael Meeks
d309d7199a deltas: fold the update: command back into an empty delta: command.
Also: address parts of #6897, primarily:

* remove the problematic aspect of bumping the last wid in our
  TileData, when this could trigger a re-send of a previously
  sent delta, causing tile corruption.
    * instead append an empty wid entry.
    * as an optimization - if the last entry is empty update
      the wid - since re-sending an empty delta is of no
      concern.

* simplify a number of code-paths that special-case zero length
  deltas. All deltas now commence with 'D'.

* still track updates in the JS - by detecting empty deltas.

* shares more code and simplifies various paths.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I02af6d4b152524c201b6985b7a3497da7f08a517
2023-07-17 11:35:25 +02:00
Julius Härtl
752cde163e feat: Add UITheme option for light/dark to ui_defaults
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Change-Id: Ief028dcec0daa2ae448f83df993e0e5ade594a7c
2023-06-01 09:49:08 +02:00
Miklos Vajna
5f77363c4f test: fix -Werror,-Winconsistent-missing-override
'trimIfInactive' overrides a member function but was not marked 'override'.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I25b0033652a3362118a77b7ef5ef7a511ce492ea
2023-03-29 17:31:42 +01:00
Michael Meeks
7444decf9f trim memory when user is inactive.
Builds on a new LOK API to do the same in the core.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I4443cd2ffbb6c7af0726162aec2ba78fc354d901
2023-03-23 11:31:24 +00:00
Michael Meeks
30e6f08147 perf: merge deltas and keyframes into the same storage.
Simplifies and accelerates the code.

Change-Id: I56b661e566efd75e3ed46918a481c26ddd5ca4c4
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-27 22:01:24 +01:00
Michael Meeks
2f2b8fb2b1 TileData: write unit tests.
Change-Id: I6ce29952800cf43d95c5572201269839b5426eac
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-27 22:01:24 +01:00
Ashod Nakashian
fac6c01725 wsd: replace strrchr with constexpr
This avoids the runtime overhead of strrchr used
in logged filenames on iOS, which is unnecessary
on string literals, and adds unit-tests.

We also strip leading './' and '../' in other builds.

Change-Id: I56ec722d1400fad9165eb046d1bd8d4438241ca3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-26 11:13:44 +03:00
Ashod Nakashian
26348a9785 wsd: test: move StringVector tests to StringVectorTests
WhiteBoxTests.cpp is by far the slowest TU
to compile (taking minutes) and gcc started showing
'note: variable tracking size limit exceeded'
and recompiles, which doubles the time.

This moves the StringVector tests into a new
home, which reduces the size of WhiteBoxTests.

Change-Id: Ia4e8daa921fb941815ad7e68f4dbb964fb2cd93e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Ashod Nakashian
480fb7b931 wsd: move tokenizer helpers into StringVector
In an attempt to reduce the size of Util.{c,h}pp
which has grown to contain all sorts of unrelated
helpers, we move StringVector helpers into
the StringVector.{c,h}pp files.

This makes the code better organized.

Change-Id: I152f341606807ae66253415b951bc9f89b09df57
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Ashod Nakashian
264bdec250 wsd: test: move Authorization tests to RequestDetailsTests
And cleanup includes to reduce build time.

Change-Id: If2e242e6688b788b91d62351ef555b31aad1ecde
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Ashod Nakashian
0403a0c0fe wsd: test: split out RequestDetails tests
WhiteBoxTests.cpp is by far the slowest TU
to compile (taking minutes) and even gcc gives
'note: variable tracking size limit exceeded'
and recompiles, which doubles the time.

This extracts the RequestDetails tests into
its own file to better parallelize the build.

Change-Id: Ic8d54d06223a122bc1ccf73cfa216e2b3a8f32a5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Michael Meeks
db63703d0c Validate as utf-8 all Websocket text messages in debug mode.
Ensure that rendersearchresult: is terminated, and identified as binary.

Change-Id: I84e83c63351cd0aac0923bf7c833b14c1be2c051
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-04-04 20:46:11 +01:00
Ashod Nakashian
52f2600cf9 wsd: test: embue all tests with a name and unify logs
Now the remaining tests that didn't have a name
get one and the logs are unified between old-
and new-style tests. Mostly.

This makes sure that all logs and assertions
properly log the test name and make test
failures easier to debug and fix.

Change-Id: Id159ffacc81642a6ec594c5143498408adab67cf
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
74cf0857d9 wsd: test: CPPUNIT_ASSERT -> LOK_ASSERT
Reduce direct dependency on CPPUNIT further.

Change-Id: I9ca39c20a9c64f983aed1a6488446e0b7f21cffe
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
08702df63f wsd: add getSystemClockAsString helper
Change-Id: If6cfa07b48d0d08060987f831fa926f5cf9214a7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
ce6c3e0454 wsd: add endsWith helper with tests
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 7e0ea08bacb0a589421feb7effa52d2a031ad16d)

Change-Id: Iac9223be5338d87861520ed7dd8cc1778727e3fd
2022-01-11 09:28:03 +01:00
Andras Timar
f07ff8c7e0 rename: remaining lool->cool changes
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ib7d4e804bebe52dead8d53b0e0bbaed0f08bf3d0
2021-11-18 14:14:11 +01:00
Henry Castro
cc8a84af60 config: rename 'lool' -> 'cool'
.
Change-Id: I13596547abac424482096a9af13c6785a8e2b897
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-11-17 09:19:04 +01:00
Henry Castro
dc1bca91cf test: rename 'lool' -> 'cool'
Change-Id: I26acf7d9d7bc154b5b06aec9bc062e206cbffc52
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-11-17 09:17:16 +01:00
Henry Castro
0310a29826 test: rename loleaflet -> cool
Change-Id: I7becbab62266ac42af8217ff9c04cac466ec6905
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-11-10 17:18:56 +01:00
Henry Castro
d9870bdff0 test: rename loleaflet -> browser
Change-Id: I1c361fdf76b3e610b9377758af7ae666437759f8
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-11-10 17:18:56 +01:00
Henry Castro
e0fe47be5f rename loleaflet.html -> cool.html
Change-Id: Iaa28f1269f8192755ec323396ae4ff054529f412
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-11-10 17:18:56 +01:00
Julius Härtl
570c31d1a1 wsd: Allow to pass ui defaults for drawings
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Change-Id: Ie311ca6b7578ead6f7c7d61fe993d4ecdc9a4386
2021-10-29 16:30:43 +02:00
Hugo Peixoto
aba9bf5597 Fix typo in comment
Signed-off-by: Hugo Peixoto <hugo.peixoto@gmail.com>
Change-Id: Icb6f788956d4c21573e54c5e66a0beb6197425e2
2021-10-18 17:30:05 +02:00
Hugo Peixoto
2bdb7ed56f Fix bug in StringVector::startsWith and add tests
The startsWith method that receives a StringToken was doing a bounds
check on the wrong parameter. This caused most calls to return false.

This commit adds some tests to both versions of StringVector::startsWith.

Signed-off-by: Hugo Peixoto <hugo.peixoto@gmail.com>
Change-Id: Icd4c648d681723ac66dba3c6a42ab7920850c619
2021-10-18 08:18:14 +02:00
Miklos Vajna
95c700ff47 Test JsonUtil::escapeJSONValue()
Follow-up to commit d1bc6911b5 (Escape
strings in JSON, 2021-10-13).

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: If8d21d6ebcf080f8893dedbebcd42aaad3b921a1
2021-10-14 11:58:07 +02:00
Michael Meeks
eeb4dfd77e Compiler with recent cppunit.
test/lokassert.hpp:16:22: note: 'operator<<' should be declared prior to the call site

Change-Id: I7533490e64b1181b3349d0966b42eba4dcc88f05
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-09-13 19:53:47 +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
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
Ashod Nakashian
28687c0bbf wsd: hexifying helpers and tests
Change-Id: I2f7fa4e6ade3361db612dbb9aa68e4d28b3905d9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 348ca073abe2c980f746324589bc58bf5550dc4b)
2021-09-13 09:40:09 -04:00
Ashod Nakashian
0fa12e8e76 wsd: add hexify-data utility
Using for fuzzing and integration testing.

With unit-tests.

Change-Id: I23f8c619e239310d92c74c4d5e4157afb52a5e56
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-13 21:57:43 -04:00
Michael Meeks
5c345a1d14 Message: cleanup message parsing of payloads.
Change-Id: Id11a702590539ff4f20fa56272beeb6d91b9e7bd
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-05-05 02:51:54 +01:00
Miklos Vajna
d3c9e07ff3 StringVector: add a way to get a string-number pair out of this ...
... without copying the token.

And use it in TileDesc::parse(), which is known to be a hot path.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I0dcf2eb26c93254cdc6a1c11f9708daf213a825d
2021-04-27 15:31:21 +02:00
Miklos Vajna
c11f0e5708 StringVector: add a way to get a number out of this without copying the token
And use it in TileDesc::parse(), which is known to be a hot path.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I20375d7a1c31f61662446979e4d6799fd45b49d3
2021-04-27 15:31:21 +02:00
Miklos Vajna
a5566baa03 Add version of std::atoi() that needs no extra allocation
std::atoi() assumes a null-terminated string and our strings are not
always null-terminated. So add a version that takes a length parameter,
this way we don't have to copy strings around.

Also switch to this in http::StatusLine::parse().

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I449b356c1b9948c562434618596e8e3b38656088
2021-04-26 16:22:27 +02:00
Michael Meeks
2fcc5451d7 Avoid errno == ERANGE poisoning numerical conversions.
Change-Id: I0156310257caf7c578fb273393566a0970b3bb1f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-04-16 22:43:17 +01:00
Ashod Nakashian
9d5f8fc73e wsd: http: improved parseUri and new parseUrl with tests
Change-Id: Icee821ab6176d17e08bfc6bc581eaf4b3986da60
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-07 11:36:10 -04:00