feat: public Markdown and isolated HTML landing pages (3.2.4)

This commit is contained in:
SantaSpeen committed 2026-10-30 16:00:55 +03:00
1 parent 9f777bafbc
commit 3bc62d2b69
50 files changed
+1065 -94

No files matched your search

+10 -3
View File
@@ -17,6 +17,9 @@ import (
var withHashFile = func(fn handleFunc) handleFunc {
return func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
id, ifPath := ifPathWithName(r)
if !validSharePath(r.URL.Path) {
return http.StatusBadRequest, nil
}
link, err := d.store.Share.GetByHash(id)
if err != nil {
return errToStatus(err), err
@@ -62,14 +65,18 @@ var withHashFile = func(fn handleFunc) handleFunc {
if file.IsDir {
filePath = ifPath
} else if ifPath != "/" && ifPath != "." && ifPath != "/"+file.Name {
// Keep the legacy /key/original-filename download alias, but never
// interpret a suffix on a single-file share as an attachment path.
return http.StatusNotFound, nil
}
// set fs root to the shared file/folder. Unless external symlinks are
// explicitly allowed, this is a ScopedFs (not a bare BasePathFs) so the
// Set fs root to the shared file/folder. Public access always uses a
// ScopedFs (not a bare BasePathFs) so the
// share is also symlink-confined: a link inside the shared subtree that
// points elsewhere in the owner's scope — outside the share — must not be
// followed.
d.user.Fs = files.NewFs(d.user.Fs, basePath, d.server.FollowExternalSymlinks)
d.user.Fs = files.NewScopedFs(d.user.Fs, basePath)
// the filesystem is now rebased onto basePath, so paths handed to the
// rule checker are relative to it. Resolve them back to the user's