umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.4k stars 2.66k forks source link

Imagesharp Cropping blocks other middleware #15470

Open rsoeteman opened 8 months ago

rsoeteman commented 8 months ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

v12+

Bug summary

I have a filter that checks media items. This works fine until I request an image with image dimensions.

https://localhost:44318/media/3cleoc0g/adminprotected.png?width=500 then the whole pipeline is terminated. https://localhost:44318/media/3cleoc0g/adminprotected.png Works since this url is ignored by the imageprocessor

Specifics

No response

Steps to reproduce

use this filter

 public  class MyTestFilterFilter : UmbracoPipelineFilter 
 {
     public MyTestFilterFilter(string name) : base(name) => PrePipeline = PrePipelineAction;

     public MyTestFilterFilter(string name, Action<IApplicationBuilder> prePipeline, Action<IApplicationBuilder> postPipeline, Action<IApplicationBuilder> endpointCallback) : base(name, prePipeline, postPipeline, endpointCallback)
     {
     }

     public MyTestFilterFilter(string name, Action<IApplicationBuilder> prePipeline = null, Action<IApplicationBuilder> preRouting = null, Action<IApplicationBuilder> postRouting = null, Action<IApplicationBuilder> postPipeline = null, Action<IApplicationBuilder> endpoints = null) : base(name, prePipeline, preRouting, postRouting, postPipeline, endpoints)
     {
     }

     private void PrePipelineAction(IApplicationBuilder applicationBuilder)
     {
         //Get's hit when there are no cropper dimensions, otherwise not.
     }
 }

And configure it

builder.Services.Configure<UmbracoPipelineOptions>(options => options.AddFilter(new MyTestFilterFilter("MyTestFilterFilter")));

Request https://localhost:44318/media/3cleoc0g/adminprotected.png See PrePipelineAction is hit

Request https://localhost:44318/media/3cleoc0g/adminprotected.png?width=500 see PrePipelineAction is not hit.

Expected result / actual result

Expected: In both cases the PrePipelineAction is hit

github-actions[bot] commented 8 months ago

Hi there @rsoeteman!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

bergmania commented 8 months ago

Hi @rsoeteman

Imagesharp middleware is added in the same way.

I think you will need to insure you add your filter first, e.g.

builder.Services.Configure<UmbracoPipelineOptions>(options => options.PipelineFilters.Insert(0, new MyTestFilterFilter("MyTestFilterFilter")));
rsoeteman commented 8 months ago

Thanks @bergmania Tried that but same result, maybe my plugin gets registered before ImageSharp?

bergmania commented 8 months ago

You should be able to inspect the options.PipelineFilters and see the ordering. And if your get registed before imagesharp, then imagesharp should still end up after your.