@@ -14,14 +14,15 @@ import (
1414)
1515
1616var (
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(" )
2526)
2627
2728////////////////////////////////////////////////////////////////
@@ -129,9 +130,13 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, params map[stri
129130 tag = t .Hash
130131 if tag == Metadata {
131132 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 {
133134 // 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+ }
135140 } else if tag == Defs && tb .Peek (1 ).TokenType == xml .StartTagCloseVoidToken {
136141 // skip empty tags
137142 t .Data = nil
0 commit comments