Skip to content

Commit

Permalink
CSS: explicitly check if URL is a data URI before minifying data URI
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Jan 13, 2020
1 parent 70870d2 commit 7c4fdeb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion css/css.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
transparentBytes = []byte("transparent")
initialBytes = []byte("initial")
importantBytes = []byte("!important")
dataSchemeBytes = []byte("data:")
)

type cssMinifier struct {
Expand Down Expand Up @@ -522,7 +523,9 @@ func (c *cssMinifier) minifyTokens(prop Hash, values []Token) []Token {
uri = removeMarkupNewlines(uri)
uri = uri[1 : len(uri)-1]
}
uri = minify.DataURI(c.m, uri)
if 4 < len(uri) && parse.EqualFold(uri[:5], dataSchemeBytes) {
uri = minify.DataURI(c.m, uri)
}
if css.IsURLUnquoted(uri) {
values[i].Data = append(append([]byte("url("), uri...), ')')
} else {
Expand Down

0 comments on commit 7c4fdeb

Please sign in to comment.