U4-8216 Hijacked controller actions fail with custom RenderModel subclass due to ModelBinding error

This commit is contained in:
Shannon
2016-03-21 16:12:34 +01:00
parent 75c2b07ad3
commit cd401f5e37

View File

@@ -174,9 +174,15 @@ namespace Umbraco.Web.Mvc
public IModelBinder GetBinder(Type modelType)
{
return TypeHelper.IsTypeAssignableFrom<IRenderModel>(modelType) || TypeHelper.IsTypeAssignableFrom<IPublishedContent>(modelType)
? this
: null;
// can bind to RenderModel (exact type match)
if (modelType == typeof(RenderModel)) return this;
// can bind to RenderModel<TContent> (exact generic type match)
if (modelType.IsGenericType && modelType.GetGenericTypeDefinition() == typeof(RenderModel<>)) return this;
// can bind to TContent where TContent : IPublishedContent (any IPublishedContent implementation)
if (typeof(IPublishedContent).IsAssignableFrom(modelType)) return this;
return null;
}
}
}