Fixing issue with compliance export encoding (#7042)
Этот коммит содержится в:
@@ -4,6 +4,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -64,6 +65,15 @@ func CompliancePostHeader() []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanComplianceStrings(in string) string {
|
||||||
|
if matched, _ := regexp.MatchString("^\\s*(=|\\+|\\-)", in); matched {
|
||||||
|
return "'" + in
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return in
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (me *CompliancePost) Row() []string {
|
func (me *CompliancePost) Row() []string {
|
||||||
|
|
||||||
postDeleteAt := ""
|
postDeleteAt := ""
|
||||||
@@ -77,15 +87,15 @@ func (me *CompliancePost) Row() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return []string{
|
return []string{
|
||||||
me.TeamName,
|
cleanComplianceStrings(me.TeamName),
|
||||||
me.TeamDisplayName,
|
cleanComplianceStrings(me.TeamDisplayName),
|
||||||
|
|
||||||
me.ChannelName,
|
cleanComplianceStrings(me.ChannelName),
|
||||||
me.ChannelDisplayName,
|
cleanComplianceStrings(me.ChannelDisplayName),
|
||||||
|
|
||||||
me.UserUsername,
|
cleanComplianceStrings(me.UserUsername),
|
||||||
me.UserEmail,
|
cleanComplianceStrings(me.UserEmail),
|
||||||
me.UserNickname,
|
cleanComplianceStrings(me.UserNickname),
|
||||||
|
|
||||||
me.PostId,
|
me.PostId,
|
||||||
time.Unix(0, me.PostCreateAt*int64(1000*1000)).Format(time.RFC3339),
|
time.Unix(0, me.PostCreateAt*int64(1000*1000)).Format(time.RFC3339),
|
||||||
@@ -95,7 +105,7 @@ func (me *CompliancePost) Row() []string {
|
|||||||
me.PostRootId,
|
me.PostRootId,
|
||||||
me.PostParentId,
|
me.PostParentId,
|
||||||
me.PostOriginalId,
|
me.PostOriginalId,
|
||||||
me.PostMessage,
|
cleanComplianceStrings(me.PostMessage),
|
||||||
me.PostType,
|
me.PostType,
|
||||||
me.PostProps,
|
me.PostProps,
|
||||||
me.PostHashtags,
|
me.PostHashtags,
|
||||||
|
|||||||
@@ -25,3 +25,26 @@ func TestCompliancePost(t *testing.T) {
|
|||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cleanTests = []struct {
|
||||||
|
in string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{"hello", "hello"},
|
||||||
|
{"=hello", "'=hello"},
|
||||||
|
{"+hello", "'+hello"},
|
||||||
|
{"-hello", "'-hello"},
|
||||||
|
{" =hello", "' =hello"},
|
||||||
|
{" +hello", "' +hello"},
|
||||||
|
{" -hello", "' -hello"},
|
||||||
|
{"\t -hello", "'\t -hello"},
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCleanComplianceStrings(t *testing.T) {
|
||||||
|
for _, tt := range cleanTests {
|
||||||
|
actual := cleanComplianceStrings(tt.in)
|
||||||
|
if actual != tt.expected {
|
||||||
|
t.Errorf("cleanComplianceStrings(%v): expected %v, actual %v", tt.in, tt.expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user