Slack: Raw links to binary files spew a lot of garbage into a channel

Created on 22 May 2018  路  8Comments  路  Source: integrations/slack

Steps to reproduce:
Link the following two URLs in a channel that has the new GitHub For Slack integration turned on, such that GfS is doing the link expansion of the first link:
1) https://github.com/jenkinsci/emotional-jenkins-plugin/blob/master/src/main/webapp/images/sad-jenkins.png?raw=true
2) https://raw.githubusercontent.com/jenkinsci/emotional-jenkins-plugin/master/src/main/webapp/images/sad-jenkins.png

The url for 1) is obtained by doing a "right-click" / "copy image address" from the repository listing https://github.com/jenkinsci/emotional-jenkins-plugin/blob/master/src/main/webapp/images/sad-jenkins.png. We would assume it would be served up as an image, but instead it renders as though somebody threw the text content of the file into a ``` block.

screen shot 2018-05-22 at 4 53 38 pm

It'd be great if some kind of logic was used to avoid trying to render binary files as text here.
(I've also seen this trigger for links to PDFs and SVGs, to give other examples of filetypes commonly both stored in GitHub repositories and linked in Slack.)

good first issue bug

All 8 comments

Is this still relevant? If so, just comment with any updates and we'll leave it open. Otherwise, if there is no further activity, it will be closed.

Sure seems to still inline them as gibberish.

Thanks for reporting the issue.

If someone wants to try fixing this, I think it it _Should Be Easy鈩.

You'll want to update the blob unfurl to check if the file is binary and avoid unfurling it if it is. Unfortunately the contents API doesn't return any meta data about what GitHub thinks the file is, so we'll have to do our own binary detection. isbinaryfile looks like it would do the trick.

Whoops, I've just seen that there was already a PR open to fix this. The implementation is almost identical #676 and #685

@doms as I said in my previous comment we have very similar PRs. Yours looks complete and with tests so feel free to update your PR and we can go ahead and merge it and I'll close mine.

@gimenete Sounds good! Just waiting from further feedback from @bkeepers !

@gimenete It looks like because of how #676 was merged into master through #705 this issue didn't get closed out properly.

@R-Campbell oh, thanks! I'll close it now then 馃槃

Was this page helpful?
0 / 5 - 0 ratings