Limit colour strings to 200 chars, helps reduce effect of potential ReDoS

This commit is contained in:
Lovell Fuller 2025-10-18 14:52:17 +01:00
parent c1c16ed3e6
commit 206eb4a89a

View File

@ -139,7 +139,10 @@ function toColorspace (colorspace) {
* @throws {Error} Invalid value * @throws {Error} Invalid value
*/ */
function _getBackgroundColourOption (value) { function _getBackgroundColourOption (value) {
if (is.object(value) || is.string(value)) { if (
is.object(value) ||
(is.string(value) && value.length >= 3 && value.length <= 200)
) {
const colour = color(value); const colour = color(value);
return [ return [
colour.red(), colour.red(),