mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
🎨 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:
parent
2d0613637e
commit
be18e6c560
1 changed files with 8 additions and 1 deletions
|
|
@ -17,8 +17,8 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"github.com/siyuan-note/filelock"
|
"github.com/siyuan-note/filelock"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/model"
|
"github.com/siyuan-note/siyuan/kernel/model"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -131,6 +132,12 @@ func html2BlockDOM(c *gin.Context) {
|
||||||
localPath = strings.TrimPrefix(localPath, "/")
|
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) {
|
if !filepath.IsAbs(localPath) {
|
||||||
// Kernel crash when copy-pasting from some browsers https://github.com/siyuan-note/siyuan/issues/9203
|
// Kernel crash when copy-pasting from some browsers https://github.com/siyuan-note/siyuan/issues/9203
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue