mirror of https://github.com/gophish/gophish
Fixed template validation to better support the all the possible template tags. Fixes #1189
parent
159ea126a0
commit
0c5925aeec
|
@ -36,31 +36,28 @@ func (t *Template) Validate() error {
|
|||
}
|
||||
// Test that the variables used in the template
|
||||
// validate with no issues
|
||||
td := struct {
|
||||
Result
|
||||
URL string
|
||||
TrackingURL string
|
||||
Tracker string
|
||||
From string
|
||||
}{
|
||||
Result{
|
||||
BaseRecipient: BaseRecipient{
|
||||
Email: "foo@bar.com",
|
||||
FirstName: "Foo",
|
||||
LastName: "Bar",
|
||||
Position: "Test",
|
||||
},
|
||||
},
|
||||
"http://foo.bar",
|
||||
"http://foo.bar/track",
|
||||
"<img src='http://foo.bar/track",
|
||||
"John Doe <foo@bar.com>",
|
||||
vc := ValidationContext{
|
||||
FromAddress: "foo@bar.com",
|
||||
BaseURL: "http://example.com",
|
||||
}
|
||||
_, err := ExecuteTemplate(t.HTML, td)
|
||||
td := Result{
|
||||
BaseRecipient: BaseRecipient{
|
||||
Email: "foo@bar.com",
|
||||
FirstName: "Foo",
|
||||
LastName: "Bar",
|
||||
Position: "Test",
|
||||
},
|
||||
RId: "123456",
|
||||
}
|
||||
ptx, err := NewPhishingTemplateContext(vc, td.BaseRecipient, td.RId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = ExecuteTemplate(t.Text, td)
|
||||
_, err = ExecuteTemplate(t.HTML, ptx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = ExecuteTemplate(t.Text, ptx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -15,6 +15,20 @@ type TemplateContext interface {
|
|||
getBaseURL() string
|
||||
}
|
||||
|
||||
// ValidationContext is used for validating templates and pages
|
||||
type ValidationContext struct {
|
||||
FromAddress string
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
func (vc ValidationContext) getFromAddress() string {
|
||||
return vc.FromAddress
|
||||
}
|
||||
|
||||
func (vc ValidationContext) getBaseURL() string {
|
||||
return vc.BaseURL
|
||||
}
|
||||
|
||||
// PhishingTemplateContext is the context that is sent to any template, such
|
||||
// as the email or landing page content.
|
||||
type PhishingTemplateContext struct {
|
||||
|
|
Loading…
Reference in New Issue