Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit f6b2d6d

Browse files
committed
common: Tweak SanitiseLogString() for better display
Some of the functions which use it for backend logging look a bit weird due to the stripped out line breaks. This commit ensures there's at least a space between words, which should help.
1 parent a421ffd commit f6b2d6d

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

common/sqlite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ func SQLiteRunQueryDefensive(w http.ResponseWriter, r *http.Request, querySource
16061606
var memUsed, memHighWater int64
16071607
memUsed, memHighWater, dataRows, err = SQLiteRunQuery(sdb, querySource, query, false, false)
16081608
if err != nil {
1609-
log.Printf("Error when preparing statement by '%s' for database (%s/%s): '%s'", SanitiseLogString(loggedInUser),
1609+
log.Printf("Error when running query by '%s' for database (%s/%s): '%s'", SanitiseLogString(loggedInUser),
16101610
SanitiseLogString(dbOwner), SanitiseLogString(dbName), SanitiseLogString(err.Error()))
16111611
return SQLiteRecordSet{}, err
16121612
}

common/userinput.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,8 @@ func GetUsername(r *http.Request, allowGet bool) (userName string, err error) {
503503
}
504504

505505
func SanitiseLogString(v string) (result string) {
506-
result = strings.Replace(v, "\n", "", -1)
506+
result = strings.Replace(v, "\n", " ", -1)
507507
result = strings.Replace(result, "\r", "", -1)
508508
result = strings.Replace(result, "'", "\\'", -1)
509-
510509
return result
511510
}

0 commit comments

Comments
 (0)