diff --git a/internal/common/eventmanager.go b/internal/common/eventmanager.go index dba898fbc..fe4dbb9d2 100644 --- a/internal/common/eventmanager.go +++ b/internal/common/eventmanager.go @@ -780,6 +780,7 @@ func (p *EventParams) getStringReplacements(addObjectData, jsonEscaped bool) []s "{{Event}}", p.Event, "{{Status}}", fmt.Sprintf("%d", p.Status), "{{VirtualPath}}", p.getStringReplacement(p.VirtualPath, jsonEscaped), + "{{EscapedVirtualPath}}", p.getStringReplacement(url.QueryEscape(p.VirtualPath), jsonEscaped), "{{FsPath}}", p.getStringReplacement(p.FsPath, jsonEscaped), "{{VirtualTargetPath}}", p.getStringReplacement(p.VirtualTargetPath, jsonEscaped), "{{FsTargetPath}}", p.getStringReplacement(p.FsTargetPath, jsonEscaped), diff --git a/internal/common/protocol_test.go b/internal/common/protocol_test.go index a30dedc3a..88fb946fa 100644 --- a/internal/common/protocol_test.go +++ b/internal/common/protocol_test.go @@ -26,6 +26,7 @@ import ( "math" "net" "net/http" + "net/url" "os" "path" "path/filepath" @@ -6087,7 +6088,7 @@ func TestEventActionEmailAttachments(t *testing.T) { EmailConfig: dataprovider.EventActionEmailConfig{ Recipients: []string{"test@example.com"}, Subject: `"{{Event}}" from "{{Name}}"`, - Body: "Fs path {{FsPath}}, size: {{FileSize}}, protocol: {{Protocol}}, IP: {{IP}}", + Body: "Fs path {{FsPath}}, size: {{FileSize}}, protocol: {{Protocol}}, IP: {{IP}} {{EscapedVirtualPath}}", Attachments: []string{"/archive/{{VirtualPath}}.zip"}, }, }, @@ -6146,6 +6147,7 @@ func TestEventActionEmailAttachments(t *testing.T) { assert.Len(t, email.To, 1) assert.True(t, util.Contains(email.To, "test@example.com")) assert.Contains(t, email.Data, `Subject: "upload" from`) + assert.Contains(t, email.Data, url.QueryEscape("/"+testFileName)) assert.Contains(t, email.Data, "Content-Disposition: attachment") } } diff --git a/static/locales/en/translation.json b/static/locales/en/translation.json index 93c020092..1c2c60834 100644 --- a/static/locales/en/translation.json +++ b/static/locales/en/translation.json @@ -1026,6 +1026,7 @@ "status_string": "Status as string. Possible values \"OK\", \"KO\"", "error_string": "Error details. Replaced with an empty string if no errors occur", "virtual_path": "Path seen by SFTPGo users, for example \"/adir/afile.txt\"", + "escaped_virtual_path": "HTTP query string encoded path, for example \"%2Fadir%2Fafile.txt\".", "virtual_dir_path": "Parent directory for \"VirtualPath\", for example if \"VirtualPath\" is \"/adir/afile.txt\", \"VirtualDirPath\" is \"/adir\"", "fs_path": "Full filesystem path, for example \"/user/homedir/adir/afile.txt\" or \"C:/data/user/homedir/adir/afile.txt\" on Windows", "ext": "File extension, for example \".txt\" if the filename is \"afile.txt\"", diff --git a/static/locales/it/translation.json b/static/locales/it/translation.json index 62542172c..2516668a3 100644 --- a/static/locales/it/translation.json +++ b/static/locales/it/translation.json @@ -1026,6 +1026,7 @@ "status_string": "Stato come stringa. Valori possibili \"OK\", \"KO\"", "error_string": "Dettagli circa l'errore. Sostituito con una stringa vuota se non si verificano errori", "virtual_path": "Percorso visualizzato dagli utenti SFTPGo, ad esempio \"/adir/afile.txt\"", + "escaped_virtual_path": "Percorso codificato per HTTP query string, ad esempio \"%2Fadir%2Fafile.txt\".", "virtual_dir_path": "Directory superiore per \"VirtualPath\", ad esempio se \"VirtualPath\" è \"/adir/afile.txt\", \"VirtualDirPath\" è \"/adir\"", "fs_path": "Percorso completo del filesystem, ad esempio \"/user/homedir/adir/afile.txt\" o \"C:/data/user/homedir/adir/afile.txt\" su Windows", "ext": "Estensione del file, ad esempio \".txt\" se il nome del file è \"afile.txt\"", diff --git a/templates/webadmin/eventaction.html b/templates/webadmin/eventaction.html index 60e32b6e2..6d35fe16d 100644 --- a/templates/webadmin/eventaction.html +++ b/templates/webadmin/eventaction.html @@ -884,6 +884,9 @@
{{`{{VirtualPath}}`}} => Path seen by SFTPGo users, for example "/adir/afile.txt".
++ {{`{{EscapedVirtualPath}}`}} => HTTP query string encoded path, for example "%2Fadir%2Fafile.txt". +
{{`{{VirtualDirPath}}`}} => Parent directory for VirtualPath, for example if VirtualPath is "/adir/afile.txt", VirtualDirPath is "/adir".