Source file src/html/fuzz.go
1 // Copyright 2019 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build gofuzz 6 7 package html 8 9 import ( 10 "fmt" 11 ) 12 13 func Fuzz(data []byte) int { 14 v := string(data) 15 16 e := EscapeString(v) 17 u := UnescapeString(e) 18 if v != u { 19 fmt.Printf("v = %q\n", v) 20 fmt.Printf("e = %q\n", e) 21 fmt.Printf("u = %q\n", u) 22 panic("not equal") 23 } 24 25 // As per the documentation, this isn't always equal to v, so it makes 26 // no sense to check for equality. It can still be interesting to find 27 // panics in it though. 28 EscapeString(UnescapeString(v)) 29 30 return 0 31 } 32