mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
tpl: Fix error with unicode in file paths
Add url.QueryUnescape before reading file which allows files with unicode in their paths to be read. Fixes #6996
This commit is contained in:
parent
108314444b
commit
c4fa2f0799
2 changed files with 11 additions and 1 deletions
|
@ -157,6 +157,11 @@ func TestGetJSON(t *testing.T) {
|
||||||
"",
|
"",
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
`pass/üńīçøðê-url.json`,
|
||||||
|
`{"gomeetup":["Sydney","San Francisco","Stockholm"]}`,
|
||||||
|
map[string]interface{}{"gomeetup": []interface{}{"Sydney", "San Francisco", "Stockholm"}},
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
|
|
||||||
msg := qt.Commentf("Test %d", i)
|
msg := qt.Commentf("Test %d", i)
|
||||||
|
|
|
@ -16,6 +16,7 @@ package data
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -107,7 +108,11 @@ func getLocal(url string, fs afero.Fs, cfg config.Provider) ([]byte, error) {
|
||||||
func (ns *Namespace) getResource(cache *filecache.Cache, unmarshal func(b []byte) (bool, error), req *http.Request) error {
|
func (ns *Namespace) getResource(cache *filecache.Cache, unmarshal func(b []byte) (bool, error), req *http.Request) error {
|
||||||
switch req.URL.Scheme {
|
switch req.URL.Scheme {
|
||||||
case "":
|
case "":
|
||||||
b, err := getLocal(req.URL.String(), ns.deps.Fs.Source, ns.deps.Cfg)
|
url, err := url.QueryUnescape(req.URL.String())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b, err := getLocal(url, ns.deps.Fs.Source, ns.deps.Cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue