-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed the notification service error when the user's display name con…
…tained special characters
- Loading branch information
Showing
4 changed files
with
107 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Bugfix: Fix the email notification service | ||
|
||
We fixed an error in the notification service that caused the email notification to fail when the user's display name contained special characters. | ||
|
||
|
||
https://github.com/owncloud/ocis/pull/9514 | ||
https://github.com/owncloud/ocis/issues/9402 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package channels | ||
|
||
import ( | ||
"net/mail" | ||
"testing" | ||
) | ||
|
||
func Test_appendSender(t *testing.T) { | ||
type args struct { | ||
sender string | ||
a mail.Address | ||
} | ||
|
||
a1, err := mail.ParseAddress("ownCloud <[email protected]>") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
a2, err := mail.ParseAddress("[email protected]") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
sender string | ||
want1 string | ||
want2 string | ||
}{ | ||
{ | ||
name: "empty sender", | ||
sender: "", | ||
want1: `"ownCloud" <[email protected]>`, | ||
want2: `<[email protected]>`, | ||
}, | ||
{ | ||
name: "not empty sender", | ||
sender: `Joe Q. Public`, | ||
want1: `"Joe Q. Public via ownCloud" <[email protected]>`, | ||
want2: `"Joe Q. Public via" <[email protected]>`, | ||
}, | ||
{ | ||
name: "sender whit comma and semicolon", | ||
sender: `Joe, Q; Public:`, | ||
want1: `"Joe, Q; Public: via ownCloud" <[email protected]>`, | ||
want2: `"Joe, Q; Public: via" <[email protected]>`, | ||
}, | ||
{ | ||
name: "sender with quotes", | ||
sender: `Joe Q. "Public"`, | ||
want1: `"Joe Q. \"Public\" via ownCloud" <[email protected]>`, | ||
want2: `"Joe Q. \"Public\" via" <[email protected]>`, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := appendSender(tt.sender, *a1); got != tt.want1 { | ||
t.Errorf("appendSender() = %v, want %v", got, tt.want1) | ||
} | ||
if got := appendSender(tt.sender, *a2); got != tt.want2 { | ||
t.Errorf("appendSender() = %v, want %v", got, tt.want2) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters