导出和记录属性的时候,替换特殊字符串
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -15,6 +16,7 @@ import (
|
||||
"github.com/gogf/gf/v2/net/gclient"
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
type sendBody struct {
|
||||
@@ -66,6 +68,16 @@ var (
|
||||
|
||||
)
|
||||
|
||||
var safePropertyRE = regexp.MustCompile(`["'\\\/]`)
|
||||
|
||||
func safeProperty(property map[string]any) {
|
||||
for k, v := range property {
|
||||
if _, ok := v.(string); ok {
|
||||
property[k] = safePropertyRE.ReplaceAllString(gconv.String(v), "*")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getLocationMapValue(key string) *time.Location {
|
||||
// 1. 先尝试读
|
||||
value, loaded := locationMap.Load(key)
|
||||
@@ -278,6 +290,7 @@ func (sdk *SDK) Log(uid, event string, property map[string]any, timezone string,
|
||||
if len(property) == 0 {
|
||||
property = map[string]any{"ts": gtime.Now().Timestamp()}
|
||||
}
|
||||
safeProperty(property)
|
||||
var et *gtime.Time
|
||||
if len(customEventTime) > 0 {
|
||||
et = gtime.NewFromTime(customEventTime[0])
|
||||
|
||||
Reference in New Issue
Block a user