From 9de375d169ae552e2ceea6ac2fc88f96c1a4ff3b Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 2 Aug 2023 23:34:24 -0400 Subject: [PATCH 1/3] unusued range var --- database.go | 2 +- web.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/database.go b/database.go index e398a22..8c9696b 100644 --- a/database.go +++ b/database.go @@ -1121,7 +1121,7 @@ func cleanupdb(arg string) { if err != nil { elog.Fatal(err) } - for xid, _ := range filexids { + for xid := range filexids { _, err = tx.Exec("delete from filedata where xid = ?", xid) if err != nil { elog.Fatal(err) diff --git a/web.go b/web.go index c7507cc..a6b0eb5 100644 --- a/web.go +++ b/web.go @@ -602,7 +602,7 @@ func xzone(w http.ResponseWriter, r *http.Request) { honkers = append(honkers, Honker{XID: xid}) } rows.Close() - for i, _ := range honkers { + for i := range honkers { _, honkers[i].Handle = handles(honkers[i].XID) } templinfo := getInfo(r) From 79756a6b0fe8784f6f23a2e8a43c8ecbb4019387 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 4 Aug 2023 13:06:24 -0400 Subject: [PATCH 2/3] don't report csp violations by default --- web.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web.go b/web.go index a6b0eb5..2249f9a 100644 --- a/web.go +++ b/web.go @@ -2560,6 +2560,9 @@ func apihandler(w http.ResponseWriter, r *http.Request) { } func fiveoh(w http.ResponseWriter, r *http.Request) { + if !develMode { + return + } fd, err := os.OpenFile("violations.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { elog.Printf("error opening violations! %s", err) @@ -2606,7 +2609,11 @@ func bgmonitor() { func addcspheaders(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Security-Policy", "default-src 'none'; script-src 'self'; connect-src 'self'; style-src 'self'; img-src 'self'; media-src 'self'; report-uri /csp-violation") + policy := "default-src 'none'; script-src 'self'; connect-src 'self'; style-src 'self'; img-src 'self'; media-src 'self'" + if develMode { + policy += "; report-uri /csp-violation" + } + w.Header().Set("Content-Security-Policy", policy) next.ServeHTTP(w, r) }) } From 2376371d7668d2f16ab2e9a8c94c687cb66f092a Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 4 Aug 2023 13:08:15 -0400 Subject: [PATCH 3/3] update twitter import again, from tom --- import.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/import.go b/import.go index 8ac5c34..7dfbe6e 100644 --- a/import.go +++ b/import.go @@ -338,7 +338,7 @@ func importTwitter(username, source string) { } var tweets []*Tweet - fd, err := os.Open(source + "/tweet.js") + fd, err := os.Open(source + "/tweets.js") if err != nil { elog.Fatal(err) } @@ -375,11 +375,6 @@ func importTwitter(username, source string) { continue } - if t.Tweet.FavoriteCount == "0" || t.Tweet.FavoriteCount == "" { - log.Printf("skipping, unworthy tweet") - continue - } - what := "honk" noise := "" if parent := tweetmap[t.Tweet.InReplyToStatusID]; parent != nil {