AppFlowy icon indicating copy to clipboard operation
AppFlowy copied to clipboard

[Bug] Images from URL return "invalid URL" if URL contains extra arguments.

Open TDuffinNTU opened this issue 2 years ago • 5 comments

Bug Description

https://images.pexels.com/photos/732444/pexels-photo-732444.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2

Take the above image URL from pexels. It'll open in a browser tab just fine, and is the result of copying the link to an image on the site. However, in Appflowy the image doesn't apply as the URL is "invalid". Removing the arguments makes the image work fine.

image

How to Reproduce

Copy an image from pexels, unsplash, etc. using "copy link to image" or "copy image url" in your browser.

Example: https://images.pexels.com/photos/732444/pexels-photo-732444.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2

Attempt to set it as your document's cover photo with the image from URL feature:

image

Expected Behavior

Image is detected and loaded.

Operating System

Windows

AppFlowy Version(s)

0.3.5

Screenshots

As above.

Additional Context

Possibly failing because the Uri parser is expecting an image file extension such as .jpg? We had some issues with this on our own apps and found that making a get request to the URI and parsing the returned content-type in the response header was a good indicator of whether the link contained the document type we were expecting.

TDuffinNTU avatar Oct 13 '23 14:10 TDuffinNTU

@MayurSMahajan I want to work on this please assign it to me.

DevaanshPathak avatar Oct 20 '23 08:10 DevaanshPathak

Assigned. Have fun !

MayurSMahajan avatar Oct 20 '23 08:10 MayurSMahajan

It is a kind of SQL injection to be exact I am working on the uri parser for it to just expect img extensions and ignore the extra attributes.

DevaanshPathak avatar Oct 28 '23 00:10 DevaanshPathak

@DevaanshPathak , still working on this? need help?

annieappflowy avatar Dec 21 '23 19:12 annieappflowy

@annieappflowy I was working on it until yesterday but am unable to find a fix. Working on open source code is not as easy as it sounds.

DevaanshPathak avatar Dec 24 '23 15:12 DevaanshPathak

Since this issue was created, a lot has changed for the document cover, and I can't reproduce on MacOS anymore.

I'm going to close this for now, we can reopen or create a new issue if still needed.

Xazin avatar Mar 02 '24 19:03 Xazin