File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1153,7 +1153,11 @@ exports.maxSatisfying = maxSatisfying;
11531153function maxSatisfying ( versions , range , loose ) {
11541154 var max = null ;
11551155 var maxSV = null ;
1156- var rangeObj = new Range ( range , loose ) ;
1156+ try {
1157+ var rangeObj = new Range ( range , loose ) ;
1158+ } catch ( er ) {
1159+ return null ;
1160+ }
11571161 versions . forEach ( function ( v ) {
11581162 if ( rangeObj . test ( v ) ) { // satisfies(v, range, loose)
11591163 if ( ! max || maxSV . compare ( v ) === - 1 ) { // compare(max, v, true)
@@ -1169,7 +1173,11 @@ exports.minSatisfying = minSatisfying;
11691173function minSatisfying ( versions , range , loose ) {
11701174 var min = null ;
11711175 var minSV = null ;
1172- var rangeObj = new Range ( range , loose ) ;
1176+ try {
1177+ var rangeObj = new Range ( range , loose ) ;
1178+ } catch ( er ) {
1179+ return null ;
1180+ }
11731181 versions . forEach ( function ( v ) {
11741182 if ( rangeObj . test ( v ) ) { // satisfies(v, range, loose)
11751183 if ( ! min || minSV . compare ( v ) === 1 ) { // compare(min, v, true)
Original file line number Diff line number Diff line change @@ -890,3 +890,10 @@ test('sorting', function(t) {
890890 t . same ( semver . rsort ( list ) , rsorted ) ;
891891 t . end ( ) ;
892892} ) ;
893+
894+ test ( 'bad ranges in max/min satisfying' , function ( t ) {
895+ var r = 'some frogs and sneks-v2.5.6' ;
896+ t . equal ( semver . maxSatisfying ( [ ] , r ) , null ) ;
897+ t . equal ( semver . minSatisfying ( [ ] , r ) , null ) ;
898+ t . end ( ) ;
899+ } ) ;
You can’t perform that action at this time.
0 commit comments