Commit graph

1266 commits

Author SHA1 Message Date
John McLear
46dc943101 lint: linestylefilter and rjquery.js 2021-01-14 13:06:34 +00:00
John McLear
c38c34bef4
linting: ace2_inner
* remove IE and add strict headers

* linting: kids are back, need to stop for today

* linting: farbtastic fix

* lint: more lint fixes

* more lint fixes

* linting: sub 100 errors

* comments where I need help

* ready to be helped :)

* small fixes

* fixes

* linting: all errors resolved

* linting: remove note to self

* fix as per nulli/wezz000li suggestion

* fix as per nulli/wezz000li suggestion

* resolve merge conflicts

* better use if to silence eslint

* Use `for..of` with `Object.keys` instead of `for..in`

* lint: move setSelection to before call

Co-authored-by: webzwo0i <webzwo0i@c3d2.de>
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-01-14 10:00:14 +00:00
John McLear
38c9827161
Feature: Scroll to Line number based on Hash IE http://foo.com/p/bar#L10 will scroll to line 10. (#4554)
Includes test coverage
Co-authored-by: webzwo0i <webzwo0i@c3d2.de>
2020-12-26 22:05:08 +01:00
John McLear
e051f2f2f7 lint: scroll.js 2020-12-26 20:43:10 +00:00
Richard Hansen
9f7d42185d socket.io: Reconnect if the server disconnects
This will make the pages gracefully handle HTTP server restart events,
which happen whenever a plugin is installed or uninstalled via the
`/admin/plugins` page.
2020-12-23 16:18:28 -05:00
Richard Hansen
303964c51e socket.io: Factor out client connection logic 2020-12-23 16:18:28 -05:00
Richard Hansen
7eb0f996c3 socket.io: Delete ignored resource option
I couldn't find any reference to a `resource` option in either the
socket.io-client documentation or its source code.
2020-12-23 16:18:28 -05:00
Richard Hansen
ff19181cd1 lint: Fix some straightforward ESLint errors 2020-12-23 16:18:28 -05:00
webzwo0i
790ba72a9e change scroll-behavior to auto
timeslider follow test: ensure there are so much lines in the pad view
below the changed line, so that the changed line will be the first
visible line
2020-12-23 16:18:28 -05:00
John McLear
996a2d86dd lint: chat (#4573)
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-23 16:18:28 -05:00
John McLear
8bf463fb00 lint: broadcast_revisions (#4571)
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-23 16:17:59 -05:00
John McLear
4aef15cb11
lint: collab-client (#4574)
* lint: collab-client

* Undo incorrect lint fixes

These will be re-fixed in a future commit.

* Properly fix guard-for-in error

* Properly fix prefer-rest-params errors

* Move some code back to where it was

Moving the code makes it hard to review the diff.

* Delete DISCONNECT_REASON case

Someone reading the code won't understand what "used to handle
appLevelDisconnectReason" means until they dig through the Git
history. Given the server never sends messages of type
DISCONNECT_REASON anyway, just delete the case.

* Refine lint fixes

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-21 20:19:00 +00:00
Hossein Marzban
170a230c3a
Lint: timeslider (#4580)
Squashed changes from rhansen@rhansen.org:
  * Move code back to where it was. (It's easier to review changes
    when the code isn't moved. This causes some no-use-before-define
    warnings to reappear, but those are just warnings.)
  * Move eslint-disable comment to same line
  * Use `window.clientvars` to resolve no-global-assign
  * Undo changes that aren't about fixing lint errors
2020-12-20 18:24:17 -05:00
John McLear
bca60c8b17 lazydeveloper: remove console log 2020-12-20 10:56:19 +00:00
John McLear
e18b9d1844 timeslider/bugfix: timeslider wasn't updating when new pad contents was created - #4595 2020-12-20 10:45:16 +00:00
John McLear
0362d3b05d
lint: pad prefix files (#4577)
* lint: pad_connectionstatus

* lint: pad_utils

* lint: pad_userlist.js -- still WIP

* shift underscore not to be in require but to be used from window

* lint: pad_modals

* pad_impexp.js

* lint: more errors done

* lint: auto reconn

* lint: pad_editor

* lint: finish auto reconn

* lint: imp exp rework

* lint: import

* lint: pad.js nearly done but pizza here...

* lint: clientVars global query

* put clientVars in window

* Revert incorrect lint fixes

* Properly fix guard-for-in lint errors

* Properly fix no-unused-vars error regarding `gritter`

* Refine lint fixes

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-20 07:15:58 +00:00
Hossein Marzban
34ee77993f
Lint: pluginfw tsort.js (#4576)
* lint: pluginfw tsort.js

* Don't comment out the `console.log()` call

Disabling the log message is out of scope for the pull request.

* Put const and let on separate lines

* Convert `tsort` from function to arrow function

ESLint doesn't complain about this due to a bug in
prefer-arrow/prefer-arrow-functions rule:
https://github.com/TristonJ/eslint-plugin-prefer-arrow/issues/24

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-20 06:18:49 +00:00
Richard Hansen
b82bf5c726 Drop support for Internet Explorer 2020-12-19 19:13:31 +00:00
Richard Hansen
d9b7aa489d pad import/export: Delete dead functions 2020-12-18 09:29:28 +00:00
Richard Hansen
7e50fc2ab5 Delete dead SERVER_MESSAGE and guest handling code
None of this code seems to be reachable. Hopefully no plugins expect
it to exist.
2020-12-18 09:29:28 +00:00
Richard Hansen
f54dcbc766 lint: Re-run eslint --fix 2020-12-16 22:09:48 +00:00
John McLear
92e36b82b5
linting: pad_editbar.js 2020-12-16 12:12:25 +00:00
Hossein Marzban
6f309ac20a
lint: pluginfw/client_plugins (#4572) 2020-12-15 21:40:41 -05:00
Richard Hansen
a44debdcfe Add ' and * to acceptable URL characters
These characters are in the RFC3986 reserved set.

These characters are added to the set of characters that cannot be the
last character of a URL to avoid mislinkification.
2020-12-14 07:03:17 +00:00
Richard Hansen
7d23278ed0 Exclude ?, !, and ) from last character of URL
Now the final character in each of these example strings is no longer
considered part of the URL:
  * Have you seen http://example.com?
  * Look at http://example.com!
  * (see http://example.com)
2020-12-14 07:03:17 +00:00
Richard Hansen
7e8de5540f Factor out common URL regular expression code
This also eliminates the differences between the regular expressions.
2020-12-14 07:03:17 +00:00
Richard Hansen
ca01856f94 lint: Fix some straightforward ESLint errors 2020-12-14 07:03:17 +00:00
Richard Hansen
e66e8a4eb2 pad: Fix wrong variable name in global exception handler
This fixes a bug introduced in commit
c845d985e0.
2020-12-10 22:25:58 +00:00
webzwo0i
d25010d5d7
pluginfw: explicitly install the latest version of a plugin, fix for #4536 (#4543) 2020-12-05 14:08:02 +00:00
Richard Hansen
aa41b0920c admin/plugins: Don't keep adding more Update buttons 2020-11-27 16:59:24 +00:00
Richard Hansen
6a00d7f8d6 admin/plugins: Use jQuery to build the Update button 2020-11-27 16:59:24 +00:00
Richard Hansen
2ddc45bf07 admin/plugins: Simplify jQuery search for plugin actions 2020-11-27 16:59:24 +00:00
Richard Hansen
973644c7dd lint: Fix ESLint errors in /admin/plugins code 2020-11-27 16:59:24 +00:00
Richard Hansen
750c7cb1cf pad: Delete unused ip and userAgent client vars 2020-11-26 15:00:46 +00:00
Richard Hansen
53bc80e381 pad userlist: Use jQuery to create rows
This makes the code easier to read and maintain, and it reduces the
likelihood of introducing an XSS vulnerability.
2020-11-26 15:00:46 +00:00
Ilmar Türk
ba7d80fa57
Update dropdowns on language change (#4519) 2020-11-25 21:39:21 +00:00
Richard Hansen
e247c716c2 editor: Add argument to suppress SonarCloud error
This also makes it easier for devs to understand the expected function
signature.
2020-11-24 20:06:12 +00:00
Richard Hansen
d24306ea6a editor: Delete unused isTimeUp argument
This fixes a SonarCloud error.
2020-11-24 20:06:12 +00:00
Richard Hansen
ed7ba64635 editor: Delete unused optModFunc argument 2020-11-24 20:06:12 +00:00
Richard Hansen
d0114d4ac2 editor: Delete commented-out code 2020-11-24 20:06:12 +00:00
Richard Hansen
bb722763d0 editor: Delete dead code
This silences some SonarCloud errors.
2020-11-24 20:06:12 +00:00
Richard Hansen
8e5fd19db2 lint: Run eslint --fix on src/ 2020-11-24 20:06:12 +00:00
Richard Hansen
0625739cb8 lint: Declare variables above their first use
This makes it possible to convert from `var` to `let` without getting
ReferenceErrors.
2020-11-24 20:06:12 +00:00
Richard Hansen
7df3ded66f lint: Put opening brace on same line as function
Normally I would let `eslint --fix` do this for me, but there's a bug
that causes:

    const x = function ()
    {
      // ...
    };

to become:

    const x = ()
    => {
      // ...
    };

which ESLint thinks is a syntax error. (It probably is; I don't know
enough about the automatic semicolon insertion rules to be confident.)
2020-11-24 20:06:12 +00:00
Richard Hansen
07bcbbd404 pad: Include the stack in the data sent to /jserror 2020-11-17 08:02:27 +00:00
Richard Hansen
c845d985e0 pad: Pop up an error message on unhandled Promise rejection 2020-11-17 08:02:27 +00:00
Richard Hansen
93c335b3b8 pad: Use a relative URL to simplify
Also avoid creating an unnecessary variable.
2020-11-17 08:02:27 +00:00
Richard Hansen
cedd27e4fe plugins: Default the module name to the plugin name 2020-11-13 20:30:27 +00:00
Richard Hansen
afb025030c plugins: Use a log4js logger for npm messages 2020-11-13 20:30:27 +00:00
Richard Hansen
8a918fbc46 plugins: asyncify more functions 2020-11-13 20:30:27 +00:00
Richard Hansen
9f575ebc84 plugins: Delete unused ensure function 2020-11-13 20:30:27 +00:00
Richard Hansen
ac5614dadd plugins: Don't export callInit
It's unused outside of this module.

Also use an arrow function.
2020-11-13 20:30:27 +00:00
Richard Hansen
ba4794cf8a plugins: Call require('./hooks') at top level 2020-11-13 20:30:27 +00:00
Richard Hansen
14a9479e69 plugins: Use functions from fs.promises 2020-11-13 20:30:27 +00:00
Richard Hansen
d624aa936e plugins: Fix plugin name in error messages 2020-11-13 20:30:27 +00:00
ilmar
d5c5ca224b Fix missing arg handling in html10n.js 2020-11-05 10:38:22 +00:00
Richard Hansen
98de2b0899 Use contentEditable for all browsers
This makes it possible to disable `contentEditable` for certain
elements in some circumstances (e.g., on links so that users can click
on them normally).
2020-11-03 19:02:01 +00:00
Richard Hansen
5e2a27a182 Replace setClassPresence(x, ...) with x.classList.toggle(...) 2020-11-03 19:02:01 +00:00
Richard Hansen
4594608c04 Delete commented-out code 2020-11-03 19:02:01 +00:00
Gabriel Medeiros Coelho
ce77c48475 remove unnecessary conditional
if animationState evaluates to -1 or 0, it would end up in a conditional that assign its value to itself. Since this is redundant, it is better to remove this conditional, to avoid an extra check
2020-11-01 01:41:09 -05:00
Richard Hansen
193028702d pad: Don't paste when middle-clicking on a link 2020-10-25 07:06:29 +00:00
John McLear
cb5fcbb74e
editor: allow paste into links (#3802) 2020-10-24 16:59:03 +01:00
Richard Hansen
36aceb3aba hooks: Rewrite callAll and aCallAll for consistency
Rewrite the `callAll` and `aCallAll` functions to support all
reasonable hook behaviors and to report errors for unreasonable
behaviors (e.g., calling the callback twice).

Now a hook function like the following works as expected when invoked
by `aCallAll`:

```
exports.myHookFn = (hookName, context, cb) => {
  cb('some value');
  return;
};
```
2020-10-24 16:08:50 +01:00
Richard Hansen
55939a0d7e hooks: Delete unused flatten function 2020-10-24 16:08:50 +01:00
webzwo0i
1e7a9e1791
tests: better timeslider follow contents (#4421) 2020-10-21 10:05:58 +01:00
Richard Hansen
2379ade7e9 Move out pad.modals.reconnecttimer trailing space 2020-10-20 11:02:37 +01:00
Richard Hansen
734fe9c297 Use jQuery methods to build DOM elements 2020-10-20 11:02:37 +01:00
Richard Hansen
a2554fff22 pad: Pop up an error message dialog box upon socket.io error 2020-10-20 10:01:49 +01:00
Richard Hansen
5b887396c3 pad: Check for null collabClient in socket.io event handlers 2020-10-20 10:01:49 +01:00
Richard Hansen
b1acf6143a pad: Delete do-nothing sendClientReady wrapper 2020-10-20 10:01:49 +01:00
Richard Hansen
a712ce457d gritter: Treat strings as text, not HTML
This forces users to use jQuery or DOM objects if they want
formatting, which helps avoid XSS vulnerabilities.
2020-10-20 10:01:49 +01:00
Richard Hansen
8463134125 pad: Improve rendering of uncaught exceptions
* Use jQuery to build the message HTML so that special characters in
    the error message, URL, etc. are properly escaped. This helps
    avoid XSS vulnerabilities.
  * Use bold text for the error message to make it stand out.
  * Add a line break between the error message and "in <url> at line
    <line>" so that the error message stands out more.
  * Use `<p>...</p>` instead of `</br>` to separate the parts of the
    popup.
  * Use CSS for spacing instead of `</br>`.
  * Grammar fixes (add a missing comma, "at" instead of "in").
2020-10-20 10:01:49 +01:00
Richard Hansen
d35dbaaacc gritter: Accept jQuery or DOM objects for title and text
Teach Gritter to accept anything that jQuery's `.append()` method
accepts for the title and text of a popup message. This makes it
easier to safely build HTML messages with proper escaping of special
characters (to prevent XSS vulnerabilities).
2020-10-20 10:01:49 +01:00
Richard Hansen
d680405f58 pad: Include .js URL in /jserror error report 2020-10-20 10:01:49 +01:00
Richard Hansen
7f79d201e6 CSP: Move index.html inline code to separate .js file 2020-10-12 20:46:06 +01:00
Richard Hansen
a4927095ae CSP: Disable the indexCustomInlineScripts hook 2020-10-11 20:31:00 +01:00
Richard Hansen
052fbb944f
plugins: Delete noisy and useless debug message (#4409)
The debug statement mostly printed the following useless message over
and over, causing Travis CI logs to become truncated:

    [DEBUG] pluginfw - [ undefined ] returning
2020-10-11 09:51:53 +01:00
webzwo0i
a2328cd7f0
timeslider: bugfix: follow pad contents - only goToLineNumber if it exists (#4390) 2020-10-10 16:57:22 +01:00
John McLear
66df0a572f
Security: FEATURE REMOVAL: Remove all plain text password logic and ui (#4178)
This will be a breaking change for some people.  

We removed all internal password control logic.  If this affects you, you have two options:

1. Use a plugin for authentication and use session based pad access (recommended).
1. Use a plugin for password setting.

The reasoning for removing this feature is to reduce the overall security footprint of Etherpad.  It is unnecessary and cumbersome to keep this feature and with the thousands of available authentication methods available in the world our focus should be on supporting those and allowing more granual access based on their implementations (instead of half assed baking our own).
2020-10-07 13:43:54 +01:00
Richard Hansen
ba6bdf35be Make the aceAttribClasses hook harder to misuse 2020-10-07 10:37:56 +01:00
Richard Hansen
5aa318a09b Call the aceAttribClasses hook synchronously
We could instead await the results of the hook, but then all callers
and their callers recursively would have to be converted to async, and
that's a huge change.
2020-10-07 10:37:56 +01:00
Richard Hansen
a8cf434d1d import: Replace the allowAnyoneToImport check with userCanModify
This reduces the number of hoops a user or tool must jump through to
import.
2020-10-05 18:48:16 +01:00
Richard Hansen
2db4b04af3 cookies: Use SameSite=None if in an iframe from another site 2020-10-04 08:57:44 +01:00
Richard Hansen
bf53162cdd cookies: Use Lax instead of Strict for SameSite 2020-10-04 08:57:44 +01:00
Richard Hansen
3ab0f30ac8 cookies: Use js-cookie to read and write cookies
Rather than reinvent the wheel, use a well-tested library to parse and
write cookies. This should also help prevent XSS vulnerabilities
because the library handles special characters such as semicolon.
2020-10-04 08:57:44 +01:00
Richard Hansen
d55edebddd cookies: Refactor pad_cookie.js
* Use the cookie functions from `pad_utils.js`.
  * Delete unused methods, variables, and parameters.
  * Simplify the logic.
  * Use an ES6 class instead of a weird literal thingy.
  * Use `const` instead of `var`.
2020-10-04 08:57:44 +01:00
Richard Hansen
304318b618 webaccess: Move pre-authn authz check to a separate hook
Before this change, the authorize hook was invoked twice: once before
authentication and again after (if settings.requireAuthorization is
true). Now pre-authentication authorization is instead handled by a
new preAuthorize hook, and the authorize hook is only invoked after
the user has authenticated.

Rationale: Without this change it is too easy to write an
authorization plugin that is too permissive. Specifically:

  * If the plugin does not check the path for /admin then a non-admin
    user might be able to access /admin pages.
  * If the plugin assumes that the user has already been authenticated
    by the time the authorize function is called then unauthenticated
    users might be able to gain access to restricted resources.

This change also avoids calling the plugin's authorize function twice
per access, which makes it easier for plugin authors to write an
authorization plugin that is easy to understand.

This change may break existing authorization plugins: After this
change, the authorize hook will no longer be able to authorize
non-admin access to /admin pages. This is intentional. Access to admin
pages should instead be controlled via the `is_admin` user setting,
which can be set in the config file or by an authentication plugin.

Also:
  * Add tests for the authenticate and authorize hooks.
  * Disable the authentication failure delay when testing.
2020-09-27 21:19:58 +01:00
Richard Hansen
1e3aa9edff pad: Revert back to sending CLIENT_READY on reconnect
Commit 0bb8d73ba2 fixed the author ID
that is saved in the socket.io sessioninfo when the client sends a
`CLIENT_READY` with `reconnect` set to true, so it is now safe to undo
the workaround from PR #3868.

Fixes #4331.
2020-09-26 18:32:04 +01:00
Richard Hansen
45ec8326f0 Add a new 'rejected' disconnect reason
This reason will be used in a future commit that will reject erroneous
messages.
2020-09-22 14:09:07 +01:00
Sebastian Castro
12bd617f51
css: Improve toolbar responsiveness for small screen (#4322)
Until now, the "mobile layout" (with right toolbar on bottom of the screen) was displayed only when screen was smaller than 800px. It made the toolbar break for screen about 1000px when a lot of plugins are in the toolbar.
Now instead, we detect with javascript when the toolbar icons overflow the natural space available, and we switch in "mobile layout" in such case
2020-09-19 19:09:30 +01:00
Richard Hansen
5ac5b65aff Pad: Disable toolbar and import/export when reconnecting 2020-09-15 20:04:17 +01:00
Richard Hansen
ed3c82e8c3 Use null, not "null", if sessionID cookie doesn't exist
`decodeURIComponent(null)` returns the string `'null'`, which we don't
want.
2020-09-11 22:10:04 +01:00
Sebastian Castro
818194da90
editor/performance: Fix performance for large pads (#4267)
* Fix line numbers top padding

This old rule was conflicting with new css rules introduced in 1.8.4

* Fixes #4228 Performance degradation for long pads 

Due to layout trashing when calculating new heights
2020-09-08 14:52:26 +01:00
Richard Hansen
da459888dc plugins: Move plugin definitions to avoid monkey patching
Also document the plugin data structures.
2020-09-08 00:50:24 +01:00
Richard Hansen
dcbf876d03 hooks: New mechanism to deprecate hooks
I plan on splitting authFailure into authnFailure and authzFailure so
that separate authentication and authentication plugins can coexist
peacefully. This change will make it possible to mark the authFailure
hook as deprecated (which simply logs a warning).
2020-09-08 00:49:10 +01:00
Richard Hansen
8cf2bcaeb4 plugins: Fix type typo
`exports.parts` is a topologically sorted array, but the intermediate
collection of parts assembled in `plugins.update()` is associative.
2020-09-08 00:47:32 +01:00
Richard Hansen
442fe1e86f pluginfw: Always include the function name in hook_fn_name
Plugin authors are allowed to omit the function name in the `ep.json`
parts definition. For example:

```
{
  "parts": [
    {
      "name": "ep_example",
      "hooks": {
        "authenticate": "ep_example",
        "authFailure": "ep_example"
      }
    }
  ]
}
```

If omitted, the function name is assumed to be the same as the hook
name. Before this change, `hook_fn_name` for the example hooks would
both be `/opt/etherpad-lite/node_modules/ep_example`. Now they are
suffixed with `:authenticate` and `:authFailure`. This improves
logging, and it makes it possible to use `hook_fn_name` to uniquely
identify a particular hook function.
2020-09-05 22:43:17 +01:00
Richard Hansen
6f3e7d14f6 hooks: Always return a list from aCallFirst and callFirst
Every existing caller of `aCallFirst` expects a list and will throw an
exception if given `undefined`. (Nobody calls `callFirst`, except
maybe plugins.)
2020-09-05 20:35:19 +01:00
webzwo0i
d25cd891ae
remove json2, all supported browsers have JSON now (#4198)
cf. https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/JSON
2020-07-28 00:52:25 +01:00
Joas Souza
0835bfeabb
Bugfix: wait promise finish on hooks (#4194)
This commit fixes the error of not waiting the async code to finish.
As the forEach did not wait until the async code finish we may get a
hook set up incorrectly. To fix it, we use an "Array.map" to iterate and
wait the promises to be resolved and then returned
2020-07-23 20:47:59 +01:00