Skip to content

Commit be94337

Browse files
authored
Apply regex change to address DoS vulnerability
This is a stop-gap measure to patch a known vulnerability with the version of three we currently use in bootstrap. We'll work on updating and using the latest publicly-available version once we have time to deal with the breaking changes it brings with it.
1 parent 4541808 commit be94337

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

build/three.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// threejs.org/license
12
(function (global, factory) {
23
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
34
typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -8070,7 +8071,7 @@
80708071

80718072
var m;
80728073

8073-
if ( m = /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec( style ) ) {
8074+
if ( m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec( style ) ) {
80748075

80758076
// rgb / hsl
80768077

@@ -8083,7 +8084,7 @@
80838084
case 'rgb':
80848085
case 'rgba':
80858086

8086-
if ( color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
8087+
if ( color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
80878088

80888089
// rgb(255,0,0) rgba(255,0,0,0.5)
80898090
this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;
@@ -8096,7 +8097,7 @@
80968097

80978098
}
80988099

8099-
if ( color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
8100+
if ( color = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
81008101

81018102
// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
81028103
this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;
@@ -8114,7 +8115,7 @@
81148115
case 'hsl':
81158116
case 'hsla':
81168117

8117-
if ( color = /^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
8118+
if ( color = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
81188119

81198120
// hsl(120,50%,50%) hsla(120,50%,50%,0.5)
81208121
var h = parseFloat( color[ 1 ] ) / 360;

build/three.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/three.module.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// threejs.org/license
12
// Polyfills
23

34
if ( Number.EPSILON === undefined ) {
@@ -8064,7 +8065,7 @@ Object.assign( Color.prototype, {
80648065

80658066
var m;
80668067

8067-
if ( m = /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec( style ) ) {
8068+
if ( m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec( style ) ) {
80688069

80698070
// rgb / hsl
80708071

@@ -8077,7 +8078,7 @@ Object.assign( Color.prototype, {
80778078
case 'rgb':
80788079
case 'rgba':
80798080

8080-
if ( color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
8081+
if ( color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
80818082

80828083
// rgb(255,0,0) rgba(255,0,0,0.5)
80838084
this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;
@@ -8090,7 +8091,7 @@ Object.assign( Color.prototype, {
80908091

80918092
}
80928093

8093-
if ( color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
8094+
if ( color = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
80948095

80958096
// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
80968097
this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;
@@ -8108,7 +8109,7 @@ Object.assign( Color.prototype, {
81088109
case 'hsl':
81098110
case 'hsla':
81108111

8111-
if ( color = /^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
8112+
if ( color = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
81128113

81138114
// hsl(120,50%,50%) hsla(120,50%,50%,0.5)
81148115
var h = parseFloat( color[ 1 ] ) / 360;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "three",
3-
"version": "0.112.1",
3+
"version": "0.112.2",
44
"description": "JavaScript 3D library",
55
"main": "build/three.js",
66
"module": "build/three.module.js",

src/math/Color.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Object.assign( Color.prototype, {
169169

170170
var m;
171171

172-
if ( m = /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec( style ) ) {
172+
if ( m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec( style ) ) {
173173

174174
// rgb / hsl
175175

@@ -182,7 +182,7 @@ Object.assign( Color.prototype, {
182182
case 'rgb':
183183
case 'rgba':
184184

185-
if ( color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
185+
if ( color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
186186

187187
// rgb(255,0,0) rgba(255,0,0,0.5)
188188
this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;
@@ -195,7 +195,7 @@ Object.assign( Color.prototype, {
195195

196196
}
197197

198-
if ( color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
198+
if ( color = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
199199

200200
// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
201201
this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;
@@ -213,7 +213,7 @@ Object.assign( Color.prototype, {
213213
case 'hsl':
214214
case 'hsla':
215215

216-
if ( color = /^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
216+
if ( color = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
217217

218218
// hsl(120,50%,50%) hsla(120,50%,50%,0.5)
219219
var h = parseFloat( color[ 1 ] ) / 360;

0 commit comments

Comments
 (0)