Skip to content

📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Fix escape html panic on nil pointers

Smaug6739f5c5bac472ca
diff --git a/backend/controllers/nodes.controller.go b/backend/controllers/nodes.controller.go
index 2138cbbe..7f419b92 100644
--- a/backend/controllers/nodes.controller.go
+++ b/backend/controllers/nodes.controller.go
@@ -172,7 +172,7 @@ func (ctr *Controller) CreateNode(c *gin.Context) (int, any) {
if err != nil {
return http.StatusUnauthorized, err
}
- escapedHTMLContent := utils.EscapeHTML(*node.ContentCompiled)
+ escapedHTMLContent := utils.EscapeHTML(node.ContentCompiled)
node = &models.Node{
Id: ctr.app.Snowflake.Generate(),
ParentId: node.ParentId,
@@ -246,7 +246,7 @@ func (ctr *Controller) UpdateNode(c *gin.Context) (int, any) {
node.Accessibility = dbNode.Accessibility
node.Access = dbNode.Access
}
- escapedHTMLContent := utils.EscapeHTML(*node.ContentCompiled)
+ escapedHTMLContent := utils.EscapeHTML(node.ContentCompiled)
node = &models.Node{
Id: nodeId,
ParentId: node.ParentId,
diff --git a/backend/utils/escape-html.go b/backend/utils/escape-html.go
index 74110566..a4e2fe12 100644
--- a/backend/utils/escape-html.go
+++ b/backend/utils/escape-html.go
@@ -99,6 +99,9 @@ func InitBluemonday() {
}
// EscapeHTML sanitizes user input to prevent XSS attacks
-func EscapeHTML(input string) string {
- return policy.Sanitize(input)
+func EscapeHTML(input *string) string {
+ if input == nil || *input == "" {
+ return ""
+ }
+ return policy.Sanitize(*input)
}
diff --git a/docker-compose.yml b/docker-compose.yml
index 9246d3bf..8b2fb205 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -68,13 +68,12 @@ services:
DATABASE_NAME: alexandrie
DATABASE_USER: alexandrie
DATABASE_PASSWORD: password
- ALLOW_UNSECURE: 'true' # Set to 'true' if you run without HTTPS (e.g., local dev); in production, use 'false' and set up HTTPS
# Application Configuration
- JWT_SECRET: your-secure-jwt-secret-key-change-this-in-production
- DOMAIN_CLIENT: http://localhost:8200 # For CORS Policy, if you have "Cors" error, check this
- COOKIE_DOMAIN: localhost # Very optional, can be left empty. For auth cookies: If you can't login (or you are disconnected immediatly), check this; DON'T set an URL just the DOMAIN (e.g., "example.com" or "localhost")
-
+ JWT_SECRET: t493m87nh5sgjpe8rmzu8smjz0usheijbfkophgroh548pje9kgore§G/(GO
+ DOMAIN_CLIENT: http://192.168.0.25:8200 # For CORS Policy, if you have "Cors" error, check this
+ COOKIE_DOMAIN: 192.168.0.25 # Very optional, can be left empty. For auth cookies: If you can't login (or you are disconnected immediatly), check this; DON'T set an URL just the DOMAIN (e.g., "example.com" or "localhost")
+ ALLOW_UNSECURE: 'true' # Allow cookies over HTTP (not HTTPS). Set to 'false' in production with HTTPS
# MinIO Configuration (optional, you can replace config with "" to disable MinIO usage)
MINIO_ENDPOINT: rustfs:9000
MINIO_ACCESSKEY: alexandrie-key
@@ -109,9 +108,9 @@ services:
environment:
PORT: 8200
# Runtime configuration - builds with these values at startup
- NUXT_PUBLIC_BASE_API: http://localhost:8201
- NUXT_PUBLIC_BASE_CDN: http://localhost:9000/alexandrie
- NUXT_PUBLIC_BASE_URL: http://localhost:8200
+ NUXT_PUBLIC_BASE_API: http://192.168.0.25:8201
+ NUXT_PUBLIC_BASE_CDN: http://192.168.0.25:9000/alexandrie
+ NUXT_PUBLIC_BASE_URL: http://192.168.0.25:8200
ports:
- '8200:8200'
depends_on: