Skip to content

Commit

Permalink
use text/template to avoid HTML escaping
Browse files Browse the repository at this point in the history
Co-authored-by: Roy O'Young <roy2220@outlook.com>

Closes #57
  • Loading branch information
willnorris committed Aug 9, 2021
1 parent 058aeeb commit b431030
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (
"errors"
"flag"
"fmt"
"html/template"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
"strings"
"text/template"
"time"

"golang.org/x/sync/errgroup"
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
package main

import (
"html/template"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"text/template"
)

func run(t *testing.T, name string, args ...string) {
Expand Down
2 changes: 1 addition & 1 deletion tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"bufio"
"bytes"
"fmt"
"html/template"
"io/ioutil"
"strings"
"text/template"
"unicode"
)

Expand Down
10 changes: 9 additions & 1 deletion tmpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ package main

import (
"errors"
"html/template"
"os"
"testing"
"text/template"
)

func init() {
Expand Down Expand Up @@ -170,6 +170,14 @@ func TestExecuteTemplate(t *testing.T) {
"/*", " * ", "*/",
"/*\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 {
Expand Down

0 comments on commit b431030

Please sign in to comment.