summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-07-28 09:32:37 -0600
committerGitHub <noreply@github.com>2017-07-28 09:32:37 -0600
commit571e4f2ae10d06addd0868f1ac474cc2055fbcb6 (patch)
tree8bc827b7369007204e995950c42f840024da30a8 /model
parent2d43e9975762b3bd4e6ede6c4db1e16ac661ab87 (diff)
downloadchat-571e4f2ae10d06addd0868f1ac474cc2055fbcb6.tar.gz
chat-571e4f2ae10d06addd0868f1ac474cc2055fbcb6.tar.bz2
chat-571e4f2ae10d06addd0868f1ac474cc2055fbcb6.zip
Fixing issue with compliance export encoding (#7042)
Diffstat (limited to 'model')
-rw-r--r--model/compliance_post.go26
-rw-r--r--model/compliance_post_test.go23
2 files changed, 41 insertions, 8 deletions
diff --git a/model/compliance_post.go b/model/compliance_post.go
index f39fea2f5..3751c5862 100644
--- a/model/compliance_post.go
+++ b/model/compliance_post.go
@@ -4,6 +4,7 @@
package model
import (
+ "regexp"
"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 {
postDeleteAt := ""
@@ -77,15 +87,15 @@ func (me *CompliancePost) Row() []string {
}
return []string{
- me.TeamName,
- me.TeamDisplayName,
+ cleanComplianceStrings(me.TeamName),
+ cleanComplianceStrings(me.TeamDisplayName),
- me.ChannelName,
- me.ChannelDisplayName,
+ cleanComplianceStrings(me.ChannelName),
+ cleanComplianceStrings(me.ChannelDisplayName),
- me.UserUsername,
- me.UserEmail,
- me.UserNickname,
+ cleanComplianceStrings(me.UserUsername),
+ cleanComplianceStrings(me.UserEmail),
+ cleanComplianceStrings(me.UserNickname),
me.PostId,
time.Unix(0, me.PostCreateAt*int64(1000*1000)).Format(time.RFC3339),
@@ -95,7 +105,7 @@ func (me *CompliancePost) Row() []string {
me.PostRootId,
me.PostParentId,
me.PostOriginalId,
- me.PostMessage,
+ cleanComplianceStrings(me.PostMessage),
me.PostType,
me.PostProps,
me.PostHashtags,
diff --git a/model/compliance_post_test.go b/model/compliance_post_test.go
index 4866b2494..ff159ef1b 100644
--- a/model/compliance_post_test.go
+++ b/model/compliance_post_test.go
@@ -25,3 +25,26 @@ func TestCompliancePost(t *testing.T) {
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)
+ }
+ }
+}