Jelajahi Sumber

Fix ReDos in Color.js

Yeting Li 4 tahun lalu
induk
melakukan
0f5de4f5da
1 mengubah file dengan 2 tambahan dan 2 penghapusan
  1. 2 2
      src/math/Color.js

+ 2 - 2
src/math/Color.js

@@ -169,14 +169,14 @@ class Color {
 
 			let color;
 			const name = m[ 1 ];
-			const components = m[ 2 ];
+			const components = m[ 2 ].replace(/^\s*/, '');
 
 			switch ( name ) {
 
 				case 'rgb':
 				case 'rgba':
 
-					if ( color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
+					if ( color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
 
 						// rgb(255,0,0) rgba(255,0,0,0.5)
 						this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;