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

Open
opened 2 weeks ago by Bouni · 7 comments
Bouni commented 2 weeks ago

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 2 weeks ago
konrad was assigned by dpschen 2 weeks ago
konrad commented 2 weeks ago
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.
Bouni commented 1 week ago
Poster
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?
konrad commented 1 week ago
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.
Bouni commented 1 week ago
Poster

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 😅
konrad commented 1 week ago
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" 1 week ago
dpschen commented 1 week ago
Collaborator

image

😉

![image](/attachments/b59028b2-b8a5-4d8f-b873-0e2f23d6722b) 😉
Bouni commented 6 days ago
Poster

@dpschen 😆 Nasty typo

@dpschen 😆 Nasty typo
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/frontend#3224
Loading…
There is no content yet.