Skip to content

Build your personal knowledge base with Trilium Notes

fix(import): address Greptile review of the OneNote importer

Elian Doranb6c25abda1d0
diff --git a/apps/server/src/routes/api/onenote_import.ts b/apps/server/src/routes/api/onenote_import.ts
index ec4f72b21c..fe33061984 100644
--- a/apps/server/src/routes/api/onenote_import.ts
+++ b/apps/server/src/routes/api/onenote_import.ts
@@ -130,7 +130,9 @@ async function getValidAccessToken(req: Request): Promise<string | null> {
return tokens.access_token;
}
- return session.accessToken;
+ // Expired with no refresh token: force a clean reconnect rather than handing back a stale token
+ // that would fail mid-import with a confusing Graph 401.
+ return null;
}
interface TokenStore {
diff --git a/packages/trilium-core/src/services/sanitizer.spec.ts b/packages/trilium-core/src/services/sanitizer.spec.ts
index 0737f163bd..230c953fc4 100644
--- a/packages/trilium-core/src/services/sanitizer.spec.ts
+++ b/packages/trilium-core/src/services/sanitizer.spec.ts
@@ -51,6 +51,13 @@ describe("sanitize", () => {
expect(sanitizeHtml(dirty)).toBe(clean);
});
+ it("keeps the hidden-border style on table header cells", () => {
+ // The OneNote importer maps hidden borders to border-color:transparent on table, td and th —
+ // all three must survive sanitization, or header cells render with visible borders.
+ const dirty = `<table style="border-color:transparent"><tr><th style="border-color:transparent">H</th><td style="border-color:transparent">C</td></tr></table>`;
+ expect(sanitizeHtml(dirty)).toBe(dirty);
+ });
+
describe("bookmark anchors", () => {
it("preserves id attribute on empty <a> tags (CKEditor bookmarks)", () => {
const dirty = `<a id="my-bookmark"></a>`;
diff --git a/packages/trilium-core/src/services/sanitizer.ts b/packages/trilium-core/src/services/sanitizer.ts
index 0a4af492b1..8e72796973 100644
--- a/packages/trilium-core/src/services/sanitizer.ts
+++ b/packages/trilium-core/src/services/sanitizer.ts
@@ -81,6 +81,9 @@ export function sanitizeHtml(dirtyHtml: string) {
/^\s*\d+(?:px|em|%)\s*(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)\s*(#(0x)?[0-9a-fA-F]+|rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\))\s*$/
]
},
+ th: {
+ "border-color": [...colorRegex, /^\s*transparent\s*$/]
+ },
col: {
width: sizeRegex
}