aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/mobius/threaded_news.go8
-rw-r--r--internal/mobius/transaction_handlers.go8
2 files changed, 13 insertions, 3 deletions
diff --git a/internal/mobius/threaded_news.go b/internal/mobius/threaded_news.go
index 600006a..e9d9c22 100644
--- a/internal/mobius/threaded_news.go
+++ b/internal/mobius/threaded_news.go
@@ -129,6 +129,10 @@ func (n *ThreadedNewsYAML) PostArticle(newsPath []string, parentArticleID uint32
binary.BigEndian.PutUint32(article.ParentArt[:], parentArticleID)
+ if len(newsPath) == 0 {
+ return fmt.Errorf("invalid news path")
+ }
+
cats := n.getCatByPath(newsPath[:len(newsPath)-1])
catName := newsPath[len(newsPath)-1]
@@ -176,6 +180,10 @@ func (n *ThreadedNewsYAML) DeleteArticle(newsPath []string, articleID uint32, _
// // TODO: Handle delete recursive
//}
+ if len(newsPath) == 0 {
+ return fmt.Errorf("invalid news path")
+ }
+
cats := n.getCatByPath(newsPath[:len(newsPath)-1])
catName := newsPath[len(newsPath)-1]
diff --git a/internal/mobius/transaction_handlers.go b/internal/mobius/transaction_handlers.go
index 3253ff2..6f734c7 100644
--- a/internal/mobius/transaction_handlers.go
+++ b/internal/mobius/transaction_handlers.go
@@ -1148,8 +1148,9 @@ func HandleGetNewsArtData(cc *hotline.ClientConn, t *hotline.Transaction) (res [
// None
func HandleDelNewsItem(cc *hotline.ClientConn, t *hotline.Transaction) (res []hotline.Transaction) {
pathStrs, err := t.GetField(hotline.FieldNewsPath).DecodeNewsPath()
- if err != nil {
- return res
+ if err != nil || len(pathStrs) == 0 {
+ cc.Logger.Error("invalid news path")
+ return nil
}
item := cc.Server.ThreadedNewsMgr.NewsItem(pathStrs)
@@ -1217,7 +1218,8 @@ func HandlePostNewsArt(cc *hotline.ClientConn, t *hotline.Transaction) (res []ho
}
pathStrs, err := t.GetField(hotline.FieldNewsPath).DecodeNewsPath()
- if err != nil {
+ if err != nil || len(pathStrs) == 0 {
+ cc.Logger.Error("invalid news path")
return res
}