Skip to content

Commit f057884

Browse files
authored
executor/mail: fix: line breaks in email body are not properly converted to <br /> (#888)
1 parent 51f284f commit f057884

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

internal/digraph/builder.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ var stepBuilderRegistry = []stepBuilderEntry{
8585
{name: "repeatPolicy", fn: buildRepeatPolicy},
8686
{name: "signalOnStop", fn: buildSignalOnStop},
8787
{name: "precondition", fn: buildStepPrecondition},
88+
{name: "output", fn: buildOutput},
8889
}
8990

9091
type stepBuilderEntry struct {
@@ -550,7 +551,6 @@ func buildStep(ctx BuildContext, def stepDef, fns []*funcDef) (*Step, error) {
550551
Script: def.Script,
551552
Stdout: def.Stdout,
552553
Stderr: def.Stderr,
553-
Output: def.Output,
554554
Dir: def.Dir,
555555
MailOnError: def.MailOnError,
556556
ExecutorConfig: ExecutorConfig{Config: make(map[string]any)},
@@ -625,6 +625,20 @@ func buildRepeatPolicy(_ BuildContext, def stepDef, step *Step) error {
625625
return nil
626626
}
627627

628+
func buildOutput(_ BuildContext, def stepDef, step *Step) error {
629+
if def.Output == "" {
630+
return nil
631+
}
632+
633+
if strings.HasPrefix(def.Output, "$") {
634+
step.Output = strings.TrimPrefix(def.Output, "$")
635+
return nil
636+
}
637+
638+
step.Output = def.Output
639+
return nil
640+
}
641+
628642
func buildStepPrecondition(ctx BuildContext, def stepDef, step *Step) error {
629643
// Parse both `preconditions` and `precondition` fields.
630644
conditions, err := parsePrecondition(ctx, def.Preconditions)

internal/mailer/mailer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func joinBytes(s ...[]byte) []byte {
157157

158158
func newlineToBrTag(body string) string {
159159
return strings.NewReplacer(
160-
`\r\n`, "<br />", `\r`, "<br />", `\n`, "<br />",
160+
`\r\n`, "<br />", `\r`, "<br />", `\n`, "<br />", "\r\n", "<br />", "\r", "<br />", "\n", "<br />",
161161
).Replace(body)
162162
}
163163

schemas/dag.schema.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
},
3535
"schedule": {
3636
"type": "string",
37-
"pattern": "(\\*|[0-5]?[0-9]|\\*/[0-9]+)\\s+(\\*|1?[0-9]|2[0-3]|\\*/[0-9]+)\\s+(\\*|[1-2]?[0-9]|3[0-1]|\\*/[0-9]+)\\s+(\\*|[0-9]|1[0-2]|\\*/[0-9]+|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\\s+(\\*/[0-9]+|\\*|[0-7]|sun|mon|tue|wed|thu|fri|sat)\\s*(\\*/[0-9]+|\\*|[0-9]+)?",
3837
"description": "Cron expression that determines how often the DAG runs (e.g., '5 4 * * *' runs daily at 04:05). If omitted, the DAG will only run manually."
3938
},
4039
"skipIfSuccessful": {

0 commit comments

Comments
 (0)