From 7f42443cce11e64b24266b154d1e64c2a513f66c Mon Sep 17 00:00:00 2001 From: Jeff Date: Sat, 20 Oct 2018 10:26:12 -0400 Subject: [PATCH 1/4] update css --- contrib/static/site.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/static/site.css b/contrib/static/site.css index 4b2ade3..c7ca52f 100644 --- a/contrib/static/site.css +++ b/contrib/static/site.css @@ -848,3 +848,8 @@ th > label { .spoiler:hover a:hover { color: #0066FF; } + + + :target { + background-color: #493769; + } From 644f8da3f4d2b2b7290082ff85dee589dbdf6fb9 Mon Sep 17 00:00:00 2001 From: Jeff Date: Sat, 20 Oct 2018 10:27:24 -0400 Subject: [PATCH 2/4] update css --- contrib/static/krane.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/static/krane.css b/contrib/static/krane.css index e4ba2df..34c08e0 100644 --- a/contrib/static/krane.css +++ b/contrib/static/krane.css @@ -538,3 +538,9 @@ background-repeat: repeat; border: solid #333 1px; padding-left: 1em; } + + + +:target { + background-color: #493769; +} From b4de45569ee69e51cd04a1c3f0f272ad84d2cba2 Mon Sep 17 00:00:00 2001 From: Jeff Date: Sat, 20 Oct 2018 11:24:30 -0400 Subject: [PATCH 3/4] don't fallback to english to prevent cache layer DoS --- contrib/backends/srndv2/src/srnd/i18n.go | 10 +++++++++- contrib/backends/srndv2/src/srnd/null_cache.go | 6 +++++- contrib/static/krane.css | 7 +++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/contrib/backends/srndv2/src/srnd/i18n.go b/contrib/backends/srndv2/src/srnd/i18n.go index c8e43b5..2d6566f 100644 --- a/contrib/backends/srndv2/src/srnd/i18n.go +++ b/contrib/backends/srndv2/src/srnd/i18n.go @@ -7,6 +7,7 @@ import ( "log" "path/filepath" "strings" + "errors" ) type I18N struct { @@ -22,6 +23,7 @@ type I18N struct { } var I18nProvider *I18N = nil +var ErrNoLang = errors.New("no such language") //Read all .ini files in dir, where the filenames are BCP 47 tags //Use the language matcher to get the best match for the locale preference @@ -41,17 +43,23 @@ func NewI18n(locale, dir string) (*I18N, error) { return nil, err } + found:= false serverLangs := make([]language.Tag, 1) - serverLangs[0] = language.AmericanEnglish // en-US fallback + // serverLangs[0] = language.AmericanEnglish // en-US fallback for _, file := range files { if filepath.Ext(file.Name()) == ".ini" { name := strings.TrimSuffix(file.Name(), ".ini") tag, err := language.Parse(name) if err == nil { serverLangs = append(serverLangs, tag) + found = true; } } } + if !found { + return nil, ErrNoLang + } + matcher := language.NewMatcher(serverLangs) tag, _, _ := matcher.Match(pref) diff --git a/contrib/backends/srndv2/src/srnd/null_cache.go b/contrib/backends/srndv2/src/srnd/null_cache.go index 8011296..a9722cd 100644 --- a/contrib/backends/srndv2/src/srnd/null_cache.go +++ b/contrib/backends/srndv2/src/srnd/null_cache.go @@ -51,6 +51,7 @@ func (self *nullHandler) GetI18N(r *http.Request) *I18N { i, err = NewI18n(lang, self.translations) if err != nil { log.Println(err) + return nil } if i != nil { self.i18n[lang] = i @@ -64,7 +65,10 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { sfw := strings.Count(r.URL.RawQuery, "sfw=1") > 0 i18n := self.GetI18N(r) - + if i18n == nil { + http.Redirect(w, r, r.URL.Path, http.StatusFound) + return + } path := r.URL.Path _, file := filepath.Split(path) diff --git a/contrib/static/krane.css b/contrib/static/krane.css index 34c08e0..705b292 100644 --- a/contrib/static/krane.css +++ b/contrib/static/krane.css @@ -544,3 +544,10 @@ background-repeat: repeat; :target { background-color: #493769; } + +body { + display: inline-flex; + flex-direction: column; + flex-wrap: wrap; + flex-flow: wrap; +} From 0c77218b70d89256a832a4e02977a5f601559987 Mon Sep 17 00:00:00 2001 From: Jeff Date: Sat, 20 Oct 2018 11:37:13 -0400 Subject: [PATCH 4/4] 404 instead of redirect --- contrib/backends/srndv2/src/srnd/null_cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/backends/srndv2/src/srnd/null_cache.go b/contrib/backends/srndv2/src/srnd/null_cache.go index a9722cd..b5bbcec 100644 --- a/contrib/backends/srndv2/src/srnd/null_cache.go +++ b/contrib/backends/srndv2/src/srnd/null_cache.go @@ -66,7 +66,7 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { sfw := strings.Count(r.URL.RawQuery, "sfw=1") > 0 i18n := self.GetI18N(r) if i18n == nil { - http.Redirect(w, r, r.URL.Path, http.StatusFound) + w.WriteHeader(http.StatusNotFound) return } path := r.URL.Path