Skip to content

Commit b431030

Browse files
committed
use text/template to avoid HTML escaping
Co-authored-by: Roy O'Young <[email protected]> Closes #57
1 parent 058aeeb commit b431030

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import (
2121
"errors"
2222
"flag"
2323
"fmt"
24-
"html/template"
2524
"io/ioutil"
2625
"log"
2726
"os"
2827
"path/filepath"
2928
"regexp"
3029
"strings"
30+
"text/template"
3131
"time"
3232

3333
"golang.org/x/sync/errgroup"

main_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
package main
1616

1717
import (
18-
"html/template"
1918
"io/ioutil"
2019
"os"
2120
"os/exec"
2221
"path/filepath"
2322
"strings"
2423
"testing"
24+
"text/template"
2525
)
2626

2727
func run(t *testing.T, name string, args ...string) {

tmpl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import (
1818
"bufio"
1919
"bytes"
2020
"fmt"
21-
"html/template"
2221
"io/ioutil"
2322
"strings"
23+
"text/template"
2424
"unicode"
2525
)
2626

tmpl_test.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ package main
1616

1717
import (
1818
"errors"
19-
"html/template"
2019
"os"
2120
"testing"
21+
"text/template"
2222
)
2323

2424
func init() {
@@ -170,6 +170,14 @@ func TestExecuteTemplate(t *testing.T) {
170170
"/*", " * ", "*/",
171171
"/*\n * HYS\n*/\n\n",
172172
},
173+
174+
// ensure we don't escape HTML characters by using the wrong template package
175+
{
176+
"{{.Holder}}",
177+
licenseData{Holder: "A&Z"},
178+
"", "", "",
179+
"A&Z\n\n",
180+
},
173181
}
174182

175183
for _, tt := range tests {

0 commit comments

Comments
 (0)