Skip to content

Commit

Permalink
Bugfix: early ending end tag
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Feb 15, 2016
1 parent 4768b39 commit f558b7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions svg/svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,12 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
return err
}
case xml.EndTagToken:
t.Data[2+len(t.Text)] = '>'
if _, err := w.Write(t.Data[:2+len(t.Text)+1]); err != nil {
if len(t.Data) > 2+len(t.Text) {
t.Data[2+len(t.Text)] = '>'
if _, err := w.Write(t.Data[:2+len(t.Text)+1]); err != nil {
return err
}
} else if _, err := w.Write(t.Data); err != nil {
return err
}
}
Expand Down
1 change: 1 addition & 0 deletions svg/svg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestSVG(t *testing.T) {
{`<!DOCTYPE bla><?xml?><!-- comment --><metadata/>`, ``},

{`<polygon fill="none" stroke="#000" points="-0.1,"/>`, `<polygon fill="none" stroke="#000" points="-0.1,"/>`}, // #45
{`</0`, `</0`}, // go fuzz
}

m := minify.New()
Expand Down

0 comments on commit f558b7f

Please sign in to comment.