Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Restore mobile boot page directory access https://github.com/siyuan-note/siyuan/issues/19489

Daniel26b4310bd919
diff --git a/kernel/server/appearance_path.go b/kernel/server/appearance_path.go
index 5ec2a7dd4b..b831eaec99 100644
--- a/kernel/server/appearance_path.go
+++ b/kernel/server/appearance_path.go
@@ -31,6 +31,10 @@ func resolveAppearanceFile(root, requestPath string) (string, int) {
if !ok {
return "", http.StatusForbidden
}
+ // 启动页目录映射到首页,首页仍需经过完整的路径和符号链接校验。
+ if relativePath == "boot" {
+ relativePath = filepath.Join(relativePath, "index.html")
+ }
root, err := filepath.Abs(root)
if err != nil {
return "", http.StatusInternalServerError
diff --git a/kernel/server/appearance_path_test.go b/kernel/server/appearance_path_test.go
index 38e7240434..ba05037391 100644
--- a/kernel/server/appearance_path_test.go
+++ b/kernel/server/appearance_path_test.go
@@ -55,6 +55,7 @@ func TestAppearanceFileBoundaries(t *testing.T) {
write(filepath.Join(filepath.Dir(util.AppearancePath), "conf.json"), `{"secret":"credential"}`)
write(filepath.Join(outside, "theme.css"), "resource")
write(filepath.Join(outside, "icon.js"), "resource")
+ write(filepath.Join(util.AppearancePath, "boot/index.html"), "boot page")
engine := gin.New()
serveAppearance(engine)
check := func(path string, status int, body string) {
@@ -73,6 +74,17 @@ func TestAppearanceFileBoundaries(t *testing.T) {
check("themes/local/theme.js", 200, "")
check("themes/local/", 404, "")
check("../conf.json", 403, "")
+ check("boot/", 200, "boot page")
+ check("boot/?v=3.8.4-alpha.9&appearance=0", 200, "boot page")
+ recorder := httptest.NewRecorder()
+ engine.ServeHTTP(recorder, httptest.NewRequest("GET", "/appearance/boot/index.html?v=3.8.4-alpha.9&appearance=0", nil))
+ if recorder.Code != 301 || recorder.Header().Get("Location") != "./?v=3.8.4-alpha.9&appearance=0" {
+ t.Fatalf("boot redirect: status=%d location=%q", recorder.Code, recorder.Header().Get("Location"))
+ }
+ if err := os.Remove(filepath.Join(util.AppearancePath, "boot/index.html")); err != nil {
+ t.Fatal(err)
+ }
+ check("boot/", 404, "")
link := func(target, name string) {
t.Helper()
if err := os.Symlink(target, filepath.Join(util.AppearancePath, name)); err != nil {
@@ -80,6 +92,9 @@ func TestAppearanceFileBoundaries(t *testing.T) {
}
}
link(outside, "themes/linked")
+ link(filepath.Join(filepath.Dir(util.AppearancePath), "conf.json"), "boot/index.html")
+ check("boot/", 403, "")
+ check("boot/index.html", 403, "")
link(outside, "icons/linked")
check("themes/linked/theme.css", 200, "resource")
check("icons/linked/icon.js", 200, "resource")