fuzz.go 644 B

12345678910111213141516171819202122232425262728293031
  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. //go:build gofuzz
  5. package html
  6. import (
  7. "fmt"
  8. )
  9. func Fuzz(data []byte) int {
  10. v := string(data)
  11. e := EscapeString(v)
  12. u := UnescapeString(e)
  13. if v != u {
  14. fmt.Printf("v = %q\n", v)
  15. fmt.Printf("e = %q\n", e)
  16. fmt.Printf("u = %q\n", u)
  17. panic("not equal")
  18. }
  19. // As per the documentation, this isn't always equal to v, so it makes
  20. // no sense to check for equality. It can still be interesting to find
  21. // panics in it though.
  22. EscapeString(UnescapeString(v))
  23. return 0
  24. }