{ "issue": { "url": "https://api.github.com/repos/laurent22/joplin/issues/12121", "repository_url": "https://api.github.com/repos/laurent22/joplin", "labels_url": "https://api.github.com/repos/laurent22/joplin/issues/12121/labels{/name}", "comments_url": "https://api.github.com/repos/laurent22/joplin/issues/12121/comments", "events_url": "https://api.github.com/repos/laurent22/joplin/issues/12121/events", "html_url": "https://github.com/laurent22/joplin/pull/12121", "id": 3002529135, "node_id": "PR_kwDOBLftOs6S_hAU", "number": 12121, "title": "Desktop: Fixes #12049: Fixes MD extensionless imports/tagging", "user": { "login": "tue-AqielOostenbrug", "id": 104417251, "node_id": "U_kgDOBjlH4w", "avatar_url": "https://avatars.githubusercontent.com/u/104417251?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tue-AqielOostenbrug", "html_url": "https://github.com/tue-AqielOostenbrug", "followers_url": "https://api.github.com/users/tue-AqielOostenbrug/followers", "following_url": "https://api.github.com/users/tue-AqielOostenbrug/following{/other_user}", "gists_url": "https://api.github.com/users/tue-AqielOostenbrug/gists{/gist_id}", "starred_url": "https://api.github.com/users/tue-AqielOostenbrug/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tue-AqielOostenbrug/subscriptions", "organizations_url": "https://api.github.com/users/tue-AqielOostenbrug/orgs", "repos_url": "https://api.github.com/users/tue-AqielOostenbrug/repos", "events_url": "https://api.github.com/users/tue-AqielOostenbrug/events{/privacy}", "received_events_url": "https://api.github.com/users/tue-AqielOostenbrug/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "labels": [], "state": "open", "locked": false, "assignee": null, "assignees": [], "milestone": null, "comments": 6, "created_at": "2025-04-17T13:36:30Z", "updated_at": "2025-04-24T13:16:19Z", "closed_at": null, "author_association": "FIRST_TIME_CONTRIBUTOR", "active_lock_reason": null, "draft": false, "pull_request": { "url": "https://api.github.com/repos/laurent22/joplin/pulls/12121", "html_url": "https://github.com/laurent22/joplin/pull/12121", "diff_url": "https://github.com/laurent22/joplin/pull/12121.diff", "patch_url": "https://github.com/laurent22/joplin/pull/12121.patch", "merged_at": null }, "body": "# Background\r\nThis PR attempts to fix issue #12049. In the issue, @marph91 reports on a mix of two problems with importing files with no extension in Markdown. \r\n\r\n# Fix Results\r\nFiles without extensions are imported as files without extensions in Markdown :D. Files without extension are assumed to be of type `application/octet-stream` (binary) as @laurent22 suggested.\r\n\r\n# Explanation\r\n\r\n### Problem 1\r\nFiles without an extension and leading `./` like `![file1](./file1)` get imported as `.file1` whilst only importing `file` is expected.\r\n\r\n### Fix 1\r\nSquashing all `/./` into `/` for the provided path in the function `filename(path)` in `packages/utils/path.ts`:\r\n\r\n![Image](https://github.com/user-attachments/assets/f5e6de76-d1b6-4b64-b147-84b7cb79be72)\r\n(fixed code)\r\n\r\nAnd only splitting on `.` **to find the extension** after removing text preceding the last `/` in the path in the function `fileExtension(path)` in `packages/utils/path.ts`. This ensures that the `..././...` does not get interpreted as a file with the extension `/...` (which has to be filtered out later in the code.)\r\n\r\n![Image](https://github.com/user-attachments/assets/15ea0f98-2fa8-436a-9075-a9a3cc20622f)\r\n(fixed code)\r\n### Problem 2\r\nFiles without an extension, like `![file2](file2)`, are not imported because we attempt to import them as `../../file2.` instead of `../../file2`\r\n\r\n![Image](https://github.com/user-attachments/assets/9abf474e-8a7d-486e-ab8e-3f95c674df83)\r\n(old code)\r\n\r\n### Fix 2\r\nWhile parsing, make it optional to concatenate filenames and their extensions in the function `importLocalFiles(...)` in `packages/lib/services/interop/InteropService_Importer_Md.ts`. So if the file doesn't have an extension (the extension is an empty string), we don't try to import the file as `..\\..\\file3.`, and instead attempt to import the file as `..\\..\\file3`\r\n\r\n![fix2](https://github.com/user-attachments/assets/5e044c63-35f8-457c-a2bb-328fbca8693c)\r\n(fixed code)\r\n\r\n# Testing\r\nAdd an extensionless file and a Markdown file with the first two cases described by @marph91 i.e. containing:\r\n```\r\n1. File without extension and leading `./`: [file1](./sample-extensionless). Get's imported, but filename is converted to extension, like `.file1`\r\n2. File without extension: [file2](sample-extensionless). Not imported at all.\r\n```\r\nCheck if there are truly 2 resulting imports, and if `.sample-extension-less` and `./sample-extension-less` don't occur in the file (could happen if they were not imported).", "closed_by": null, "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/12121/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "timeline_url": "https://api.github.com/repos/laurent22/joplin/issues/12121/timeline", "performed_via_github_app": null, "state_reason": null }, "comments": [ { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2812961629", "html_url": "https://github.com/laurent22/joplin/pull/12121#issuecomment-2812961629", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/12121", "id": 2812961629, "node_id": "IC_kwDOBLftOs6nqmNd", "user": { "login": "github-actions[bot]", "id": 41898282, "node_id": "MDM6Qm90NDE4OTgyODI=", "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github-actions%5Bbot%5D", "html_url": "https://github.com/apps/github-actions", "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers", "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}", "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}", "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions", "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs", "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos", "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}", "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events", "type": "Bot", "user_view_type": "public", "site_admin": false }, "created_at": "2025-04-17T13:36:43Z", "updated_at": "2025-04-20T11:40:01Z", "author_association": "CONTRIBUTOR", "body": "****CLA Assistant Lite bot**** All contributors have signed the CLA ✍️ ✅", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2812961629/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": { "id": 15368, "client_id": "Iv1.05c79e9ad1f6bdfa", "slug": "github-actions", "node_id": "MDM6QXBwMTUzNjg=", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "user_view_type": "public", "site_admin": false }, "name": "GitHub Actions", "description": "Automate your workflow from idea to production", "external_url": "https://help.github.com/en/actions", "html_url": "https://github.com/apps/github-actions", "created_at": "2018-07-30T09:30:17Z", "updated_at": "2025-03-07T16:35:00Z", "permissions": { "actions": "write", "administration": "read", "attestations": "write", "checks": "write", "contents": "write", "deployments": "write", "discussions": "write", "issues": "write", "merge_queues": "write", "metadata": "read", "models": "read", "packages": "write", "pages": "write", "pull_requests": "write", "repository_hooks": "write", "repository_projects": "write", "security_events": "write", "statuses": "write", "vulnerability_alerts": "read" }, "events": [ "branch_protection_rule", "check_run", "check_suite", "create", "delete", "deployment", "deployment_status", "discussion", "discussion_comment", "fork", "gollum", "issues", "issue_comment", "label", "merge_group", "milestone", "page_build", "project", "project_card", "project_column", "public", "pull_request", "pull_request_review", "pull_request_review_comment", "push", "registry_package", "release", "repository", "repository_dispatch", "status", "watch", "workflow_dispatch", "workflow_run" ] } }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2812962785", "html_url": "https://github.com/laurent22/joplin/pull/12121#issuecomment-2812962785", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/12121", "id": 2812962785, "node_id": "IC_kwDOBLftOs6nqmfh", "user": { "login": "tue-AqielOostenbrug", "id": 104417251, "node_id": "U_kgDOBjlH4w", "avatar_url": "https://avatars.githubusercontent.com/u/104417251?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tue-AqielOostenbrug", "html_url": "https://github.com/tue-AqielOostenbrug", "followers_url": "https://api.github.com/users/tue-AqielOostenbrug/followers", "following_url": "https://api.github.com/users/tue-AqielOostenbrug/following{/other_user}", "gists_url": "https://api.github.com/users/tue-AqielOostenbrug/gists{/gist_id}", "starred_url": "https://api.github.com/users/tue-AqielOostenbrug/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tue-AqielOostenbrug/subscriptions", "organizations_url": "https://api.github.com/users/tue-AqielOostenbrug/orgs", "repos_url": "https://api.github.com/users/tue-AqielOostenbrug/repos", "events_url": "https://api.github.com/users/tue-AqielOostenbrug/events{/privacy}", "received_events_url": "https://api.github.com/users/tue-AqielOostenbrug/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2025-04-17T13:37:04Z", "updated_at": "2025-04-17T13:37:04Z", "author_association": "NONE", "body": "I have read the CLA Document and I hereby sign the CLA", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2812962785/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2812998902", "html_url": "https://github.com/laurent22/joplin/pull/12121#issuecomment-2812998902", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/12121", "id": 2812998902, "node_id": "IC_kwDOBLftOs6nqvT2", "user": { "login": "personalizedrefrigerator", "id": 46334387, "node_id": "MDQ6VXNlcjQ2MzM0Mzg3", "avatar_url": "https://avatars.githubusercontent.com/u/46334387?v=4", "gravatar_id": "", "url": "https://api.github.com/users/personalizedrefrigerator", "html_url": "https://github.com/personalizedrefrigerator", "followers_url": "https://api.github.com/users/personalizedrefrigerator/followers", "following_url": "https://api.github.com/users/personalizedrefrigerator/following{/other_user}", "gists_url": "https://api.github.com/users/personalizedrefrigerator/gists{/gist_id}", "starred_url": "https://api.github.com/users/personalizedrefrigerator/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/personalizedrefrigerator/subscriptions", "organizations_url": "https://api.github.com/users/personalizedrefrigerator/orgs", "repos_url": "https://api.github.com/users/personalizedrefrigerator/repos", "events_url": "https://api.github.com/users/personalizedrefrigerator/events{/privacy}", "received_events_url": "https://api.github.com/users/personalizedrefrigerator/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2025-04-17T13:49:20Z", "updated_at": "2025-04-17T13:49:20Z", "author_association": "COLLABORATOR", "body": "Thank you for working on this!\r\n\r\nThe pull request currently splits by `/` and replaces `/./` with `/`. Windows, however, supports `\\`s as path separators. Does the issue still exist on Windows, with this pull request?", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2812998902/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2813633894", "html_url": "https://github.com/laurent22/joplin/pull/12121#issuecomment-2813633894", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/12121", "id": 2813633894, "node_id": "IC_kwDOBLftOs6ntKVm", "user": { "login": "tue-AqielOostenbrug", "id": 104417251, "node_id": "U_kgDOBjlH4w", "avatar_url": "https://avatars.githubusercontent.com/u/104417251?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tue-AqielOostenbrug", "html_url": "https://github.com/tue-AqielOostenbrug", "followers_url": "https://api.github.com/users/tue-AqielOostenbrug/followers", "following_url": "https://api.github.com/users/tue-AqielOostenbrug/following{/other_user}", "gists_url": "https://api.github.com/users/tue-AqielOostenbrug/gists{/gist_id}", "starred_url": "https://api.github.com/users/tue-AqielOostenbrug/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tue-AqielOostenbrug/subscriptions", "organizations_url": "https://api.github.com/users/tue-AqielOostenbrug/orgs", "repos_url": "https://api.github.com/users/tue-AqielOostenbrug/repos", "events_url": "https://api.github.com/users/tue-AqielOostenbrug/events{/privacy}", "received_events_url": "https://api.github.com/users/tue-AqielOostenbrug/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2025-04-17T17:37:11Z", "updated_at": "2025-04-17T17:38:15Z", "author_association": "NONE", "body": "Hi @personalizedrefrigerator, happy to be here n contribute :).\r\n\r\nFrom what I've seen of Joplin, I think that it automatically converts forward slashes to backward slashes since:\r\n- I think Markdown is only supposed to work with forward slashes\r\n- Testing tagging with backslashes tested on Windows shows me that backslashes are automatically converted to forward slashes. \r\n- A forward slash is hardcoded into the assignment of attachmentPath just before my code modifications in the `importLocalFiles(...)` function in `packages/lib/services/interop/InteropService_Importer_Md.ts` (above) and mixing backward and forward slashes would cause havoc filepath resolving.\r\n\r\nSo, I think this PR would also fix it for Windows since the behaviour would be the same.\r\n\r\nBut, right now I'm struggling a bit with a CI specific check:\r\n[InteropService_Importer_OneNote › should be able to create notes from corrupted attachment](https://github.com/laurent22/joplin/actions/runs/14520029169/job/40738459628?pr=12121)\r\n(https://github.com/laurent22/joplin/tree/dev/packages/lib/services/interop/InteropService_Importer_OneNote.test.ts) (line 170)\r\n```\r\nskipIfNotCI('should ignore broken characters at the start of paragraph', async () => {\r\n\t\tlet idx = 0;\r\n\t\tconst originalIdGenerator = BaseModel.setIdGenerator(() => String(idx++));\r\n\t\tconst notes = await importNote(`${supportDir}/onenote/bug_broken_character.zip`);\r\n\r\n\t\texpect(notes.find(n => n.title === 'Action research - Wikipedia').body).toMatchSnapshot();\r\n\r\n\t\tBaseModel.setIdGenerator(originalIdGenerator);\r\n\t});\r\n```\r\nThis seems to just be a CI specific test that can't run locally. Do you maybe know a bit more about why it is failing?", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2813633894/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2826714702", "html_url": "https://github.com/laurent22/joplin/pull/12121#issuecomment-2826714702", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/12121", "id": 2826714702, "node_id": "IC_kwDOBLftOs6ofD5O", "user": { "login": "laurent22", "id": 1285584, "node_id": "MDQ6VXNlcjEyODU1ODQ=", "avatar_url": "https://avatars.githubusercontent.com/u/1285584?v=4", "gravatar_id": "", "url": "https://api.github.com/users/laurent22", "html_url": "https://github.com/laurent22", "followers_url": "https://api.github.com/users/laurent22/followers", "following_url": "https://api.github.com/users/laurent22/following{/other_user}", "gists_url": "https://api.github.com/users/laurent22/gists{/gist_id}", "starred_url": "https://api.github.com/users/laurent22/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/laurent22/subscriptions", "organizations_url": "https://api.github.com/users/laurent22/orgs", "repos_url": "https://api.github.com/users/laurent22/repos", "events_url": "https://api.github.com/users/laurent22/events{/privacy}", "received_events_url": "https://api.github.com/users/laurent22/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2025-04-24T08:00:07Z", "updated_at": "2025-04-24T08:00:07Z", "author_association": "OWNER", "body": "> But, right now I'm struggling a bit with a CI specific check\r\n\r\nThe failing test seems to be related to your change since it affects a path. To run the tests on your machine have a look here: `packages/onenote-converter/README.md`. I think you'd need to run `IS_CONTINUOUS_INTEGRATION=1 yarn test` to run this particular test. @pedr maybe can confirm", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2826714702/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2827601464", "html_url": "https://github.com/laurent22/joplin/pull/12121#issuecomment-2827601464", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/12121", "id": 2827601464, "node_id": "IC_kwDOBLftOs6oicY4", "user": { "login": "pedr", "id": 5051088, "node_id": "MDQ6VXNlcjUwNTEwODg=", "avatar_url": "https://avatars.githubusercontent.com/u/5051088?v=4", "gravatar_id": "", "url": "https://api.github.com/users/pedr", "html_url": "https://github.com/pedr", "followers_url": "https://api.github.com/users/pedr/followers", "following_url": "https://api.github.com/users/pedr/following{/other_user}", "gists_url": "https://api.github.com/users/pedr/gists{/gist_id}", "starred_url": "https://api.github.com/users/pedr/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/pedr/subscriptions", "organizations_url": "https://api.github.com/users/pedr/orgs", "repos_url": "https://api.github.com/users/pedr/repos", "events_url": "https://api.github.com/users/pedr/events{/privacy}", "received_events_url": "https://api.github.com/users/pedr/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2025-04-24T13:16:18Z", "updated_at": "2025-04-24T13:16:18Z", "author_association": "COLLABORATOR", "body": "> > But, right now I'm struggling a bit with a CI specific check\r\n> \r\n> The failing test seems to be related to your change since it affects a path. To run the tests on your machine have a look here: `packages/onenote-converter/README.md`. I think you'd need to run `IS_CONTINUOUS_INTEGRATION=1 yarn test` to run this particular test. @pedr maybe can confirm\r\n\r\nThat is correct, we disable the tests that rely on `onenote-converter` package by default so developers who are not going to work with it don't have to handle the Rust environment and dependencies.\r\n\r\n@laurent22 Maybe we could add this information in the error so next contributors might be able to get that the tests is failing is not only a random CI failure. I'm going to see if there is anything we can do about it with Jest", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2827601464/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null } ] }