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

Commit 7417e87

Browse files
committed
common, webui: Updates to support visualisation of live databases
1 parent a83a5e2 commit 7417e87

File tree

6 files changed

+371
-248
lines changed

6 files changed

+371
-248
lines changed

api/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ func tablesHandler(w http.ResponseWriter, r *http.Request) {
12321232
return
12331233
}
12341234
} else {
1235-
// Send the columns request to our AMQP backend
1235+
// Send the tables request to our AMQP backend
12361236
var rawResponse []byte
12371237
rawResponse, err = com.MQRequest(com.AmqpChan, liveNode, "tables", loggedInUser, dbOwner, dbName, "")
12381238
if err != nil {

common/postgresql.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,16 @@ func CheckDBPermissions(loggedInUser, dbOwner, dbFolder, dbName string, writeAcc
214214
return false, err
215215
}
216216

217-
// If we get here this means that the database does exist. The next step is to check
218-
// the permissions.
217+
// If we get here this means that the database does exist. The next step is to check the permissions.
219218

220219
if strings.ToLower(loggedInUser) == strings.ToLower(dbOwner) {
221220
// If the request is from the owner of the database, always allow access to the database
222-
223221
return true, nil
224222
} else if writeAccess == false && dbPublic {
225223
// Read access to public databases is always permitted
226-
227224
return true, nil
228225
} else if loggedInUser == "" {
229226
// If the user is not logged in and we reach this point, access is not permitted
230-
231227
return false, nil
232228
}
233229

common/sqlite.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,9 +1405,7 @@ func SQLiteRunQueryDefensive(w http.ResponseWriter, r *http.Request, querySource
14051405
}
14061406

14071407
// Automatically close the SQLite database when this function finishes
1408-
defer func() {
1409-
sdb.Close()
1410-
}()
1408+
defer sdb.Close()
14111409

14121410
// Was a user agent part of the request?
14131411
var userAgent string

common/userinput.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ func CheckUnicode(rawInput string) (str string, err error) {
2828
var decoded []byte
2929
decoded, err = base64.StdEncoding.DecodeString(rawInput)
3030
if err != nil {
31-
// When base64 decoding fails, automatically try again with base64url format instead
32-
var err2 error
31+
// When base64 decoding fails, automatically try again with base64url formats instead
32+
var err2 error // We use err2, to not overwrite the initial error message
3333
decoded, err2 = base64.URLEncoding.DecodeString(rawInput)
3434
if err2 != nil {
35-
// We use err2, so the original error message is returned if the 2nd attempt fails
36-
return
35+
// Try base64URL with no padding character(s) this time
36+
decoded, err2 = base64.RawURLEncoding.DecodeString(rawInput)
37+
if err2 != nil {
38+
// Nope. Seems like a genuine decoding problem
39+
return
40+
}
3741
}
3842
}
3943

0 commit comments

Comments
 (0)