mirror of
https://github.com/callumalpass/tasknotes.git
synced 2026-07-22 12:50:26 +00:00
fix: Support relative paths in inline task link replacement (#440)
Remove overly aggressive path sanitization that stripped ".." from link paths, which broke relative path resolution for both wikilinks and markdown links. Obsidian's metadataCache.getFirstLinkpathDest() already handles relative paths safely, so the sanitization was unnecessary and harmful.
This commit is contained in:
parent
0c64c7c0e5
commit
5432757586
3 changed files with 11 additions and 13 deletions
|
|
@ -27,6 +27,13 @@ Example:
|
|||
|
||||
## Fixed
|
||||
|
||||
- (#440) Fixed inline task replacement not working for links with relative paths
|
||||
- Markdown links with relative paths like `[task](../../../GTD/tasks/task.md)` now display inline previews
|
||||
- Wikilinks with relative paths now work correctly
|
||||
- Removed overly aggressive path sanitization that was stripping `..` from all link paths
|
||||
- Works in both Live Preview and Reading Mode
|
||||
- Thanks to @minchinweb for reporting
|
||||
|
||||
- (#814) Fixed markdown links in projects field not being recognized on Project notes
|
||||
- Tasks with markdown-style project links `[text](path)` now appear in project's Subtasks section
|
||||
- Updated project link detection to use `parseLinkToPath` utility which handles both wikilinks and markdown links
|
||||
|
|
|
|||
|
|
@ -109,13 +109,9 @@ export class ReadingModeTaskLinkProcessor {
|
|||
*/
|
||||
private resolveLinkPath(linkPath: string, sourcePath: string): string | null {
|
||||
try {
|
||||
// Sanitize link path to prevent directory traversal
|
||||
const sanitizedLinkPath = linkPath.replace(/\.\./g, "").trim();
|
||||
if (!sanitizedLinkPath) return null;
|
||||
|
||||
// Use Obsidian's metadata cache to resolve the link
|
||||
// Use Obsidian's metadata cache to resolve the link - it handles relative paths safely
|
||||
const file = this.plugin.app.metadataCache.getFirstLinkpathDest(
|
||||
sanitizedLinkPath,
|
||||
linkPath,
|
||||
sourcePath
|
||||
);
|
||||
return file?.path || null;
|
||||
|
|
|
|||
|
|
@ -394,13 +394,8 @@ function resolveLinkPathSync(
|
|||
}
|
||||
|
||||
try {
|
||||
// Sanitize link path to prevent directory traversal
|
||||
const sanitizedLinkPath = linkPath.replace(/\.\./g, "").trim();
|
||||
if (!sanitizedLinkPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const file = plugin.app.metadataCache.getFirstLinkpathDest(sanitizedLinkPath, sourcePath);
|
||||
// Use Obsidian's API to resolve the link path - it handles relative paths safely
|
||||
const file = plugin.app.metadataCache.getFirstLinkpathDest(linkPath, sourcePath);
|
||||
|
||||
// Validate result
|
||||
if (!file || !file.path || typeof file.path !== "string") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue