File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -157,9 +157,13 @@ module.exports = function(css, options){
157
157
if ( '/' != css . charAt ( 0 ) || '*' != css . charAt ( 1 ) ) return ;
158
158
159
159
var i = 2 ;
160
- while ( null != css . charAt ( i ) && ( '*' != css . charAt ( i ) || '/' != css . charAt ( i + 1 ) ) ) ++ i ;
160
+ while ( "" != css . charAt ( i ) && ( '*' != css . charAt ( i ) || '/' != css . charAt ( i + 1 ) ) ) ++ i ;
161
161
i += 2 ;
162
162
163
+ if ( "" === css . charAt ( i - 1 ) ) {
164
+ return error ( 'End of comment missing' ) ;
165
+ }
166
+
163
167
var str = css . slice ( 2 , i - 2 ) ;
164
168
column += 2 ;
165
169
updatePosition ( str ) ;
Original file line number Diff line number Diff line change @@ -45,4 +45,19 @@ describe('parse(str)', function(){
45
45
parse ( 'b { color: red; }\n{ color: green; }\na {color: blue; }' ) ;
46
46
} ) ;
47
47
} )
48
+
49
+ it ( 'should throw when a broken comment is found' , function ( ) {
50
+ assert . throws ( function ( ) {
51
+ parse ( 'thing { color: red; } /* b { color: blue; }' ) ;
52
+ } ) ;
53
+
54
+ assert . throws ( function ( ) {
55
+ parse ( '/*' ) ;
56
+ } ) ;
57
+
58
+ /* Nested comments should be fine */
59
+ assert . doesNotThrow ( function ( ) {
60
+ parse ( '/* /* */' ) ;
61
+ } ) ;
62
+ } )
48
63
} )
You can’t perform that action at this time.
0 commit comments