This commit is contained in:
Daniel 2024-07-01 21:59:57 +08:00
parent 5bcf1fe411
commit 51bd794f43
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -393,8 +393,18 @@ func serveAssets(ginServer *gin.Engine) {
relativePath := path.Join("assets", requestPath)
p, err := model.GetAssetAbsPath(relativePath)
if nil != err {
context.Status(http.StatusNotFound)
return
if strings.Contains(strings.TrimPrefix(requestPath, "/"), "/") {
// 再使用编码过的路径解析一次 https://github.com/siyuan-note/siyuan/issues/11823
dest := url.PathEscape(strings.TrimPrefix(requestPath, "/"))
dest = strings.ReplaceAll(dest, ":", "%3A")
relativePath = path.Join("assets", dest)
p, err = model.GetAssetAbsPath(relativePath)
}
if nil != err {
context.Status(http.StatusNotFound)
return
}
}
http.ServeFile(context.Writer, context.Request, p)
return