etherpad-lite/src/node/hooks/express
John McLear 2814e5b913
fix: dev mode entrypoint paths respect x-proxy-path header (#7472)
* fix: prevent race condition in session cleanup timeout

When the cleanup timeout fires, check the in-memory exp.real before
reading from the DB. If touch() extended the expiry (but the old
timeout fires late, e.g. on slow CI), reschedule instead of reading
potentially stale cached data from the DB and destroying the session.

Also increased test expiry times so the "touch after eligible for
refresh" test isn't sensitive to event loop delays on slow machines.

Fixes flaky SessionStore test from #7448.

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

* fix: dev mode entrypoint paths respect x-proxy-path header

In dev mode, the /watch/* script paths were hard-coded as absolute
paths without considering the x-proxy-path header used for subdirectory
reverse proxy setups. This caused 404s for the script tags when hosting
Etherpad on a subdirectory URL (e.g., /pad).

Now reads the x-proxy-path header from the request and prefixes the
entrypoint path, matching how admin.ts handles proxy paths.

Fixes #7137

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

* test: make proxy path tests deterministic in production mode

Tests now verify entrypoint paths and x-proxy-path header handling
in production mode (where tests run) rather than conditionally
asserting only in dev mode.

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

* security: sanitize x-proxy-path header to prevent XSS

The header value was injected directly into <script src="...">
without sanitization. An attacker who can set request headers could
inject arbitrary HTML/JS. Now only allows path-safe characters.

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

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 13:32:33 +01:00
..
admin.ts chore: fix minor issue on admin retrieval 2025-09-08 20:11:45 +02:00
adminplugins.ts feat: disable stats endpoint if enableMetrics is false 2025-07-27 22:22:18 +02:00
adminsettings.ts Enforce 2-space indentation across codebase (#7426) 2026-04-01 19:48:45 +01:00
apicalls.ts chore: fixed objectAsString 2025-08-01 21:58:10 +02:00
errorhandling.ts Added typescript to etherpad 2024-02-05 21:13:02 +01:00
importexport.ts feat: make cookie names configurable with prefix setting (#7450) 2026-04-05 01:58:29 +01:00
openapi.ts fix: POST API requests with JSON body no longer time out (#7455) 2026-04-05 01:58:35 +01:00
padurlsanitize.ts Added typescript to etherpad 2024-02-05 21:13:02 +01:00
pwa.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
socketio.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
specialpages.ts fix: dev mode entrypoint paths respect x-proxy-path header (#7472) 2026-04-06 13:32:33 +01:00
static.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
tokenTransfer.ts feat: make cookie names configurable with prefix setting (#7450) 2026-04-05 01:58:29 +01:00
webaccess.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00