ptpb / pb

pb is a formerly-lightweight pastebin and url shortener
Other
549 stars 52 forks source link

Images pastes without an extension are not displayed correctly in Firefox #128

Closed HalosGhost closed 9 years ago

HalosGhost commented 9 years ago

An image paste loaded in Firefox without an extension added to the end of the id will not correctly display (instead, the binary data will be output).

buhman commented 9 years ago

Needs testcase or example.

HalosGhost commented 9 years ago

If, for example, you navigate to this paste in Firefox, you will see the following:

binary junk

If, instead, you navigate to the same paste with a file extension specified (note that you can give it an incorrect file extension), you will find this:

the image

buhman commented 9 years ago

Ahh. Not a bug. It's intended that you override the default text/plain with your extension, because doing it this way is fast and simple to implement.

Otherwise, it's possible to libmagic the body on every GET (or calculate this once and store the result in the db).

So uh.. how do you want this to work exactly?

If you -F @c=foo.jpg right now, you get <shortid>.jpg back. Would you rather I also set the 'default' mimetype for <shortid> to jpg for that paste as well?

HalosGhost commented 9 years ago

I think that using libmagic on every GET seems like a sadtime; but using it once and storing it (probably on upload so that it handles paste updating fine) seems like it'd be a good idea (since it would gracefully handle stdin cases).

Does that make sense to you?

buhman commented 9 years ago

Yep.

HalosGhost commented 9 years ago

Great! I look forward to the implementation!

buhman commented 9 years ago

3ca079ad0ed0cbdbe715eab44f462648e0dc61b9

buhman commented 9 years ago

note that you can give it an incorrect file extension

Not a bug.