Conversation
micahmo
left a comment
There was a problem hiding this comment.
Nice fix! Just out of curiosity, what is the proxy and why do we have to parse it like this?
| : ScalableImageWidget.fromSISource( | ||
| si: ScalableImageSource.fromSvgHttpUrl(uri), | ||
| ) | ||
| : Container( |
There was a problem hiding this comment.
At some point we could make this into a separate SvgViewer widget.
This was introduced as an option in Lemmy 0.19.4: From what I'm understanding, this option allows images that originally came from source A, to be served from source B instead. This helps prevent deanonymization attacks and reduce load on external servers since you (the client) are not connecting to a random external server to fetch contents (and reveal possible information about your client to that given server) For example: if someone uploads an image on To be a bit more clear, the url rewrites it to the following format: |
Hmm, you're right. This might not be the best solution now that I think about it some more. I looked a bit more into it, and it seems like there are some scenarios where the image proxying doesn't work properly. For example, I believe this is the original link that was associated with the issue: https://lemm.ee/post/39487068/14003619. Lemmy UI doesn't display it properly either: This is the corresponding markdown: This is the error when we try to access that link: This might just have to be an issue that we push upstream to Lemmy instead, since it affects them too. I'll see if there's possibly another way to do this without removing the benefits of the image proxying. |
|
I see, maybe the issue with proxied images in comments is an isolated case. Can you verify that other proxied images which work on the web UI also work in Thunder? Then there's the question of the dimensions fix for squished images. Are we unable to load dimensions from proxied images, even though the images themselves load fine? |
… remove proxy bypass from markdown images
It seems like this is isolated to the one example I mentioned above so far. From my brief testing, other images in comments seem to be rendering properly, even though they are being proxied.
I applied a slightly different fix for this in this PR! Instead of using the original URL, I adjusted to logic for image URL parsing to take into account the image proxy endpoint. This should fix the issues with dimensions not loading properly and respect the image proxy settings. |
|
Glad to see that the comment issue was an isolated case! And, if I'm understanding this fix correctly, we're only using the non-proxied URL to determine that it refers to an image, right? But we're never hitting it directly? Looks much better to me! P.S. Out of curiosity, I tried to test this fix. I logged in with my
|
Theoretically, this should be the case! However, I'm noticing something (which relates to the second part of your message)
I looked into this, and it seems like it might be because the API returns back the original URL for images? It seems to apply the proxy to the thumbnail image, but not the post url. |
Ahh interesting! On the one hand, I would say that's not our fault and we shouldn't necessarily have to handle it. On the other hand, I'm still wondering how this fix helps the squished image case, since we don't seem to be using the thumbnail URL for full-height images. At least, I could never hit this breakpoint, either by scrolling the feed or by opening images. Maybe I'm doing something wrong that's unrelated to the API response issue. |
|
You're right - that block of code no longer applies for the dimension fetching logic! Initially, I had this block of code still in-place for bool isImage = isImageUrl(imageUrl!);
if (!isImage) throw Exception('The URL provided was not an image');Because of that, I applied a fix to the URL parsing to handle that case: if (uri.path == '/api/v3/image_proxy') {
Uri? parsedUri = Uri.tryParse(uri.queryParameters['url'] ?? '');
if (parsedUri != null) path = parsedUri.path;
}However, when testing this, I realized that some dimensions weren't being fetched properly because the URL didn't conform to a standard image url (ending with the image format). To solve this, I removed the final imageProvider = ExtendedNetworkImageProvider(imageUrl ?? '', cache: true, cacheRawData: true);
final imageData = await imageProvider.getNetworkImageData();
if (imageData == null) throw Exception('Failed to retrieve image data from $imageUrl');I kept in the proxy parsing logic to handle a more general case (whenever isImageUrl is called):
image.parsing.mp4 |
|
Whew, that's a lot! 😊 If I can summarize:
Fair summary? 😊 |
Correct! This is assuming that the proxied image resolves to a valid image and does not throw an error.
Yup!
I'll have to do more checks here to see if this is right. From the top of my head:
It seems like Lemmy doesn't rewrite the post URL - so proxy images don't apply to places where we use |
|
Cool, that all sounds good. And you're right, our image viewer uses the post image with the goal of showing the highest resolution image to the user. If Lemmy wants to rewrite those to proxy URLs, they can do that in the back end. Aside from any testing you still want to do, I think this is good to go! |






Pull Request Description
This PR fixes issues with markdown images that rely on proxied images (for certain instances that enable this feature). Additionally, I've constrained SVG images to match up with the comment images to prevent render overflow errors.
Issue Being Fixed
Issue Number: #1527
Screenshots / Recordings
proxied.markdown.mp4
Checklist
semanticLabels where applicable for accessibility?