sanitize ./...

This commit is contained in:
nkanaev
2026-04-25 22:41:22 +01:00
parent cbe1f971a5
commit f01c26b2c2
8 changed files with 10 additions and 34 deletions

View File

@@ -32,7 +32,7 @@ func opt(envVar, defaultValue string) string {
func parseAuthfile(authfile io.Reader) (username, password string, err error) {
scanner := bufio.NewScanner(authfile)
for scanner.Scan() {
if scanner.Scan() {
line := scanner.Text()
parts := strings.SplitN(line, ":", 2)
if len(parts) != 2 {
@@ -40,7 +40,6 @@ func parseAuthfile(authfile io.Reader) (username, password string, err error) {
}
username = parts[0]
password = parts[1]
break
}
return username, password, nil
}

View File

@@ -5,7 +5,6 @@ import (
"html/template"
"io"
"io/fs"
"io/ioutil"
"log"
"os"
)
@@ -37,7 +36,7 @@ func Template(path string) *template.Template {
}
defer svgfile.Close()
content, err := ioutil.ReadAll(svgfile)
content, err := io.ReadAll(svgfile)
// should never happen
if err != nil {
log.Fatal(err)

View File

@@ -15,7 +15,7 @@ import (
"golang.org/x/net/html/charset"
)
var UnknownFormat = errors.New("unknown feed format")
var ErrUnknownFormat = errors.New("unknown feed format")
type feedProbe struct {
feedType string
@@ -89,7 +89,7 @@ func ParseWithEncoding(r io.Reader, fallbackEncoding string) (*Feed, error) {
out := sniff(string(lookup))
if out.feedType == "" {
return nil, UnknownFormat
return nil, ErrUnknownFormat
}
if out.encoding == "" && fallbackEncoding != "" {

View File

@@ -34,23 +34,6 @@ type mediaDescription struct {
Text string `xml:",chardata"`
}
func (m *media) firstMediaThumbnail() string {
for _, c := range m.MediaContents {
for _, t := range c.MediaThumbnails {
return t.URL
}
}
for _, t := range m.MediaThumbnails {
return t.URL
}
for _, g := range m.MediaGroups {
for _, t := range g.MediaThumbnails {
return t.URL
}
}
return ""
}
func (m *media) firstMediaDescription() string {
for _, d := range m.MediaDescriptions {
return plain2html(d.Text)

View File

@@ -17,10 +17,6 @@ type Middleware struct {
DB *storage.Storage
}
func unsafeMethod(method string) bool {
return method == "POST" || method == "PUT" || method == "DELETE"
}
func (m *Middleware) Handler(c *router.Context) {
for _, path := range m.Public {
if strings.HasPrefix(c.Req.URL.Path, m.BasePath+path) {

View File

@@ -55,7 +55,7 @@ func (s *Storage) ToggleFolderExpanded(folderId int64, isExpanded bool) bool {
}
func (s *Storage) ListFolders() []Folder {
result := make([]Folder, 0, 0)
result := make([]Folder, 0)
rows, err := s.db.Query(`
select id, title, is_expanded
from folders

View File

@@ -251,7 +251,7 @@ func (s *Storage) CountItems(filter ItemFilter) int {
func (s *Storage) ListItems(filter ItemFilter, limit int, newestFirst bool, withContent bool) []Item {
predicate, args := listQueryPredicate(filter, newestFirst)
result := make([]Item, 0, 0)
result := make([]Item, 0)
order := "date desc, id desc"
if !newestFirst {

View File

@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime"
"net/http"
"net/url"
@@ -69,10 +68,10 @@ func DiscoverFeed(candidateUrl string) (*DiscoverResult, error) {
}
switch {
case len(sources) == 0:
return nil, errors.New("No feeds found at the given url")
return nil, errors.New("no feeds found at the given url")
case len(sources) == 1:
if sources[0].Url == candidateUrl {
return nil, errors.New("Recursion!")
return nil, errors.New("recursion")
}
return DiscoverFeed(sources[0].Url)
}
@@ -103,7 +102,7 @@ func findFavicon(siteUrl, feedUrl string) (*[]byte, error) {
if siteUrl != "" {
if res, err := client.get(siteUrl); err == nil {
defer res.Body.Close()
if body, err := ioutil.ReadAll(res.Body); err == nil {
if body, err := io.ReadAll(res.Body); err == nil {
urls = append(urls, scraper.FindIcons(string(body), siteUrl)...)
if c := favicon(siteUrl); c != "" {
urls = append(urls, c)
@@ -126,7 +125,7 @@ func findFavicon(siteUrl, feedUrl string) (*[]byte, error) {
continue
}
content, err := ioutil.ReadAll(res.Body)
content, err := io.ReadAll(res.Body)
if err != nil {
continue
}