Commit Graph

5262 Commits (98993fe15620f50d454c85597116dbd1c90fd044)

Author SHA1 Message Date
muxator 98993fe156 db/SessionManager.js: "groupMangager" -> "groupManager"
Extracted from Ray's work.
2019-02-09 02:18:36 +01:00
muxator 11453d544c prepare to async: stricter checks
This change is in preparation of the future async refactoring by Ray. It tries
to extract as many changes in boolean conditions as possible, in order to make
more evident identifying eventual logic bugs in the future work.

This proved already useful in at least one case.

BEWARE: this commit exposes an incoherency in the DB API, in which, depending
on the driver used, some functions can return null or undefined. This condition
will be externally fixed by the final commit in this series ("db/DB.js: prevent
DB layer from returning undefined"). Until that commit, the code base may have
some bugs.
2019-03-01 09:43:41 +01:00
muxator e841798314 prepare to async: typos in error messages
This change extracts the grammar correction performed on the async branch,
anticipating them in a single commit. It cannot be folded with the previous
one, as it is not purely cosmetic.
2019-02-15 22:52:53 +01:00
muxator 9497ee734f prepare to async: trivial reformatting
This change is only cosmetic. Its aim is do make it easier to understand the
async changes that are going to be merged later on. It was extracted from the
original work from Ray Bellis.

To verify that nothing has changed, you can run the following command on each
file touched by this commit:
  npm install uglify-es
  diff --unified <(uglify-js --beautify bracketize <BEFORE.js>) <(uglify-js --beautify bracketize <AFTER.js>)



This is a complete script that does the same automatically (works from a
mercurial clone):

```bash
#!/usr/bin/env bash

set -eu

REVISION=<THIS_REVISION>

PARENT_REV=$(hg identify --rev "${REVISION}" --template '{p1rev}')
FILE_LIST=$(hg status --no-status --change ${REVISION})
UGLIFYJS="node_modules/uglify-es/bin/uglifyjs"

for FILE_NAME in ${FILE_LIST[@]}; do
  echo "Checking ${FILE_NAME}"
  diff --unified \
    <("${UGLIFYJS}" --beautify bracketize <(hg cat --rev "${PARENT_REV}" "${FILE_NAME}")) \
    <("${UGLIFYJS}" --beautify bracketize <(hg cat --rev "${REVISION}"   "${FILE_NAME}"))
done
```
2019-02-08 23:20:57 +01:00
muxator cc23bd18a4 db/API.js: require() Changeset library at top of file
Introduced with d246a191c6 ("Added option to restore revisions #1791") on
2014-11-08.
2019-03-07 00:39:41 +01:00
muxator 06756e49ee db/API.js: reuse the already required padMessageHandler (2 of 2)
It was introduced on 2014-11-12 by commit 9d39c9591a ("update pad clients").
2019-03-07 00:14:49 +01:00
muxator 72260b86de db/API.js: reuse the already required padMessageHandler (1 of 2)
Commit 94cb743ca8 ("Fix API call appendChatMessage to send new message to all
connected clients") fixed a bug, but introduced a redundant require().
2019-03-07 00:04:08 +01:00
muxator 10172af199 db/API.js: no need to parseInt(time) here
We are already sure that time is an int
2019-03-07 00:02:24 +01:00
muxator b34fc2de2b use Date.now() instead of new Date().getTime()
This is documented to be more performant.

The substitution was made on frontend code, too (i.e., the one in /static),
because Date.now() is supported since IE 9, and we are life supporting only
IE 11.

Commands:
  find . -name *.js | xargs sed --in-place "s/new Date().getTime()/Date.now()/g"
  find . -name *.js | xargs sed --in-place "s/(new Date()).getTime()/Date.now()/g"

Not done on jQuery.
2019-02-26 23:25:15 +01:00
muxator 90bfbeb38d PadMessageHandler.js: fixed logic error in a guard condition
The guard condition on count being non negative and < 100 used the wrong
boolean operator. In its form it was impossible.

This error was introduced in 2013, in 5592c4b0fe.
Fixes #3499
2019-02-27 00:56:41 +01:00
muxator 4b913172fe PadMessageHandler.js: renamed parameter in handleCustomMessage() to avoid name clash 2019-02-26 22:19:49 +01:00
muxator 791012bb9b PadMessageHandler.js: removed redundant return statement 2019-02-26 19:15:22 +01:00
muxator 46fdeb8dc4 ExportTxt.js: getPadTXT() does not need to be exported
This function is used only inside this module, and does not belong to its
external interface.
2019-02-22 23:32:10 +01:00
muxator 169a06793d db/API.js: almost removed optional argument handling
The HTTP API doesn't ever omit arguments, it always passes `undefined` for a
parameter that wasn't supplied in the request.

The functions that were simplified are:
  - getRevisionChangeset()
  - getText()
  - getHTML()
  - saveRevision()

The only function still supporting optional arguments is getPadSafe(), which is
only called from this module.
2019-02-19 00:15:54 +01:00
muxator 26f3f1bcd0 db/Pad.js: make "force" parameter non optional in Pad.prototype.copy()
This function was simulating two overloads:
  1. copy(destinationID, force, callback)
  2. copy(destinationID, callback), in this case "force" would be assumed false

But all the call sites always used the version with arity 3.
Thus, we can remove that optionality and always assume that the funcion will be
called with three parameters. This will simplify future work.
2019-02-13 14:01:24 +01:00
translatewiki.net 1900b00ec2 Localisation updates from https://translatewiki.net. 2019-02-25 10:41:33 +01:00
Sebastian Castro 9848a600e3 colibris: Fixes #3548 #3549 chat improvements 2019-02-22 19:48:46 +01:00
Sebastian Castro 378dbe8485 skins: Improve clientPluginNames class helper
Moving classes to html tag so it can be used to style other part of template depending on plugins like #users, #chat etc...
Rename plugin class with "plugin-" prefix, because there were conflicts with some plugins using the same .ep_font_color class to apply css rules
2019-02-22 19:48:46 +01:00
Sebastian Castro 401db8fce3 chat: Adds placeholder to input. Translate stick button 2019-02-22 19:48:08 +01:00
muxator 59a6f2e9b8 node8: get rid of node < 0.7 compatibility when deleting files.
- path.exists() is no longer part of nodejs
- fs.exists() is deprecated (as of nodejs >= 8)
- checking a file for existence before using it is open to raca condition. It is
  preferable to go ahead and use the file, and eventually handle the error
- we can afford two simple synchronous fs operations here
2019-02-19 22:01:12 +01:00
muxator 6d36bb2c53 node8: we can safely use os.tmpdir()
Since we are requiring node >= 8, we can safely use native functionalities.
2019-02-19 22:01:12 +01:00
muxator 09949c242a node8: we no longer need to use a shim for Object.values in stats.js 2019-02-19 22:01:12 +01:00
muxator 9d35d15ae3 node8: require nodejs >= 8.9.0, npm >= 6.4
Next version will be Etherpad 1.8. As planned in #3424, we are going to require
NodeJS >=8.9.0 and npm >= 6.4.

This commit implements that change and updates documentation and scripts.
Subsequent changes will get rid of old idioms, dating back to node < 0.7, that
still survive in the code.
Once migrated to NodeJS 8, we will be able to start working on migrating the
code base from callbacks to async/await, greatly simplifying legibility (see
#3540).

Closes #3557
2019-02-19 22:01:12 +01:00
muxator 9d9b7c9faf NodeVersion.js: do not use callbacks, simplify calling style in server.js 2019-02-19 00:46:37 +01:00
muxator 36addd2205 server.js: group together the loading of the stats system
No functional changes, this is intended to simplify subsequent patches.
2019-02-19 00:41:51 +01:00
translatewiki.net b16b98f8ca Localisation updates from https://translatewiki.net. 2019-02-18 08:00:31 +01:00
muxator d5d428c4ee windows: allow graceful shutdown on Windows, too
Until Etherpad 1.7.5, process.on('SIGTERM') and process.on('SIGINT') were not
hooked up under Windows, because old nodejs versions did not support them.
This excluded the possibility of doing a graceful shutdown of the database
connection under that platform.

According to nodejs 6.x documentation, it is now safe to do so. This allows to
gracefully close the DB connection when hitting CTRL+C under Windows, for
example.

Source: https://nodejs.org/docs/latest-v6.x/api/process.html#process_signal_events

  - SIGTERM is not supported on Windows, it can be listened on.
  - SIGINT from the terminal is supported on all platforms, and can usually be
    generated with <Ctrl>+C (though this may be configurable). It is not
    generated when terminal raw mode is enabled.
2019-02-16 00:14:39 +01:00
translatewiki.net c333984cd8 Localisation updates from https://translatewiki.net. 2019-02-14 09:09:18 +01:00
muxator 631b23f7a2 utils/AbsolutePaths.js: do not break when running as a Windows manual install
A Windows manual install has the same directory layout of a normal Unix one
(e.g. the nice symlink node_modules/ep_etherpad-lite -> ../src).
Only when running from the pre-built Windows package the directory layout is
different (e.g. src is physically copied into node_modules/ep_etherpad-lite).
The previous version of the code wrongly assumed that all Windows installs would
be run from the pre-built pakage.

In this version the path search is the same on all platform. If it fails, and we
are on Windows, there is a fallback for the specific case of the pre-built
package.

Fixes #3550
2019-02-11 03:28:02 +01:00
muxator 78c057af31 NodeVersion.js: factor out require('semver') 2019-02-08 19:10:49 +01:00
translatewiki.net 2e4ee39cc3 Localisation updates from https://translatewiki.net. 2019-02-07 15:55:56 +01:00
muxator acc0b05702 windows: 1.7.5 was released with node 8.15.0. Document it here. 2019-01-27 13:48:24 +01:00
muxator 4f0a2785da release: prepare for 1.7.5
Written the changelog and updated package.json.
2019-01-26 00:16:03 +01:00
muxator d475cc3d08 package.json: "http://github.com" -> "https://github.com" 2019-01-26 00:12:16 +01:00
muxator 9f31456f84 package.json: list myself among the authors 2019-01-26 00:11:11 +01:00
muxator 25da955161 README.md: on install, explicitly instruct to clone the "master" branch
The install instructions relied on the default branch being "master" on Github.
This has no longer been the case for some time now.

Let's be explicit, and directly advise new users to put themselves on the stable
branch ("master").
2019-01-25 23:05:05 +01:00
Ray Bellis c8e5d87268 api: simplify version table
This commit vastly shortens (and simplifies) the version table within
handler/APIHandler.js by building each version's entry incrementally based off
the previous version.

The resulting table has been validated by comparing the "before" and "after"
output of the following loop on both versions of the code (albeit with an
intermediate "sort" step to account for the different insertion order)

  for (let v in version) {
    let m = version[v];
    for (let [k, a] of Object.entries(m)) {
      console.log(v, k, a);
    }
  }

The patch also fixes a few typos, and removes a duplicate definition of
getChatHistory which in each applicable version was defined with two different
parameter lists, but where only the second would be used.
2019-01-22 22:51:22 +01:00
Joseph C Wang ae49409593 fix for python3 2019-01-22 22:23:18 +01:00
translatewiki.net bd48497ce3 Localisation updates from https://translatewiki.net. 2019-01-17 10:50:43 +01:00
HairyFotr fce55df2b7 Fix typos 2019-01-16 11:14:04 +01:00
translatewiki.net 02b3d42771 Localisation updates from https://translatewiki.net. 2018-12-27 10:48:05 +01:00
Luiza Pagliari 59cae81152
[chore] Allow debug mode on node versions >= 6.3 (#3527)
I've tried to install `node-inspector` using Node 8 and it looks like it is not supported. 

According to the [documentation of that tool](https://www.npmjs.com/package/node-inspector):

> Since version 6.3, Node.js provides a built-in DevTools-based debugger which mostly deprecates Node Inspector (...). The built-in debugger (...) provides certain advanced features (...) that are too difficult to implement in Node Inspector.

As [we require nodejs >= 6.9.0](https://github.com/ether/etherpad-lite#requirements), and as [`node-inspector` only works on Chrome and Opera](https://www.npmjs.com/package/node-inspector#debug), it looks like a good approach to remove the dependency of that tool and use Chrome DevTools directly. Besides, [there are other tools available](https://nodejs.org/en/docs/guides/debugging-getting-started/#inspector-clients) for debugging, if Chrome is not an option.

This PR also allow external connections to the inspector, so Etherpad instances running on containers can also be debugged. [There are obviously some risks to leave that opened on public IPs](https://nodejs.org/en/docs/guides/debugging-getting-started/#exposing-the-debug-port-publicly-is-unsafe), but I assumed no instance would run on debug mode for the final user.
2018-12-22 10:28:50 -02:00
translatewiki.net 7275cdc915 Localisation updates from https://translatewiki.net. 2018-12-17 08:51:24 +01:00
translatewiki.net db27582622 Localisation updates from https://translatewiki.net. 2018-12-10 08:08:01 +01:00
muxator aca8fae682 easysync-full-description: regenerate the pdf document
The .tex source was updated to fix some typos, but the corresponding pdf was not
regenerated.

Command used to generate the pdf:
  pdflatex easysync-full-description.tex

The incorporated changes are:
- 49114d2b7a (2014-06-01)
- c7548450c0 (2017-09-14)
2018-12-09 15:56:17 +01:00
muxator 49449453c9 README: a lot of packages mentioned in the readme are not really needed, simplify
libssl-dev, gzip, python, gcc have never been really needed for Etherpad itself.
They were probably needed back in the day to manually compile nodejs.
2018-12-01 14:16:39 +01:00
muxator 1f927f3e28 README: minor rewording 2018-12-01 14:15:40 +01:00
muxator 76007fe7cb README: removed trailing spaces 2018-12-01 14:11:01 +01:00
muxator 0ad8291ae7 hooks: restore Internet Explorer 11 compatibility.
Compatibility with IE11 regressed in 23eab79946 while working for #3488.
That commit made use of modern js syntax, not supported by IE11.

- Removed arrow functions, replaced with normal functions.
- Removed the spread operator (<...iterable>) and the "new Set()" construct,
  replaced with _.uniq()

At some point IE11 compatibility will be dropped.
Ditching it now, for such a small gain, is not wise.

Fixes #3500.
2018-11-28 20:03:39 +01:00
muxator fe20ffa202 dependencies: update wd, 1.10.3 -> 1.11.1
This is just a dev dependency, so no real risks, but it's better not to scare
users.

Reported vulnerability before this change:

$ npm audit
                       === npm audit security report ===

# Run  npm update cryptiles --depth 4  to resolve 1 vulnerability
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Insufficient Entropy                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ cryptiles                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ wd [dev]                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ wd > request > hawk > cryptiles                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/720                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
2018-11-28 18:49:12 +01:00