Commit graph

3753 commits

Author SHA1 Message Date
Richard Hansen
77f480d954 hooks: Asyncify aCallFirst 2021-02-02 09:09:02 +00:00
Richard Hansen
22d02dbcbf hooks: Factor out value normalization 2021-02-02 09:09:02 +00:00
Richard Hansen
f316a3bacd hooks: Never pass a falsy error to a callback 2021-02-02 09:09:02 +00:00
Richard Hansen
708206449a hooks: Factor out callback attachment
The separate function will be reused in a future commit.
2021-02-02 09:09:02 +00:00
Richard Hansen
13e806ad7a hooks: Inline mapFirst() into aCallFirst() for readability
There's only one caller of the function, and the function is simple,
so there's no need for a separate function.
2021-02-02 09:09:02 +00:00
Richard Hansen
4ab7a99512 hooks: Inline syncMapFirst() into callFirst() for readability
There's only one caller of the function, and the function is simple,
so there's no need for a separate function.
2021-02-02 09:09:02 +00:00
Richard Hansen
53ccfa8703 hooks: Asyncify mapFirst 2021-02-02 09:09:02 +00:00
Richard Hansen
0b83ff8ec2 hooks: Simplify syncMapFirst iteration 2021-02-02 09:09:02 +00:00
Richard Hansen
c89db33ff0 hooks: Refine caveat comments about function parameter count 2021-02-02 09:09:02 +00:00
Richard Hansen
f02f288e80 hooks: Rename args to context for consistency 2021-02-02 09:09:02 +00:00
Richard Hansen
7dba847f21 hooks: Don't export syncMapFirst or mapFirst
Nobody uses these functions outside of this file.
2021-02-02 09:09:02 +00:00
Richard Hansen
6b42dabf6c hooks: Delete unused bubbleExceptions setting 2021-02-02 09:09:02 +00:00
Richard Hansen
47f0a7dacf lint: Fix more ESLint errors 2021-02-02 09:09:02 +00:00
Richard Hansen
1bc52f4913 hooks: Remove unnecessary callAllStr() function 2021-02-02 09:09:02 +00:00
translatewiki.net
5b701b97c3 Localisation updates from https://translatewiki.net. 2021-02-01 15:21:50 +01:00
John McLear
b3dda3b11c lint: src/static/js/pluginfw/*.js 2021-01-30 17:00:40 -05:00
John McLear
0cc8405e9c Bump minimum required Node.js version to 10.17.0
This makes it possible to use fs.promises.
2021-01-30 17:00:40 -05:00
Richard Hansen
877f0c5883 server: Use wtfnode to log reasons why node isn't exiting 2021-01-30 08:05:08 +00:00
Richard Hansen
ba81ead101 server: Remove all other signal listeners 2021-01-30 08:05:08 +00:00
Richard Hansen
ecdb105bfe server: Refine process lifetime management
Define states and use them to properly handle multiple calls to
`start()`, `stop()`, and `exit()`. (Multiple calls to `exit()` can
happen if there is an uncaught exception or signal during shutdown.)

This should also make it easier to add support for cleanly restarting
the server after a shutdown (for tests or via an `/admin` page).
2021-01-30 08:05:08 +00:00
Richard Hansen
725023fe58 server: Refactor stop() to avoid no-async-promise-executor lint error
Also log when Etherpad has stopped.
2021-01-30 08:05:08 +00:00
Richard Hansen
d339f2a671 server: Perform init after adding uncaught exception handler
This avoids an unnecessary `try` block.
2021-01-30 08:05:08 +00:00
Richard Hansen
86ceb2b610 server: Exit on unhandled Promise rejection 2021-01-30 08:05:08 +00:00
John McLear
5bcd6f44a5
lint: skin-variants (#4603)
* lint: skin-variants

* for squash: Fix attachment of event listener

Before this PR the statement was outside the function. I'm assuming
the move into the function body was accidental, so move it back out.

* for squash: Preserve order of function calls

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-01-30 07:32:12 +00:00
John McLear
29179e512f lint: skiplist 2021-01-30 00:52:55 -05:00
John McLear
f72ce463ef lint: undomodule 2021-01-30 00:51:29 -05:00
Richard Hansen
89bcfa2b4a tests: Stop using nyc
There are some problems with nyc:
  * The coverage numbers aren't useful in our case because most of the
    code is executed outside the test process (the test code is mostly
    API client logic).
  * nyc messes with line numbers, which makes it much harder to debug
    problems.
  * We're seeing frequent SIGABRT crashes while nyc is printing the
    results table. I'm not sure if nyc is the cause of the crashes, or
    if it's making a race condition worse, or if the crashes have
    nothing to do with nyc, but we don't lose much by removing it so
    we might as well see if the crash frequency improves.
2021-01-29 09:17:17 +00:00
John McLear
0897a28e70 lint: AttributeManager 2021-01-29 09:16:50 +00:00
Richard Hansen
462530eafb AttributeManager: Fix attribute name during attribute removal
Before this change, the `author` attribute was silently discarded
during `.map()` iteration and the name of the attribute to remove was
included twice with two different values.
2021-01-29 09:16:50 +00:00
Richard Hansen
8efc87f33a AttributeManager: Fix bogus this during attribute removal
Before this commit, the callback passed to `.map()` during attribute
removal was a normal function, not an arrow function. This meant that
the value of `this` in the function body depended on how the callback
was invoked. In this case, the callback was invoked without any
explicit context (it was not called as a method, nor was it called via
`.call()`, `.apply()`, or `.bind()`). Without any explicit context,
the value of `this` depends on strict mode. Currently the function is
in sloppy mode, so `this` refers to the "global this" object (a.k.a.,
`window`). It doesn't make sense for the callback to reference
`window.author`, so I'm assuming the previous behavior was a bug.

Now the function is an arrow function, so the value of `this` comes
from the enclosing lexical context, which in this case is the
AttributeManager object. I believe that was the original intention.
2021-01-29 09:16:50 +00:00
Richard Hansen
c1ef12b8da lint: Re-run eslint --fix 2021-01-29 01:14:03 -05:00
Richard Hansen
b02ab430fe Bump eslint-config-etherpad to 1.0.24 2021-01-29 01:10:58 -05:00
John McLear
5d7645e36a lint: ace2_common.js linting 2021-01-29 00:53:59 -05:00
John McLear
f6eb6bd266 remove dead object code 2021-01-29 00:53:22 -05:00
translatewiki.net
989f42204f Localisation updates from https://translatewiki.net. 2021-01-28 18:48:11 +01:00
Richard Hansen
7f392e12e9 tests: Create a src/tests/ symlink that points to tests/
This makes it possible for plugin backend tests to do
`require('ep_etherpad-lite/tests/backend/common')` to access the API
key (among other things).

Eventually we probably should reverse these (move `tests/` to
`src/tests/` and make `tests/` a symlink to `src/tests/`) and move
`bin/` to `src/bin/` so that we can avoid the top-level `package.json`
mess.
2021-01-28 10:02:58 +00:00
Richard Hansen
53092fa7af db/Pad: Call padCopy and padRemove hooks asynchronously 2021-01-28 09:36:22 +00:00
Richard Hansen
e5b45cc984 contentcollector: Delete unnecessary dom functions
And move the remaining functions out of the `makeContentCollector()`
function.
2021-01-27 04:59:36 +00:00
Richard Hansen
275f041fbb contentcollector: Simplify child node access 2021-01-27 04:59:36 +00:00
Richard Hansen
1cb5453aeb contentcollector: Skip over non-Text, non-Element Nodes 2021-01-27 04:59:36 +00:00
Richard Hansen
075969aea0 contentcollector: Fix Element tag name fetch
The `name` property is only available on cheerio's Element-like
objects; DOM Element objects do not have a `name` property. Switch to
`dom.tagName()` to fix the logic for browsers.
2021-01-27 04:59:36 +00:00
Richard Hansen
e3ec9d9a4c contentcollector: Fix parent node access
The `parent` property is only available on cheerio's Node-like
objects; DOM Node objects do not have a `parent` property. Switch to
the `parentNode` property so that the code works in browsers as well
as cheerio.
2021-01-27 04:59:36 +00:00
Richard Hansen
1d36549152 contentcollector: Delete unnecessary parentheses 2021-01-27 04:59:36 +00:00
Richard Hansen
e3a47e48f9 contentcollector: Fix collectContentLineText hook
Before, the hook always ignored the return values provided by the hook
functions. Now the hook functions can change the text by either
returning a string or setting `context.text` to the desired value.

Also drop the `styl` and `cls` context properties. They were never
documented and they were always null.
2021-01-27 04:59:36 +00:00
Richard Hansen
4e220538a1 contentcollector: Use destructuring to improve readability 2021-01-27 04:59:36 +00:00
Richard Hansen
b547ce9a47 contentcollector: Invert logic to improve readability 2021-01-27 04:59:36 +00:00
Richard Hansen
b811030846 contentcollector: Delete unnecessary truthiness check 2021-01-27 04:59:36 +00:00
Richard Hansen
fc2420c244 contentcollector: Fix iteration over child Nodes
In the DOM, `.children` only includes children that are Element
objects. In cheerio 0.22.0, `.children` includes all child Nodes, not
just Elements. Use `dom.numChildNodes()` and `dom.childNode()` so that
browsers behave the same as cheerio.
2021-01-27 04:59:36 +00:00
Richard Hansen
d0bfb54c0a contentcollector: Avoid for..in iteration of object properties
`for..in` iterates over inherited properties, which is almost never
desired. In most cases there aren't any inherited enumerable
properties so it's not that big of a deal, but in the case of
HTMLCollection it's very bad because it iterates over every entry
twice (once by numerical index and once by name) plus it includes the
`length` property in the iteration.
2021-01-27 04:59:36 +00:00
Richard Hansen
3cfec58948 contentcollector: Rename dom functions for consistency with DOM spec 2021-01-27 04:59:36 +00:00
Richard Hansen
8763c3bb29 contentcollector: Fix Element attribute accesses
The `attribs` property is only available on cheerio's Element-like
objects; DOM Element objects do not have an `attribs` property. Switch
to `dom.nodeAttr()` to fix the logic for browsers.
2021-01-27 04:59:36 +00:00
Richard Hansen
99625950c8 contentcollector: Factor out call to .toLowerCase() 2021-01-27 04:59:36 +00:00
Richard Hansen
dd7fb1babe contentcollector: Document the dom object 2021-01-27 04:59:36 +00:00
Richard Hansen
74bb2f76cc contentcollector: Delete unused domInterface parameter 2021-01-27 04:59:36 +00:00
Richard Hansen
42c25b2536 openapi: Fix error logging 2021-01-27 04:59:36 +00:00
Richard Hansen
54a3dbb9a0 lint: Fix some straightforward ESLint errors 2021-01-27 04:59:36 +00:00
Bartlomiej Witczak
4b4b685bba
fix: runtime error if no buttons are present in toolbar (#4680)
Co-authored-by: Bartek Witczak <bartek@dayone.pl>
2021-01-26 11:02:54 +00:00
Richard Hansen
b73b0bcb98 farbtastic: Minimize diff to upstream
This should make it easier to upgrade to the latest version.
2021-01-26 04:07:43 -05:00
Richard Hansen
a0745d74b9 farbtastic: Document where the code came from 2021-01-26 04:07:43 -05:00
John McLear
3a19254f21 stale code: removed excanvas which was ie support for no canvas 2021-01-26 04:05:54 -05:00
John McLear
7768871f8f security: bumping socketio version due to vulnerability 2021-01-26 00:53:04 -05:00
John McLear
81b860bc35 tests: allow for longer timeout 2021-01-25 22:53:11 -05:00
John McLear
7421730b44 lint: src/node/utils/toolbar.js 2021-01-25 22:53:11 -05:00
John McLear
89aa8cf55e lint: src/node/utils/randomstring.js 2021-01-25 22:53:11 -05:00
John McLear
21ef857d8a lint: src/node/utils/promises.js 2021-01-25 22:53:11 -05:00
John McLear
b831feae66 lint: src/node/utils/path_exists.js 2021-01-25 22:53:11 -05:00
John McLear
4f7e322d53 lint: src/node/utils/padDiff.js 2021-01-25 22:53:11 -05:00
John McLear
9759e09387 lint: src/node/utils/customError.js 2021-01-25 22:53:11 -05:00
John McLear
f664f84da5 lint: src/node/utils/caching_middleware.js 2021-01-25 22:53:11 -05:00
John McLear
02c1bf7d81 lint: src/node/utils/UpdateCheck.js 2021-01-25 22:53:11 -05:00
John McLear
f8323eae89 lint: src/node/utils/TidyHtml.js 2021-01-25 22:53:11 -05:00
John McLear
31f1e39565 lint: src/node/utils/Settings.js 2021-01-25 22:53:11 -05:00
John McLear
af8ea6b45f lint: src/node/utils/NodeVersion.js 2021-01-25 22:53:11 -05:00
John McLear
b11ba23208 lint: src/node/utils/MinifyWorker.js 2021-01-25 22:53:11 -05:00
John McLear
b5e04d867e lint: src/node/utils/LibreOffice.js 2021-01-25 22:53:11 -05:00
John McLear
85d1dc8d71 lint: src/node/utils/ImportHtml.js 2021-01-25 22:53:11 -05:00
John McLear
a41b4b8e45 lint: src/node/utils/ImportEtherpad.js 2021-01-25 22:53:11 -05:00
John McLear
9fff82e370 lint: src/node/utils/ExportTxt.js 2021-01-25 22:53:11 -05:00
John McLear
bfabe7c297 lint: src/node/utils/ExportHtml.js 2021-01-25 22:53:11 -05:00
John McLear
c44c4edc10 lint: src/node/utils/ExportHelper.js 2021-01-25 22:53:11 -05:00
John McLear
a4764faded lint: src/node/utils/ExportEtherpad.js 2021-01-25 22:53:11 -05:00
John McLear
52f60ceeaa lint: src/node/utils/Cli.js 2021-01-25 22:53:11 -05:00
John McLear
60bc849be2 lint: src/node/utils/AbsolutePaths.js 2021-01-25 22:53:11 -05:00
John McLear
7afc809073 lint: src/node/utils/Abiword.js 2021-01-25 22:53:11 -05:00
John McLear
666dd7abd1 lint: src/node/padaccess.js 2021-01-25 22:53:11 -05:00
John McLear
6054f6d93f lint: src/node/hooks/i18n.js 2021-01-25 22:53:11 -05:00
John McLear
2dec36bfd7 lint: src/node/hooks/express/tests.js 2021-01-25 22:53:11 -05:00
John McLear
6df3eadecd lint: src/node/hooks/express/static.js 2021-01-25 22:53:11 -05:00
John McLear
09fc7438ea lint: src/node/hooks/express/specialpages.js 2021-01-25 22:53:11 -05:00
John McLear
72ddf35426 lint: src/node/hooks/express/padurlsanitize.js 2021-01-25 22:53:10 -05:00
John McLear
43ce0f839b lint: src/node/hooks/express/padreadonly.js 2021-01-25 22:53:10 -05:00
John McLear
2f9a3ec655 lint: src/node/hooks/express/openapi.js 2021-01-25 22:53:10 -05:00
John McLear
18ebf7b69a lint: src/node/hooks/express/isValidJSONPName.js 2021-01-25 22:53:10 -05:00
John McLear
3571eb7c32 lint: src/node/hooks/express/importexport.js 2021-01-25 22:53:10 -05:00
John McLear
3cf6e1f015 lint: src/node/hooks/express/errorhandling.js 2021-01-25 22:53:10 -05:00
John McLear
4de2844af2 lint: src/node/hooks/express/apicalls.js 2021-01-25 22:53:10 -05:00
John McLear
fbc70c1276 lint: src/node/hooks/express/adminplugins.js 2021-01-25 22:53:10 -05:00
John McLear
3a586a7aad lint: src/node/hooks/express/admin.js 2021-01-25 22:53:10 -05:00
John McLear
acf889b7de lint: src/node/handler/SocketIORouter.js 2021-01-25 22:53:10 -05:00
John McLear
532bde71f7 lint: src/node/handler/PadMessageHandler.js 2021-01-25 22:53:10 -05:00