mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-28 10:30:28 +00:00
EventManager: add escaped virtual path
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
8e7086ab39
commit
b23e67ae6a
5 changed files with 9 additions and 1 deletions
|
@ -787,6 +787,7 @@ func (p *EventParams) getStringReplacements(addObjectData, jsonEscaped bool) []s
|
||||||
"{{Event}}", p.Event,
|
"{{Event}}", p.Event,
|
||||||
"{{Status}}", fmt.Sprintf("%d", p.Status),
|
"{{Status}}", fmt.Sprintf("%d", p.Status),
|
||||||
"{{VirtualPath}}", p.getStringReplacement(p.VirtualPath, jsonEscaped),
|
"{{VirtualPath}}", p.getStringReplacement(p.VirtualPath, jsonEscaped),
|
||||||
|
"{{EscapedVirtualPath}}", p.getStringReplacement(url.QueryEscape(p.VirtualPath), jsonEscaped),
|
||||||
"{{FsPath}}", p.getStringReplacement(p.FsPath, jsonEscaped),
|
"{{FsPath}}", p.getStringReplacement(p.FsPath, jsonEscaped),
|
||||||
"{{VirtualTargetPath}}", p.getStringReplacement(p.VirtualTargetPath, jsonEscaped),
|
"{{VirtualTargetPath}}", p.getStringReplacement(p.VirtualTargetPath, jsonEscaped),
|
||||||
"{{FsTargetPath}}", p.getStringReplacement(p.FsTargetPath, jsonEscaped),
|
"{{FsTargetPath}}", p.getStringReplacement(p.FsTargetPath, jsonEscaped),
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -6118,7 +6119,7 @@ func TestEventActionEmailAttachments(t *testing.T) {
|
||||||
EmailConfig: dataprovider.EventActionEmailConfig{
|
EmailConfig: dataprovider.EventActionEmailConfig{
|
||||||
Recipients: []string{"test@example.com"},
|
Recipients: []string{"test@example.com"},
|
||||||
Subject: `"{{Event}}" from "{{Name}}"`,
|
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"},
|
Attachments: []string{"/archive/{{VirtualPath}}.zip"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -6177,6 +6178,7 @@ func TestEventActionEmailAttachments(t *testing.T) {
|
||||||
assert.Len(t, email.To, 1)
|
assert.Len(t, email.To, 1)
|
||||||
assert.True(t, slices.Contains(email.To, "test@example.com"))
|
assert.True(t, slices.Contains(email.To, "test@example.com"))
|
||||||
assert.Contains(t, email.Data, `Subject: "upload" from`)
|
assert.Contains(t, email.Data, `Subject: "upload" from`)
|
||||||
|
assert.Contains(t, email.Data, url.QueryEscape("/"+testFileName))
|
||||||
assert.Contains(t, email.Data, "Content-Disposition: attachment")
|
assert.Contains(t, email.Data, "Content-Disposition: attachment")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1043,6 +1043,7 @@
|
||||||
"status_string": "Status as string. Possible values \"OK\", \"KO\"",
|
"status_string": "Status as string. Possible values \"OK\", \"KO\"",
|
||||||
"error_string": "Error details. Replaced with an empty string if no errors occur",
|
"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\"",
|
"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\"",
|
"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",
|
"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\"",
|
"ext": "File extension, for example \".txt\" if the filename is \"afile.txt\"",
|
||||||
|
|
|
@ -1043,6 +1043,7 @@
|
||||||
"status_string": "Stato come stringa. Valori possibili \"OK\", \"KO\"",
|
"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",
|
"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\"",
|
"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\"",
|
"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",
|
"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\"",
|
"ext": "Estensione del file, ad esempio \".txt\" se il nome del file è \"afile.txt\"",
|
||||||
|
|
|
@ -896,6 +896,9 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||||
<p>
|
<p>
|
||||||
<span class="shortcut">{{`{{VirtualPath}}`}}</span> => <span data-i18n="actions.placeholders_modal.virtual_path">Path seen by SFTPGo users, for example "/adir/afile.txt".</span>
|
<span class="shortcut">{{`{{VirtualPath}}`}}</span> => <span data-i18n="actions.placeholders_modal.virtual_path">Path seen by SFTPGo users, for example "/adir/afile.txt".</span>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<span class="shortcut">{{`{{EscapedVirtualPath}}`}}</span> => <span data-i18n="actions.placeholders_modal.escaped_virtual_path">HTTP query string encoded path, for example "%2Fadir%2Fafile.txt".</span>
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span class="shortcut">{{`{{VirtualDirPath}}`}}</span> => <span data-i18n="actions.placeholders_modal.virtual_dir_path">Parent directory for VirtualPath, for example if VirtualPath is "/adir/afile.txt", VirtualDirPath is "/adir".</span>
|
<span class="shortcut">{{`{{VirtualDirPath}}`}}</span> => <span data-i18n="actions.placeholders_modal.virtual_dir_path">Parent directory for VirtualPath, for example if VirtualPath is "/adir/afile.txt", VirtualDirPath is "/adir".</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in a new issue