[chore]: Bump github.com/tdewolff/minify/v2 from 2.12.4 to 2.12.5 (#1649)

Bumps [github.com/tdewolff/minify/v2](https://github.com/tdewolff/minify) from 2.12.4 to 2.12.5.
- [Release notes](https://github.com/tdewolff/minify/releases)
- [Commits](https://github.com/tdewolff/minify/compare/v2.12.4...v2.12.5)

---
updated-dependencies:
- dependency-name: github.com/tdewolff/minify/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2023-03-27 15:59:57 +02:00 committed by GitHub
commit 9e1756ce8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 28 deletions

View file

@ -8,6 +8,8 @@
**[JavaScript bindings](https://www.npmjs.com/package/@tdewolff/minify)** install with `npm i @tdewolff/minify`
**[.NET bindings](https://github.com/JKamsker/NMinify)** install with `Install-Package NMinify` or `dotnet add package NMinify`, thanks to Jonas Kamsker for the port
---
*Did you know that the shortest valid piece of HTML5 is `<!doctype html><title>x</title>`? See for yourself at the [W3C Validator](http://validator.w3.org/)!*

View file

@ -18,11 +18,11 @@ var (
// Epsilon is the closest number to zero that is not considered to be zero.
var Epsilon = 0.00001
// Mediatype minifies a given mediatype by removing all whitespace.
// Mediatype minifies a given mediatype by removing all whitespace and lowercasing all parts except strings (which may be case sensitive).
func Mediatype(b []byte) []byte {
j := 0
start := 0
inString := false
start, lastString := 0, 0
for i, c := range b {
if !inString && parse.IsWhitespace(c) {
if start != 0 {
@ -33,13 +33,20 @@ func Mediatype(b []byte) []byte {
start = i + 1
} else if c == '"' {
inString = !inString
if inString {
parse.ToLower(b[lastString:i])
} else {
lastString = j + (i + 1 - start)
}
}
}
if start != 0 {
j += copy(b[j:], b[start:])
return parse.ToLower(b[:j])
parse.ToLower(b[lastString:j])
return b[:j]
}
return parse.ToLower(b)
parse.ToLower(b[lastString:])
return b
}
// DataURI minifies a data URI and calls a minifier by the specified mediatype. Specifications: https://www.ietf.org/rfc/rfc2397.txt.

View file

@ -392,14 +392,15 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
}
if attr.Traits&caselessAttr != 0 {
val = parse.ToLower(val)
if attr.Hash == Enctype || attr.Hash == Codetype || attr.Hash == Accept || attr.Hash == Type && (t.Hash == A || t.Hash == Link || t.Hash == Embed || t.Hash == Object || t.Hash == Source || t.Hash == Script || t.Hash == Style) {
val = minify.Mediatype(val)
}
}
if rawTagHash != 0 && attr.Hash == Type {
rawTagMediatype = parse.Copy(val)
}
if attr.Hash == Enctype || attr.Hash == Codetype || attr.Hash == Accept || attr.Hash == Type && (t.Hash == A || t.Hash == Link || t.Hash == Embed || t.Hash == Object || t.Hash == Source || t.Hash == Script || t.Hash == Style) {
val = minify.Mediatype(val)
}
// default attribute values can be omitted
if !o.KeepDefaultAttrVals && (attr.Hash == Type && (t.Hash == Script && jsMimetypes[string(val)] ||
t.Hash == Style && bytes.Equal(val, cssMimeBytes) ||

View file

@ -137,7 +137,7 @@ var tagMap = map[Hash]traits{
}
var attrMap = map[Hash]traits{
Accept: caselessAttr,
Accept: trimAttr,
Accept_Charset: caselessAttr,
Action: urlAttr,
Align: caselessAttr,
@ -156,7 +156,7 @@ var attrMap = map[Hash]traits{
Classid: urlAttr,
Clear: caselessAttr,
Codebase: urlAttr,
Codetype: caselessAttr,
Codetype: trimAttr,
Color: caselessAttr,
Cols: trimAttr,
Colspan: trimAttr,
@ -172,7 +172,7 @@ var attrMap = map[Hash]traits{
Dir: caselessAttr,
Disabled: booleanAttr,
Enabled: booleanAttr,
Enctype: caselessAttr,
Enctype: trimAttr,
Face: caselessAttr,
Formaction: urlAttr,
Formnovalidate: booleanAttr,
@ -228,7 +228,7 @@ var attrMap = map[Hash]traits{
Text: caselessAttr,
Translate: caselessAttr,
Truespeed: booleanAttr,
Type: caselessAttr,
Type: trimAttr,
Typemustmatch: booleanAttr,
Undeterminate: booleanAttr,
Usemap: urlAttr,

View file

@ -280,12 +280,7 @@ func replaceEntities(b []byte, i int, entitiesMap map[string][]byte, revEntities
} else if r[0] == '&' {
// check if for example &amp; is followed by something that could potentially be an entity
k := j + 1
if k < len(b) && b[k] == '#' {
k++
}
for ; k < len(b) && k-j <= MaxEntityLength && (b[k] >= '0' && b[k] <= '9' || b[k] >= 'a' && b[k] <= 'z' || b[k] >= 'A' && b[k] <= 'Z'); k++ {
}
if k < len(b) && b[k] == ';' {
if k < len(b) && (b[k] >= '0' && b[k] <= '9' || b[k] >= 'a' && b[k] <= 'z' || b[k] >= 'A' && b[k] <= 'Z' || b[k] == '#') {
return b, k
}
}