Skip to content

Conversation

@stokito
Copy link
Contributor

@stokito stokito commented Jan 8, 2026

https://igniterealtime.atlassian.net/browse/SPARK-2380
The URLConnection.getFileNameMap() returns the sun.net.www.MimeTable that 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.

(link.startsWith("xmpp:") && link.contains("?join")) ||
link.startsWith("file:/")) && link.indexOf(".") > 1) {
link.startsWith("file:/"))
&& link.indexOf(".") > 1) {
Copy link
Contributor Author

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/*")
Copy link
Contributor Author

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.

Copy link
Contributor Author

@stokito stokito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments

Copy link
Member

@guusdk guusdk left a 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.

@guusdk guusdk merged commit 1f0f5da into igniterealtime:master Jan 8, 2026
3 checks passed
@stokito stokito deleted the SPARK-2380_msg_fetch_images branch January 8, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants