etherpad-lite/src
John McLear ce038b0b0f
fix(pad): keep token-less Delete pad reachable without pad-wide settings (#7959) (#7960)
* fix(pad): keep token-less Delete pad reachable without pad-wide settings (#7959)

The token-less "Delete pad" button (#delete-pad) was nested inside the
enablePadWideSettings-gated pad-settings section, so disabling pad-wide
settings removed the only way to delete a pad without a recovery token.
Combined with #7926 hiding the token disclosure when deletion needs no
token (e.g. allowPadDeletionByAllUsers), a user who was allowed to delete
could be left with no deletion UI at all.

Pad deletion is unrelated to pad-wide settings, so:

- Move #delete-pad out of the enablePadWideSettings block in pad.html; it
  is now always rendered and hidden by default.
- Add a canDeletePad clientVar (isCreator || allowPadDeletionByAllUsers)
  and drive the button's visibility from it in pad_editor.ts, mirroring the
  existing canDeleteWithoutToken handling for the token disclosure.

The two controls are now mutually coherent and neither depends on
enablePadWideSettings: the plain button shows when this session can delete
without a token, the recovery-token disclosure shows otherwise.

Tests:
- backend padDeletionUiPlacement.ts: #delete-pad is rendered with
  enablePadWideSettings both on and off (fails without the template move).
- backend socketio.ts: canDeletePad reflects the creator/allow-all matrix,
  including a non-creator who only gains it under allowPadDeletionByAllUsers.
- frontend pad_settings.spec.ts: asserts #delete-pad is no longer a
  descendant of #pad-settings-section.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(pad): never let readonly sessions delete via token-less paths (#7959)

Qodo review of #7960: `canDeletePad` was `isCreator || allowPadDeletionByAllUsers`,
so under allowPadDeletionByAllUsers a readonly viewer received
canDeletePad=true and the relocated #delete-pad button unhid for them.
Worse, the server-side handlePadDelete `flagOk`/`creatorOk` branches never
checked session.readonly either, so a readonly-link holder could actually
delete the pad without a token — a data-loss hole that the new always-rendered
button would expose.

Exclude readonly sessions from both the clientVar and the server's token-less
authorization paths. A valid recovery token (tokenOk) stays a sufficient
credential regardless of session mode.

Test: socketio.ts asserts a readonly viewer gets canDeletePad=false and that a
token-less PAD_DELETE from a readonly session leaves the pad intact (red before
this change on the clientVar assertion).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 15:18:23 +01:00
..
locales Localisation updates from https://translatewiki.net. 2026-06-15 14:03:51 +02:00
node fix(pad): keep token-less Delete pad reachable without pad-wide settings (#7959) (#7960) 2026-06-17 15:18:23 +01:00
static fix(pad): keep token-less Delete pad reachable without pad-wide settings (#7959) (#7960) 2026-06-17 15:18:23 +01:00
templates fix(pad): keep token-less Delete pad reachable without pad-wide settings (#7959) (#7960) 2026-06-17 15:18:23 +01:00
tests fix(pad): keep token-less Delete pad reachable without pad-wide settings (#7959) (#7960) 2026-06-17 15:18:23 +01:00
.eslintrc.cjs Feat/admin react (#6211) 2024-03-09 23:07:09 +01:00
ep.json feat(updater): tier 2 — manual-click update from /admin/update (#7607) (#7704) 2026-05-10 09:00:07 +01:00
etherpad_icon.svg Change favicon to be closer to new style 2020-04-19 18:20:21 +02:00
package.json build(deps): bump undici from 8.4.1 to 8.5.0 (#7972) 2026-06-17 15:17:49 +01:00
playwright.config.ts test(playwright): un-skip ep_headings2 spec under WITH_PLUGINS (#7634) 2026-04-30 06:12:23 +01:00
README.md remove one less warning during install by having a readme placeholder 2013-02-10 03:04:08 +00:00
tsconfig.json 🩹 — Avoid duplicate key "types" in tsconfig (#7610) 2026-04-28 13:06:43 +08:00
vitest.config.ts Feat/changeset ts (#6594) 2024-08-18 12:14:24 +02:00
web.config Added typescript to etherpad 2024-02-05 21:13:02 +01:00

Ignore this file and see the file in the base installation folder