File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 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){
157157 if ( '/' != css . charAt ( 0 ) || '*' != css . charAt ( 1 ) ) return ;
158158
159159 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 ;
161161 i += 2 ;
162162
163+ if ( "" === css . charAt ( i - 1 ) ) {
164+ return error ( 'End of comment missing' ) ;
165+ }
166+
163167 var str = css . slice ( 2 , i - 2 ) ;
164168 column += 2 ;
165169 updatePosition ( str ) ;
Original file line number Diff line number Diff line change @@ -45,4 +45,19 @@ describe('parse(str)', function(){
4545 parse ( 'b { color: red; }\n{ color: green; }\na {color: blue; }' ) ;
4646 } ) ;
4747 } )
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+ } )
4863} )
You can’t perform that action at this time.
0 commit comments