From a1373e2e4f7323d30b2c8b05c3e51aa2e9dd07ec Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 3 Jan 2022 07:28:49 -0500 Subject: [PATCH] CSS: Justify use of rtrim on CSS property values CSS does not acknowledge carriage return or form feed characters as whitespace but it does replace them with whitespace, making it acceptable to use `rtrim`. Closes gh-4956 (cherry picked from commit 655c0ed5e204b1f6427e09d615a49586a7bc84eb) --- src/css/curCSS.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/css/curCSS.js b/src/css/curCSS.js index 9d8750973..85c867a96 100644 --- a/src/css/curCSS.js +++ b/src/css/curCSS.js @@ -32,6 +32,12 @@ function curCSS( elem, name, computed ) { // trim whitespace for custom property (issue gh-4926) if ( isCustomProp ) { + + // rtrim treats U+000D CARRIAGE RETURN and U+000C FORM FEED + // as whitespace while CSS does not, but this is not a problem + // because CSS preprocessing replaces them with U+000A LINE FEED + // (which *is* CSS whitespace) + // https://www.w3.org/TR/css-syntax-3/#input-preprocessing ret = ret.replace( rtrimCSS, "$1" ); }