mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 06:30:33 +03: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:
parent
d48b986c45
commit
5d50c46482
2 changed files with 32 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue