advanced-cms / advanced-reviews

This is an Open Source add-on that improves the reviewing process and lets external users to view & review content items or whole projects without the need to access the Edit Mode. Created and maintained by Bartosz Sekuła and Grzegorz Wiecheć
Apache License 2.0
17 stars 15 forks source link

404 on preview images due to queryparams #210

Closed QuirijnLangedijk closed 1 year ago

QuirijnLangedijk commented 2 years ago

Hi,

When visiting a preview link, image urls give a 404. This seems to be because the generated URLs are wrong, or break the package. For example: src="http://localhost:57728/ImageProxy?token=ef3ed40e-69ea-4a7b-b4fc-4a67e6405790&contentLink=5517_12302?width=518&height=345" I can find two reasons why:

  1. The query parameters that are added after the contentLink seem to break the request.
  2. The url is being encoded (& -> \&). This also happens on the 'normal' view, but doesnt break anything. This can be fixed by using Html.Raw however.

So: "http://localhost:57728/ImageProxy?token=ef3ed40e-69ea-4a7b-b4fc-4a67e6405790&contentLink=5517_12302?width=518&height=345" doesnt work, "http://localhost:57728/ImageProxy?token=ef3ed40e-69ea-4a7b-b4fc-4a67e6405790&contentLink=5517_12302" doesnt work either, only "http://localhost:57728/ImageProxy?token=ef3ed40e-69ea-4a7b-b4fc-4a67e6405790&contentLink=5517_123025" works

Is there any way to make sure the query parameters dont break the images?

barteksekula commented 2 years ago

@QuirijnLangedijk can you find out who is causing this? I don't see the issue in our test Alloy project. You can just clone the repo, build and run.

daniel-isaacs commented 1 year ago

I see the same issue with some images in Foundation. The encoded url doesn't seem to be a problem, but the query string is -- it ends up with two "?" in the URL and the second one gets treated as a literal "?", which ends up at a 404. However, I don't know if it's something that can be fixed in the add-on:

For example, the header image breaks in external view/review links, because the image path gets rendered as: "/ImageProxy?token=83615482-ef5c-4e38-ab3d-2f1c1d8dcafe&contentLink=323?format=webp&width=225"

The second question mark in there comes from the View: \src\Foundation\Features\Shared\Views\Header_Navigation.cshtml "@Url.ContentUrl(Model.LayoutSettings.SiteLogo)?format=webp&width=225"

Since the View is appending the additional query string after the URL is generated by advanced-reviews, I'm not sure anything can be done on this end. Thoughts?

(Ping me on Teams/email if you have any questions on this example.)