Merge branch 'v10/dev' into v10/feature/nullable-reference-types-in-Umbraco.Web.Backoffice
# Conflicts: # src/Umbraco.Core/Cache/MacroCacheRefresher.cs # src/Umbraco.Core/Services/MacroService.cs # src/Umbraco.Core/StaticApplicationLogging.cs # src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TrackedReferencesRepository.cs # src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs # src/Umbraco.Infrastructure/Security/UmbracoPasswordHasher.cs # src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Cms.Core.IO;
|
||||
using Umbraco.Cms.Core.Media;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Strings;
|
||||
using Umbraco.Cms.Web.Common.Attributes;
|
||||
using Umbraco.Extensions;
|
||||
using Constants = Umbraco.Cms.Core.Constants;
|
||||
@@ -53,10 +55,15 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
/// </remarks>
|
||||
public IActionResult GetResized(string imagePath, int width)
|
||||
{
|
||||
var ext = Path.GetExtension(imagePath);
|
||||
// We have to use HttpUtility to encode the path here, for non-ASCII characters
|
||||
// We cannot use the WebUtility, as we only want to encode the path, and not the entire string
|
||||
var encodedImagePath = HttpUtility.UrlPathEncode(imagePath);
|
||||
|
||||
|
||||
var ext = Path.GetExtension(encodedImagePath);
|
||||
|
||||
// check if imagePath is local to prevent open redirect
|
||||
if (!Uri.IsWellFormedUriString(imagePath, UriKind.Relative))
|
||||
if (!Uri.IsWellFormedUriString(encodedImagePath, UriKind.Relative))
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
@@ -82,7 +89,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
}
|
||||
|
||||
var rnd = imageLastModified.HasValue ? $"&rnd={imageLastModified:yyyyMMddHHmmss}" : null;
|
||||
var imageUrl = _imageUrlGenerator.GetImageUrl(new ImageUrlGenerationOptions(imagePath)
|
||||
var imageUrl = _imageUrlGenerator.GetImageUrl(new ImageUrlGenerationOptions(encodedImagePath)
|
||||
{
|
||||
Width = width,
|
||||
ImageCropMode = ImageCropMode.Max,
|
||||
|
||||
@@ -1097,7 +1097,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
return new ActionResult<IMedia>(toMove);
|
||||
}
|
||||
|
||||
[Obsolete("Please use TrackedReferencesController.GetPagedReferences() instead. Scheduled for removal in V11.")]
|
||||
[Obsolete("Please use TrackedReferencesController.GetPagedRelationsForItem() instead. Scheduled for removal in V11.")]
|
||||
public PagedResult<EntityBasic> GetPagedReferences(int id, string entityType, int pageNumber = 1, int pageSize = 100)
|
||||
{
|
||||
if (pageNumber <= 0 || pageSize <= 0)
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Core.Models.Entities;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Web.BackOffice.ModelBinders;
|
||||
using Umbraco.Cms.Web.Common.Attributes;
|
||||
@@ -19,28 +14,36 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
public class TrackedReferencesController : BackOfficeNotificationsController
|
||||
{
|
||||
private readonly ITrackedReferencesService _relationService;
|
||||
private readonly IEntityService _entityService;
|
||||
|
||||
public TrackedReferencesController(ITrackedReferencesService relationService,
|
||||
IEntityService entityService)
|
||||
public TrackedReferencesController(ITrackedReferencesService relationService)
|
||||
{
|
||||
_relationService = relationService;
|
||||
_entityService = entityService;
|
||||
}
|
||||
|
||||
// Used by info tabs on content, media etc. So this is basically finding childs of relations.
|
||||
public ActionResult<PagedResult<RelationItem>> GetPagedReferences(int id, int pageNumber = 1,
|
||||
int pageSize = 100, bool filterMustBeIsDependency = false)
|
||||
/// <summary>
|
||||
/// Gets a page list of tracked references for the current item, so you can see where an item is being used.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used by info tabs on content, media etc. and for the delete and unpublish of single items.
|
||||
/// This is basically finding parents of relations.
|
||||
/// </remarks>
|
||||
public ActionResult<PagedResult<RelationItem>> GetPagedReferences(int id, int pageNumber = 1, int pageSize = 100, bool filterMustBeIsDependency = false)
|
||||
{
|
||||
if (pageNumber <= 0 || pageSize <= 0)
|
||||
{
|
||||
return BadRequest("Both pageNumber and pageSize must be greater than zero");
|
||||
}
|
||||
|
||||
return _relationService.GetPagedRelationsForItems(new []{id}, pageNumber - 1, pageSize, filterMustBeIsDependency);
|
||||
return _relationService.GetPagedRelationsForItem(id, pageNumber - 1, pageSize, filterMustBeIsDependency);
|
||||
}
|
||||
|
||||
// Used on delete, finds
|
||||
/// <summary>
|
||||
/// Gets a page list of the child nodes of the current item used in any kind of relation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used when deleting and unpublishing a single item to check if this item has any descending items that are in any kind of relation.
|
||||
/// This is basically finding the descending items which are children in relations.
|
||||
/// </remarks>
|
||||
public ActionResult<PagedResult<RelationItem>> GetPagedDescendantsInReferences(int parentId, int pageNumber = 1, int pageSize = 100, bool filterMustBeIsDependency = true)
|
||||
{
|
||||
if (pageNumber <= 0 || pageSize <= 0)
|
||||
@@ -48,12 +51,16 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
return BadRequest("Both pageNumber and pageSize must be greater than zero");
|
||||
}
|
||||
|
||||
|
||||
return _relationService.GetPagedDescendantsInReferences(parentId, pageNumber - 1, pageSize, filterMustBeIsDependency);
|
||||
|
||||
}
|
||||
|
||||
// Used by unpublish content. So this is basically finding parents of relations.
|
||||
/// <summary>
|
||||
/// Gets a page list of the items used in any kind of relation from selected integer ids.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used when bulk deleting content/media and bulk unpublishing content (delete and unpublish on List view).
|
||||
/// This is basically finding children of relations.
|
||||
/// </remarks>
|
||||
[HttpGet]
|
||||
[HttpPost]
|
||||
public ActionResult<PagedResult<RelationItem>> GetPagedReferencedItems([FromJsonPath] int[] ids, int pageNumber = 1, int pageSize = 100, bool filterMustBeIsDependency = true)
|
||||
@@ -64,8 +71,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
}
|
||||
|
||||
return _relationService.GetPagedItemsWithRelations(ids, pageNumber - 1, pageSize, filterMustBeIsDependency);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user