From facda8281e680b6b21bafadeb1ef6943ec8a49ae Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 6 Dec 2022 01:19:33 +0100 Subject: [PATCH 1/2] fix(isRgbColor): add missing RegExp anchor (end-of-string) fixes #2113 --- src/lib/isRgbColor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/isRgbColor.js b/src/lib/isRgbColor.js index e6508e29a..9458522ab 100644 --- a/src/lib/isRgbColor.js +++ b/src/lib/isRgbColor.js @@ -2,8 +2,8 @@ import assertString from './util/assertString'; const rgbColor = /^rgb\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){2}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\)$/; const rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/; -const rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)/; -const rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)/; +const rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)$/; +const rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/; export default function isRgbColor(str, includePercentValues = true) { assertString(str); From 67ba92632321f7bdbecb477c7f181896d1da6973 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 6 Dec 2022 01:21:08 +0100 Subject: [PATCH 2/2] test(isRgbColor): add additional invalid tests related to #2113 --- test/validators.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/validators.test.js b/test/validators.test.js index 0405a7d2f..5d9b03e76 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -4359,6 +4359,8 @@ describe('Validators', () => { 'rgba(3,3,3%,.3)', 'rgb(101%,101%,101%)', 'rgba(3%,3%,101%,0.3)', + 'rgb(101%,101%,101%) additional invalid string part', + 'rgba(3%,3%,101%,0.3) additional invalid string part', ], });