🎨 Convert network images/assets to local supports URL-encoded local file names https://github.com/siyuan-note/siyuan/issues/9929

This commit is contained in:
Daniel 2023-12-20 10:12:29 +08:00
parent 2d0613637e
commit be18e6c560
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -17,8 +17,8 @@
package api
import (
"github.com/siyuan-note/siyuan/kernel/treenode"
"net/http"
"net/url"
"path/filepath"
"strings"
@ -30,6 +30,7 @@ import (
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -131,6 +132,12 @@ func html2BlockDOM(c *gin.Context) {
localPath = strings.TrimPrefix(localPath, "/")
}
unescaped, _ := url.PathUnescape(localPath)
if unescaped != localPath {
// `Convert network images/assets to local` supports URL-encoded local file names https://github.com/siyuan-note/siyuan/issues/9929
localPath = unescaped
}
if !filepath.IsAbs(localPath) {
// Kernel crash when copy-pasting from some browsers https://github.com/siyuan-note/siyuan/issues/9203
return ast.WalkContinue