Copied URL results in "missing or malformed jwt" #2023

Closed
opened 2023-03-10 08:02:24 +00:00 by Bouni · 9 comments

Description

I want to add a link to an attachment to the task description.
next I click the copy URL link below the attachment and add a link to the description like this:

- [Attachment](http://<redacted>/api/v1/tasks/227/attachments/75)

When I click that link in the description afterwards, I get a new window with a JSON message:

message	"missing or malformed jwt"

Vikunja Frontend Version

0.20.3

Vikunja API Version

v0.20.2

Browser and version

Firefox 110.0.1 (64-Bit) / Windows 11

Can you reproduce the bug on the Vikunja demo site?

Yes

Screenshots

My instance:

grafik

Try.vikunja.io

grafik
grafik
grafik

### Description I want to add a link to an attachment to the task description. next I click the copy URL link below the attachment and add a link to the description like this: ``` - [Attachment](http://<redacted>/api/v1/tasks/227/attachments/75) ``` When I click that link in the description afterwards, I get a new window with a JSON message: ``` message "missing or malformed jwt" ``` ### Vikunja Frontend Version 0.20.3 ### Vikunja API Version v0.20.2 ### Browser and version Firefox 110.0.1 (64-Bit) / Windows 11 ### Can you reproduce the bug on the Vikunja demo site? Yes ### Screenshots My instance: ![grafik](/attachments/8e53eabc-ae5d-4471-aa2a-eed385dc54ff) Try.vikunja.io ![grafik](/attachments/4b9d91d1-c14b-4633-9e76-63d36c6b26c7) ![grafik](/attachments/869168af-d374-4d1a-829c-1d1be2274eab) ![grafik](/attachments/584cf82a-9a3e-4568-a97b-1974431af5e7)
Bouni added the
kind/bug
label 2023-03-10 08:02:24 +00:00
konrad was assigned by dpschen 2023-03-10 14:18:44 +00:00
Owner

That's a limitation of the api. I think we could solve this by intercepting links to attachments and downloading them as we do when clicking on the download button. We already do something like that for images embedded in the description or comments.

That's a limitation of the api. I think we could solve this by intercepting links to attachments and downloading them as we do when clicking on the download button. We already do something like that for images embedded in the description or comments.
Author
You mean what you do here: https://kolaente.dev/vikunja/frontend/src/branch/main/src/helpers/markdownRenderer.ts#L17-L19 must be also done here: https://kolaente.dev/vikunja/frontend/src/branch/main/src/helpers/markdownRenderer.ts#L33-L35 Right?
Owner

Pretty much, but then also need to add an event handler to the link object so that it will download the attachment when clicking on it.

Pretty much, but then also need to add an event handler to the link object so that it will download the attachment when clicking on it.
Author

I just gave it a try but I don't see how I could achieve this in a .ts file (markdownRenderer.ts).
Looking at components/tasks/partials/attachments.vue I see that there's a @click="viewOrDownload(a)" but thats a .vue file.

So I think I can't send a PR 🤷‍♂️

But if you fix it I'll look closely at your solution and hopefully learn something new 😅

I just gave it a try but I don't see how I could achieve this in a .ts file (markdownRenderer.ts). Looking at components/tasks/partials/attachments.vue I see that there's a `@click="viewOrDownload(a)"` but thats a .vue file. So I think I can't send a PR 🤷‍♂️ But if you fix it I'll look closely at your solution and hopefully learn something new 😅
Owner

The part for adding an event listener to the links is similar to this one here: https://kolaente.dev/vikunja/frontend/src/branch/main/src/components/input/editor.vue#L268-L275 (adding a change handler to the checkboxes to make checklists work).

Basically, this has a few steps:

  1. For each link, check if it has a link to an attachment, like here: https://kolaente.dev/vikunja/frontend/src/branch/main/src/helpers/markdownRenderer.ts#L17-L19
  2. Then add an event listener to that link so that the click on that link is caught and the attachment is downloaded instead, preventing the actual click. Similar to here: https://kolaente.dev/vikunja/frontend/src/branch/main/src/components/input/editor.vue#L268-L275
  3. In the click event handler, download the attachment and prevent the click action.

The first could be done here as well - just querySelect all link elements in the editor scope and then check if they are linking to an attachment, then add the event handler to it.

The part for adding an event listener to the links is similar to this one here: https://kolaente.dev/vikunja/frontend/src/branch/main/src/components/input/editor.vue#L268-L275 (adding a change handler to the checkboxes to make checklists work). Basically, this has a few steps: 1. For each link, check if it has a link to an attachment, like here: https://kolaente.dev/vikunja/frontend/src/branch/main/src/helpers/markdownRenderer.ts#L17-L19 2. Then add an event listener to that link so that the click on that link is caught and the attachment is downloaded instead, preventing the actual click. Similar to here: https://kolaente.dev/vikunja/frontend/src/branch/main/src/components/input/editor.vue#L268-L275 3. In the click event handler, download the attachment and prevent the click action. The first could be done [here](https://kolaente.dev/vikunja/frontend/src/branch/main/src/components/input/editor.vue#L268) as well - just `querySelect` all link elements in the editor scope and then check if they are linking to an attachment, then add the event handler to it.
dpschen changed title from Copied URL resluts in "missing or malformed jwt" to Copied URL results in "missing or malformed jwt" 2023-03-14 20:39:18 +00:00
Member

image

😉

![image](/attachments/b59028b2-b8a5-4d8f-b873-0e2f23d6722b) 😉
Author

@dpschen 😆 Nasty typo

@dpschen 😆 Nasty typo

If the URL doesn't work as a limit of the API, would it be best to just not include the URL as a comment? Perhaps don't include a comment by default when including an attachment, or just say something like "attached 'image.png'" by default?

Just ran into this today and it's slightly awkward as a user...

If the URL doesn't work as a limit of the API, would it be best to just not include the URL as a comment? Perhaps don't include a comment by default when including an attachment, or just say something like "attached 'image.png'" by default? Just ran into this today and it's slightly awkward as a user...
Author

Seems to be fixed in 0.21.0

Seems to be fixed in 0.21.0
Bouni closed this issue 2023-09-28 09:24:11 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/vikunja#2023
No description provided.