fix: spaceless @import cause infinite loop (#136)

This commit is contained in:
makoto tsuyuki 2017-02-27 23:15:22 -08:00 committed by Remy Sharp
parent bacf080d09
commit 3fa5f7ea67
3 changed files with 5 additions and 3 deletions

View File

@ -56,7 +56,7 @@ function getImports(root, css) {
if (position !== -1) {
inliner.jobs.add('link', 1);
var match = (css.match(/@import\s*(.*?);/) || [null, ''])[1];
var match = (css.match(/@import(\s*.*?);/) || [null, ''])[1];
var url = match.replace(/url/, '')
.replace(/['}"()]/g, '')
.replace(/;/, '')
@ -74,7 +74,7 @@ function getImports(root, css) {
importedCSS = '@media ' + url.join(' ') + '{' + importedCSS + '}';
}
css = css.replace('@import ' + match, importedCSS);
css = css.replace('@import' + match, importedCSS);
return getImports.call(inliner, root, css);
});
}

View File

@ -1 +1 @@
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>inline style</title> <style> p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; @media screen and orientation:landscape{p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}};</style> </head> <body> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>inline style</title> <style> p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; @media screen and orientation:landscape{p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;};</style> </head> <body> </body> </html>

View File

@ -12,6 +12,8 @@
@import 'import.css';
/* four */
@import url('import.css') screen and (orientation:landscape);
/* five */
@import"import.css";
</style>
</head>
<body>