Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(security): require scripting to be enabled for sharing?
perfectra1n43963b7b719a
diff --git a/apps/server/src/share/routes.spec.ts b/apps/server/src/share/routes.spec.tsindex a920a3620d..4a03acd24a 100644--- a/apps/server/src/share/routes.spec.ts+++ b/apps/server/src/share/routes.spec.ts@@ -3,6 +3,7 @@ import supertest from "supertest";import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";import { safeExtractMessageAndStackFromError } from "../services/utils.js";+import config from "../services/config.js";let app: Application;@@ -36,12 +37,19 @@ describe("Share API test", () => {});it("renders custom share template", async () => {- const response = await supertest(app)- .get("/share/pQvNLLoHcMwH")- .expect(200);- expect(cannotSetHeadersCount).toBe(0);- expect(response.text).toContain("Content Start");- expect(response.text).toContain("Content End");+ // Custom EJS templates require scripting to be enabled+ const originalEnabled = config.Scripting.enabled;+ config.Scripting.enabled = true;+ try {+ const response = await supertest(app)+ .get("/share/pQvNLLoHcMwH")+ .expect(200);+ expect(cannotSetHeadersCount).toBe(0);+ expect(response.text).toContain("Content Start");+ expect(response.text).toContain("Content End");+ } finally {+ config.Scripting.enabled = originalEnabled;+ }});});