File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1- var embeddedRegexp = / d a t a : ( .* ?) ; b a s e 6 4 , / ;
1+ var embeddedRegexp = / ^ d a t a : ( .* ?) , ( . * ? ) / ;
22var commentRegexp = / \/ \* ( [ \s \S ] * ?) \* \/ / g;
33var urlsRegexp = / ( (?: @ i m p o r t \s + ) ? u r l \s * \( \s * [ ' " ] ? ) ( .* ?) ( [ ' " ] ? \s * \) ) | ( @ i m p o r t \s + [ ' " ] ? ) ( [ ^ ; ' " ] + ) / ig;
44
55function isEmbedded ( src ) {
6- return embeddedRegexp . test ( src ) ;
6+ return embeddedRegexp . test ( src . trim ( ) ) ;
77}
88
99function getUrls ( text ) {
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ describe('Parse css urls', function(){
121121 } ) ;
122122 } ) ;
123123
124- describe ( 'base64 dataURI ' , function ( ) {
124+ describe ( 'Data URI ' , function ( ) {
125125 it ( 'should ignore base64 encoded images' , function ( ) {
126126 var text = '\
127127 div.image { \
@@ -150,5 +150,23 @@ describe('Parse css urls', function(){
150150 urls . should . be . instanceof ( Array ) ;
151151 urls . should . have . length ( 0 ) ;
152152 } ) ;
153+
154+ it ( 'should ignore utf-8 encoded data uri' , function ( ) {
155+ var text = 'img.grayscale { \
156+ filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'></svg>"); \
157+ }' ;
158+ var urls = parseCssUrls ( text ) ;
159+ urls . should . be . instanceof ( Array ) ;
160+ urls . should . have . length ( 0 ) ;
161+ } ) ;
162+
163+ it ( 'should ignore minimal data uri ("data:,")' , function ( ) {
164+ var text = 'img.grayscale { \
165+ filter: url("data:,"); \
166+ }' ;
167+ var urls = parseCssUrls ( text ) ;
168+ urls . should . be . instanceof ( Array ) ;
169+ urls . should . have . length ( 0 ) ;
170+ } )
153171 } ) ;
154172} ) ;
You can’t perform that action at this time.
0 commit comments