-
Notifications
You must be signed in to change notification settings - Fork 445
SPARK-2380: messages: fetch from URL only images #940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPARK-2380: messages: fetch from URL only images #940
Conversation
… often used http://
| (link.startsWith("xmpp:") && link.contains("?join")) || | ||
| link.startsWith("file:/")) && link.indexOf(".") > 1) { | ||
| link.startsWith("file:/")) | ||
| && link.indexOf(".") > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the condition to a separate line. In fact it tries to ensure that the link is not local domain i.e. not like http://tplinkrouter/cgi-bin/exploit.cgi but at least something.com.
| final ClassicHttpRequest request = ClassicRequestBuilder.get(url) | ||
| .setHeader("Content-Type", "image/*") | ||
| final ClassicHttpRequest request = ClassicRequestBuilder.get(uri) | ||
| .setHeader("Accept", "image/*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Content-Type is a response header, for a request we should set the Accept header to show which mime types we want.
stokito
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments
guusdk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this is a full fix, but it's at least a move in the right direction. Lets merge, experiment, and possibly improve in the future.
https://igniterealtime.atlassian.net/browse/SPARK-2380
The URLConnection.getFileNameMap() returns the
sun.net.www.MimeTablethat has a map of file extension to a MIME type. So we can guess a content type by an extension.This covers most use cases.