allow option to make pad names case-insensitive (#5501) by @DanielHabenicht

* New option to make pad names case-insensitive

fixes #3844

* fix helper.gotoTimeslider()

* fix helper.aNewPad() return value

* Update src/node/utils/Settings.js

Co-authored-by: Richard Hansen <rhansen@rhansen.org>

* remove timeout

* rename enforceLowerCasePadIds to lowerCasePadIds

* use before and after hooks

* update with socket specific test

* enforce sanitizing padID for websocket connections

- only enforce for newly created pads, to combat case-sensitive pad name hijacking

* Added updated package.json file.

---------

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
Co-authored-by: SamTV12345 <40429738+samtv12345@users.noreply.github.com>
This commit is contained in:
DanielHabenicht 2023-07-03 20:52:49 +02:00 committed by GitHub
parent 22704f7dff
commit 675c0130b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 950 additions and 858 deletions

View file

@ -22,6 +22,7 @@
const CustomError = require('../utils/customError');
const Pad = require('../db/Pad');
const db = require('./DB');
const settings = require('../utils/Settings');
/**
* A cache of all loaded Pads.
@ -170,6 +171,8 @@ exports.sanitizePadId = async (padId) => {
padId = padId.replace(from, to);
}
if (settings.lowerCasePadIds) padId = padId.toLowerCase();
// we're out of possible transformations, so just return it
return padId;
};

View file

@ -236,6 +236,11 @@ exports.handleMessage = async (socket, message) => {
padID: message.padId,
token: message.token,
};
// Pad does not exist, so we need to sanitize the id
if (!(await padManager.doesPadExist(thisSession.auth.padID))) {
thisSession.auth.padID = await padManager.sanitizePadId(thisSession.auth.padID);
}
const padIds = await readOnlyManager.getIds(thisSession.auth.padID);
thisSession.padId = padIds.padId;
thisSession.readOnlyPadId = padIds.readOnlyPadId;

View file

@ -430,6 +430,11 @@ exports.importMaxFileSize = 50 * 1024 * 1024;
*/
exports.enableAdminUITests = false;
/*
* Enable auto conversion of pad Ids to lowercase.
* e.g. /p/EtHeRpAd to /p/etherpad
*/
exports.lowerCasePadIds = false;
// checks if abiword is avaiable
exports.abiwordAvailable = () => {