@@ -14,14 +14,15 @@ import (
14
14
)
15
15
16
16
var (
17
- voidBytes = []byte ("/>" )
18
- isBytes = []byte ("=" )
19
- spaceBytes = []byte (" " )
20
- cdataEndBytes = []byte ("]]>" )
21
- zeroBytes = []byte ("0" )
22
- cssMimeBytes = []byte ("text/css" )
23
- noneBytes = []byte ("none" )
24
- urlBytes = []byte ("url(" )
17
+ voidBytes = []byte ("/>" )
18
+ isBytes = []byte ("=" )
19
+ spaceBytes = []byte (" " )
20
+ cdataEndBytes = []byte ("]]>" )
21
+ zeroBytes = []byte ("0" )
22
+ svgStartTagBytes = []byte ("<svg" )
23
+ cssMimeBytes = []byte ("text/css" )
24
+ noneBytes = []byte ("none" )
25
+ urlBytes = []byte ("url(" )
25
26
)
26
27
27
28
////////////////////////////////////////////////////////////////
@@ -129,9 +130,13 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, params map[stri
129
130
tag = t .Hash
130
131
if tag == Metadata {
131
132
t .Data = nil
132
- } else if colon := bytes .IndexByte (t .Text , ':' ); colon != - 1 || t . Data == nil {
133
+ } else if colon := bytes .IndexByte (t .Data , ':' ); colon != - 1 {
133
134
// skip attributes in namespace (eg. inkscape or sodipodi)
134
- t .Data = nil
135
+ if bytes .Equal (t .Data [:colon ], svgStartTagBytes ) {
136
+ t .Data = append (t .Data [:1 ], t .Data [5 :]... )
137
+ } else {
138
+ t .Data = nil
139
+ }
135
140
} else if tag == Defs && tb .Peek (1 ).TokenType == xml .StartTagCloseVoidToken {
136
141
// skip empty tags
137
142
t .Data = nil
0 commit comments