EionRobb / purple-discord

A libpurple/Pidgin plugin for Discord
GNU General Public License v3.0
382 stars 43 forks source link

Bug: incorrect URL for text attachments #395

Closed LurkerHub closed 2 years ago

LurkerHub commented 2 years ago

To reproduce, you will need to use 2 accounts:

  1. The sender, using the official Discord client.
  2. The receiver, using Pidgin.

Steps:

  1. The sender opens a direct message communication channel with the receiver.
  2. The sender drags a text file into the Discord window and sends it to the receiver.
  3. The receiver clicks the link of the attachment.

Message example:

[click to expand] ```json { "id": "900000000000000003", "type": 0, "content": "Test", "channel_id": "800000000000000006", "author": { "id": "800000000000000002", "username": "Buddy", "avatar": null, "discriminator": "0000", "public_flags": 0 }, "attachments": [ { "id": "900000000000000008", "filename": "Custom_Dictionary.txt", "size": 80, "url": "https://cdn.discordapp.com/attachments/800000000000000006/900000000000000008/Custom_Dictionary.txt", "proxy_url": "https://media.discordapp.net/attachments/800000000000000006/900000000000000008/Custom_Dictionary.txt", "content_type": "text/plain; charset=utf-8" } ], "embeds": [], "mentions": [], "mention_roles": [], "pinned": false, "mention_everyone": false, "tts": false, "timestamp": "2022-02-06T07:07:16.353000+00:00", "edited_timestamp": null, "flags": 0, "components": [] } ```

Specifically, the attachment:

"attachments": [
  {
    "id": "900000000000000008",
    "filename": "Custom_Dictionary.txt",
    "size": 80,
    "url": "https://cdn.discordapp.com/attachments/800000000000000006/900000000000000008/Custom_Dictionary.txt",
    "proxy_url": "https://media.discordapp.net/attachments/800000000000000006/900000000000000008/Custom_Dictionary.txt",
    "content_type": "text/plain; charset=utf-8"
  }
]

The message as received by Pidgin:

<span style="color: #A82F2F"><span style="font-size: smaller">(2:07:16 AM)</span> <b>Buddy:</b></span> Test<br>
<span style="color: #A82F2F"><span style="font-size: smaller">(2:07:16 AM)</span> <b>Buddy:</b></span> https://media.discordapp.net/attachments/800000000000000006/900000000000000008/Custom_Dictionary.txt<br>

The problem:

The plugin uses the proxy_url field, which when clicked results in HTTP error 415 and a blank page (at least on Firefox). It should be using the url field instead, which leads to the actual document.

Please note that all the IDs have been obfuscated so none of the links are valid.

LurkerHub commented 2 years ago

Thank you! Please let me know when a Windows DLL is available.

EionRobb commented 2 years ago

@LurkerHub updated dll at https://eion.robbmob.com/libdiscord.dll :)