Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: url resource filename decode (#738)

Zeng19981dee8ae49fa9
diff --git a/server/resource.go b/server/resource.go
index e2c779956..bbf009edd 100644
--- a/server/resource.go
+++ b/server/resource.go
@@ -3,9 +3,9 @@ package server
import (
"encoding/json"
"fmt"
- "html"
"io"
"net/http"
+ "net/url"
"strconv"
"time"
@@ -249,8 +249,10 @@ func (s *Server) registerResourcePublicRoutes(g *echo.Group) {
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("resourceId"))).SetInternal(err)
}
-
- filename := html.UnescapeString(c.Param("filename"))
+ filename, err := url.QueryUnescape(c.Param("filename"))
+ if err != nil {
+ return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("filename is invalid: %s", c.Param("filename"))).SetInternal(err)
+ }
resourceFind := &api.ResourceFind{
ID: &resourceID,
Filename: &filename,