mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Chomp Unicode BOM if present
Useful if using or sharing files with users that use editors that append a unicode byte order marker header (like Windows notepad). This will still assume files are UTF-8 encoded. Closes #2075
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
d48b986c45
commit
5d50c46482
@@ -1052,6 +1052,19 @@ func TestPageSimpleMethods(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestChompBOM(t *testing.T) {
|
||||
p, _ := NewPage("simple.md")
|
||||
const utf8BOM = "\xef\xbb\xbf"
|
||||
_, err := p.ReadFrom(strings.NewReader(utf8BOM + simplePage))
|
||||
p.Convert()
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create a page with BOM prefixed frontmatter and body content: %s", err)
|
||||
}
|
||||
|
||||
checkPageTitle(t, p, "Simple")
|
||||
}
|
||||
|
||||
func listEqual(left, right []string) bool {
|
||||
if len(left) != len(right) {
|
||||
return false
|
||||
|
Reference in New Issue
Block a user