Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl
diff options
context:
space:
mode:
authorSam Smith <sams96@mail.com>2020-03-07 21:56:02 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-03-09 15:31:04 +0300
commitc4fa2f07996c7f1f4e257089a3c3c5b4c1339722 (patch)
tree585cbe9deef705f97dd574000472e541a0cb5285 /tpl
parent108314444b510bfc330ccac745dce7beccd52c91 (diff)
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
Diffstat (limited to 'tpl')
-rw-r--r--tpl/data/data_test.go5
-rw-r--r--tpl/data/resources.go7
2 files changed, 11 insertions, 1 deletions
diff --git a/tpl/data/data_test.go b/tpl/data/data_test.go
index 8bd4edc98..fa99006b2 100644
--- a/tpl/data/data_test.go
+++ b/tpl/data/data_test.go
@@ -157,6 +157,11 @@ func TestGetJSON(t *testing.T) {
"",
false,
},
+ {
+ `pass/üńīçøðê-url.json`,
+ `{"gomeetup":["Sydney","San Francisco","Stockholm"]}`,
+ map[string]interface{}{"gomeetup": []interface{}{"Sydney", "San Francisco", "Stockholm"}},
+ },
} {
msg := qt.Commentf("Test %d", i)
diff --git a/tpl/data/resources.go b/tpl/data/resources.go
index 7de440ca6..923d5946e 100644
--- a/tpl/data/resources.go
+++ b/tpl/data/resources.go
@@ -16,6 +16,7 @@ package data
import (
"io/ioutil"
"net/http"
+ "net/url"
"path/filepath"
"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 {
switch req.URL.Scheme {
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 {
return err
}