use text/template to avoid HTML escaping

Co-authored-by: Roy O'Young <roy2220@outlook.com>

Closes #57
This commit is contained in:
Will Norris
2021-07-29 00:25:56 -07:00
parent 058aeeb7be
commit b431030b15
4 changed files with 12 additions and 4 deletions

View File

@@ -21,13 +21,13 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"html/template"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings" "strings"
"text/template"
"time" "time"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"

View File

@@ -15,13 +15,13 @@
package main package main
import ( import (
"html/template"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
"text/template"
) )
func run(t *testing.T, name string, args ...string) { func run(t *testing.T, name string, args ...string) {

View File

@@ -18,9 +18,9 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"fmt" "fmt"
"html/template"
"io/ioutil" "io/ioutil"
"strings" "strings"
"text/template"
"unicode" "unicode"
) )

View File

@@ -16,9 +16,9 @@ package main
import ( import (
"errors" "errors"
"html/template"
"os" "os"
"testing" "testing"
"text/template"
) )
func init() { func init() {
@@ -170,6 +170,14 @@ func TestExecuteTemplate(t *testing.T) {
"/*", " * ", "*/", "/*", " * ", "*/",
"/*\n * HYS\n*/\n\n", "/*\n * HYS\n*/\n\n",
}, },
// ensure we don't escape HTML characters by using the wrong template package
{
"{{.Holder}}",
licenseData{Holder: "A&Z"},
"", "", "",
"A&Z\n\n",
},
} }
for _, tt := range tests { for _, tt := range tests {