Black Lives Matter. Support the Equal Justice Initiative.

Source file src/html/fuzz.go

Documentation: html

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

View as plain text