mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-06 11:49:14 +02:00
feat:#36 added new event grpc message
This commit is contained in:
@@ -19,9 +19,26 @@ package db
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"log/slog"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func FindCollection(app *pocketbase.PocketBase, collectionName string) (*models.Collection, error) {
|
||||
collection, dbError := app.Dao().FindCollectionByNameOrId(collectionName)
|
||||
return collection, dbError
|
||||
}
|
||||
|
||||
// IsSafeIdentifier check uuids against sql injection
|
||||
// uuids are generated by the system and are not user input
|
||||
// following the pattern of only containing alphanumeric characters and dashes
|
||||
func IsSafeIdentifier(uuid string) bool {
|
||||
// Define a regular expression that matches only valid UUID characters (alphanumeric and dashes)
|
||||
validUUIDPattern := `^[a-zA-Z0-9-]+$`
|
||||
match, err := regexp.MatchString(validUUIDPattern, uuid)
|
||||
if err != nil {
|
||||
// Handle the error according to your application's needs
|
||||
slog.Warn("Invalid UUID pattern", "uuid", uuid)
|
||||
return false
|
||||
}
|
||||
return match
|
||||
}
|
||||
|
Reference in New Issue
Block a user