Skip to content

Commit e14ee7b

Browse files
authored
Merge pull request #4269 from jandubois/file-with-tabs
Embedded files with tabs or return characters must be base64 encoded
2 parents 81f2a91 + 2e51971 commit e14ee7b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/limatmpl/embed.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ func encodeScriptReason(script string) string {
566566
start := 0
567567
line := 1
568568
for i, r := range script {
569-
if !(unicode.IsPrint(r) || r == '\n' || r == '\r' || r == '\t') {
569+
if !(unicode.IsPrint(r) || r == '\n') {
570570
return fmt.Sprintf("unprintable character %q at offset %d", r, i)
571571
}
572572
// maxLineLength includes final newline

pkg/limatmpl/embed_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,11 @@ func TestEncodeScriptReason(t *testing.T) {
503503
reason := encodeScriptReason("abc\a123")
504504
assert.Equal(t, reason, "unprintable character '\\a' at offset 3")
505505
})
506+
t.Run("contains a tab character", func(t *testing.T) {
507+
// newline character is included in character count
508+
reason := encodeScriptReason("foo\tbar")
509+
assert.Equal(t, reason, "unprintable character '\\t' at offset 3")
510+
})
506511
t.Run("long line", func(t *testing.T) {
507512
// newline character is included in character count
508513
reason := encodeScriptReason("line 1\nline 2\n01234567\n")

0 commit comments

Comments
 (0)