mirror of
https://github.com/nkanaev/yarr.git
synced 2026-04-30 14:27:45 +00:00
sanitize ./...
This commit is contained in:
@@ -32,7 +32,7 @@ func opt(envVar, defaultValue string) string {
|
|||||||
|
|
||||||
func parseAuthfile(authfile io.Reader) (username, password string, err error) {
|
func parseAuthfile(authfile io.Reader) (username, password string, err error) {
|
||||||
scanner := bufio.NewScanner(authfile)
|
scanner := bufio.NewScanner(authfile)
|
||||||
for scanner.Scan() {
|
if scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
parts := strings.SplitN(line, ":", 2)
|
parts := strings.SplitN(line, ":", 2)
|
||||||
if len(parts) != 2 {
|
if len(parts) != 2 {
|
||||||
@@ -40,7 +40,6 @@ func parseAuthfile(authfile io.Reader) (username, password string, err error) {
|
|||||||
}
|
}
|
||||||
username = parts[0]
|
username = parts[0]
|
||||||
password = parts[1]
|
password = parts[1]
|
||||||
break
|
|
||||||
}
|
}
|
||||||
return username, password, nil
|
return username, password, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
@@ -37,7 +36,7 @@ func Template(path string) *template.Template {
|
|||||||
}
|
}
|
||||||
defer svgfile.Close()
|
defer svgfile.Close()
|
||||||
|
|
||||||
content, err := ioutil.ReadAll(svgfile)
|
content, err := io.ReadAll(svgfile)
|
||||||
// should never happen
|
// should never happen
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
"golang.org/x/net/html/charset"
|
"golang.org/x/net/html/charset"
|
||||||
)
|
)
|
||||||
|
|
||||||
var UnknownFormat = errors.New("unknown feed format")
|
var ErrUnknownFormat = errors.New("unknown feed format")
|
||||||
|
|
||||||
type feedProbe struct {
|
type feedProbe struct {
|
||||||
feedType string
|
feedType string
|
||||||
@@ -89,7 +89,7 @@ func ParseWithEncoding(r io.Reader, fallbackEncoding string) (*Feed, error) {
|
|||||||
|
|
||||||
out := sniff(string(lookup))
|
out := sniff(string(lookup))
|
||||||
if out.feedType == "" {
|
if out.feedType == "" {
|
||||||
return nil, UnknownFormat
|
return nil, ErrUnknownFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
if out.encoding == "" && fallbackEncoding != "" {
|
if out.encoding == "" && fallbackEncoding != "" {
|
||||||
|
|||||||
@@ -34,23 +34,6 @@ type mediaDescription struct {
|
|||||||
Text string `xml:",chardata"`
|
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 {
|
func (m *media) firstMediaDescription() string {
|
||||||
for _, d := range m.MediaDescriptions {
|
for _, d := range m.MediaDescriptions {
|
||||||
return plain2html(d.Text)
|
return plain2html(d.Text)
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ type Middleware struct {
|
|||||||
DB *storage.Storage
|
DB *storage.Storage
|
||||||
}
|
}
|
||||||
|
|
||||||
func unsafeMethod(method string) bool {
|
|
||||||
return method == "POST" || method == "PUT" || method == "DELETE"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Middleware) Handler(c *router.Context) {
|
func (m *Middleware) Handler(c *router.Context) {
|
||||||
for _, path := range m.Public {
|
for _, path := range m.Public {
|
||||||
if strings.HasPrefix(c.Req.URL.Path, m.BasePath+path) {
|
if strings.HasPrefix(c.Req.URL.Path, m.BasePath+path) {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func (s *Storage) ToggleFolderExpanded(folderId int64, isExpanded bool) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Storage) ListFolders() []Folder {
|
func (s *Storage) ListFolders() []Folder {
|
||||||
result := make([]Folder, 0, 0)
|
result := make([]Folder, 0)
|
||||||
rows, err := s.db.Query(`
|
rows, err := s.db.Query(`
|
||||||
select id, title, is_expanded
|
select id, title, is_expanded
|
||||||
from folders
|
from folders
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ func (s *Storage) CountItems(filter ItemFilter) int {
|
|||||||
|
|
||||||
func (s *Storage) ListItems(filter ItemFilter, limit int, newestFirst bool, withContent bool) []Item {
|
func (s *Storage) ListItems(filter ItemFilter, limit int, newestFirst bool, withContent bool) []Item {
|
||||||
predicate, args := listQueryPredicate(filter, newestFirst)
|
predicate, args := listQueryPredicate(filter, newestFirst)
|
||||||
result := make([]Item, 0, 0)
|
result := make([]Item, 0)
|
||||||
|
|
||||||
order := "date desc, id desc"
|
order := "date desc, id desc"
|
||||||
if !newestFirst {
|
if !newestFirst {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -69,10 +68,10 @@ func DiscoverFeed(candidateUrl string) (*DiscoverResult, error) {
|
|||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case len(sources) == 0:
|
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:
|
case len(sources) == 1:
|
||||||
if sources[0].Url == candidateUrl {
|
if sources[0].Url == candidateUrl {
|
||||||
return nil, errors.New("Recursion!")
|
return nil, errors.New("recursion")
|
||||||
}
|
}
|
||||||
return DiscoverFeed(sources[0].Url)
|
return DiscoverFeed(sources[0].Url)
|
||||||
}
|
}
|
||||||
@@ -103,7 +102,7 @@ func findFavicon(siteUrl, feedUrl string) (*[]byte, error) {
|
|||||||
if siteUrl != "" {
|
if siteUrl != "" {
|
||||||
if res, err := client.get(siteUrl); err == nil {
|
if res, err := client.get(siteUrl); err == nil {
|
||||||
defer res.Body.Close()
|
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)...)
|
urls = append(urls, scraper.FindIcons(string(body), siteUrl)...)
|
||||||
if c := favicon(siteUrl); c != "" {
|
if c := favicon(siteUrl); c != "" {
|
||||||
urls = append(urls, c)
|
urls = append(urls, c)
|
||||||
@@ -126,7 +125,7 @@ func findFavicon(siteUrl, feedUrl string) (*[]byte, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err := ioutil.ReadAll(res.Body)
|
content, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user