(filePath: string, plugin: TaskNotesPlugin)
| 590 | } |
| 591 | |
| 592 | function getTaskInfoSync(filePath: string, plugin: TaskNotesPlugin): TaskInfo | null { |
| 593 | // Validate inputs |
| 594 | if (!filePath || typeof filePath !== "string" || filePath.trim().length === 0) { |
| 595 | return null; |
| 596 | } |
| 597 | |
| 598 | if (!plugin) { |
| 599 | return null; |
| 600 | } |
| 601 | |
| 602 | try { |
| 603 | // Check for invalid characters |
| 604 | const basicInvalidChars = /[<>:"|?*]/; |
| 605 | const hasControlChars = filePath.split("").some((char) => { |
| 606 | const code = char.charCodeAt(0); |
| 607 | return code <= 31 || code === 127; |
| 608 | }); |
| 609 | |
| 610 | if (basicInvalidChars.test(filePath) || hasControlChars) { |
| 611 | return null; |
| 612 | } |
| 613 | |
| 614 | // Use the same cached data access pattern as the views |
| 615 | // This gets the most up-to-date cached task info (updated immediately after any changes) |
| 616 | const cacheManager = plugin.cacheManager; |
| 617 | if (!cacheManager || !cacheManager.getCachedTaskInfoSync) { |
| 618 | return null; |
| 619 | } |
| 620 | |
| 621 | const taskInfo = cacheManager.getCachedTaskInfoSync(filePath); |
| 622 | |
| 623 | // Basic validation of task info structure |
| 624 | if (taskInfo && typeof taskInfo === "object" && taskInfo.title) { |
| 625 | return taskInfo; |
| 626 | } |
| 627 | |
| 628 | return null; |
| 629 | } catch { |
| 630 | return null; |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | export function createTaskLinkOverlay(plugin: TaskNotesPlugin): Extension { |
| 635 | const viewPlugin = createTaskLinkViewPlugin(plugin); |
no test coverage detected