diff --git a/internal/webserver/Webserver.go b/internal/webserver/Webserver.go index 2a4b25d..97bf0e7 100644 --- a/internal/webserver/Webserver.go +++ b/internal/webserver/Webserver.go @@ -196,15 +196,34 @@ func redirect(w http.ResponseWriter, url string) { } type redirectValues struct { - FileId string - RedirectUrl string + FileId string + RedirectUrl string + Name string + Size string + PublicName string + BaseUrl string + PasswordRequired bool } // Handling of /id/?/? - used when filename shall be displayed, will redirect to regular download URL func redirectFromFilename(w http.ResponseWriter, r *http.Request) { + addNoCacheHeader(w) id := r.PathValue("id") + file, ok := storage.GetFile(id) + if !ok { + redirect(w, "../../error") + return + } + + config := configuration.Get() err := templateFolder.ExecuteTemplate(w, "redirect_filename", redirectValues{ - id, "d"}) + FileId: id, + RedirectUrl: "d", + Name: file.Name, + Size: file.Size, + PublicName: config.PublicName, + BaseUrl: config.ServerUrl, + PasswordRequired: file.PasswordHash != ""}) helper.CheckIgnoreTimeout(err) } @@ -373,13 +392,16 @@ func showDownload(w http.ResponseWriter, r *http.Request) { return } + config := configuration.Get() + view := DownloadView{ Name: file.Name, Size: file.Size, Id: file.Id, IsDownloadView: true, EndToEndEncryption: file.Encryption.IsEndToEndEncrypted, - PublicName: configuration.Get().PublicName, + PublicName: config.PublicName, + BaseUrl: config.ServerUrl, IsFailedLogin: false, UsesHttps: configuration.UsesHttps(), } @@ -547,6 +569,7 @@ type DownloadView struct { Id string Cipher string PublicName string + BaseUrl string IsFailedLogin bool IsAdminView bool IsDownloadView bool diff --git a/internal/webserver/web/templates/html_header.tmpl b/internal/webserver/web/templates/html_header.tmpl index 2e28f72..bf9b15b 100644 --- a/internal/webserver/web/templates/html_header.tmpl +++ b/internal/webserver/web/templates/html_header.tmpl @@ -40,11 +40,18 @@ {{.PublicName}}: Password required + + + {{ else }} {{.PublicName}}: {{.Name}} - - + + + + + {{end }} + {{ else }} {{.PublicName}} {{end }} diff --git a/internal/webserver/web/templates/html_redirect_filename.tmpl b/internal/webserver/web/templates/html_redirect_filename.tmpl index 4a33baa..e773626 100644 --- a/internal/webserver/web/templates/html_redirect_filename.tmpl +++ b/internal/webserver/web/templates/html_redirect_filename.tmpl @@ -1,14 +1,30 @@ {{define "redirect_filename"}} - + + + {{ if .PasswordRequired }} + {{.PublicName}}: Password required + + + + + + {{ else }} + {{.PublicName}}: {{.Name}} + + + + + + {{end }} + + +