sanitize at the data layer too
This commit is contained in:
parent
7b10b20b9e
commit
db0888453a
1 changed files with 6 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/maddalax/htmgo/framework/h"
|
"github.com/maddalax/htmgo/framework/h"
|
||||||
"hackernews/internal/batch"
|
"hackernews/internal/batch"
|
||||||
"hackernews/internal/httpjson"
|
"hackernews/internal/httpjson"
|
||||||
|
"hackernews/internal/sanitize"
|
||||||
"hackernews/internal/timeformat"
|
"hackernews/internal/timeformat"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -132,6 +133,8 @@ func GetComment(id int) (*Comment, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
c.Text = sanitize.Sanitize(c.Text)
|
||||||
|
c.By = sanitize.Sanitize(c.By)
|
||||||
c.Time = timeformat.ParseUnix(c.TimeRaw)
|
c.Time = timeformat.ParseUnix(c.TimeRaw)
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
@ -141,6 +144,9 @@ func GetStory(id int) (*Story, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
s.Title = sanitize.Sanitize(s.Title)
|
||||||
|
s.Text = sanitize.Sanitize(s.Text)
|
||||||
|
s.By = sanitize.Sanitize(s.By)
|
||||||
s.Time = timeformat.ParseUnix(s.TimeRaw)
|
s.Time = timeformat.ParseUnix(s.TimeRaw)
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue