Fixed issue with Paths-integers being converted using local culture. (#11180)

* Fixed issue with Paths-integers being converted using local culture.

* Align with the old implementation

* Use int.TryParse insteaad of TryConvertTo when we do not want culture specific parsing

* More fixes for cultures and fixed wrong test. Users should be part of all groups to have access

* Fix casing for requested file

* Force tests to not use NLS

* try force tests to not use NLS

* try force tests to not use NLS

* Force tests on windows to run ICU

* More fixes for invariant int parsing

* Change key on actions/emptyRecycleBin, so the casing aligns with the view file, that is named emptyrecyclebin.html

* Fixed casing issue

* use Attempt to align with other code
This commit is contained in:
Bjarke Berg
2021-09-24 17:42:31 +02:00
committed by GitHub
parent 936757297e
commit 452097d975
49 changed files with 174 additions and 262 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Examine;
using Umbraco.Cms.Core.Scoping;
@@ -30,7 +31,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
{
// we cannot return FAILED here because we need the value set to get into the indexer and then deal with it from there
// because we need to remove anything that doesn't pass by parent Id in the cases that umbraco data is moved to an illegal parent.
if (!path.Contains(string.Concat(",", ParentId.Value, ",")))
if (!path.Contains(string.Concat(",", ParentId.Value.ToString(CultureInfo.InvariantCulture), ",")))
return false;
}
@@ -39,7 +40,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
public bool ValidateRecycleBin(string path, string category)
{
var recycleBinId = category == IndexTypes.Content ? Constants.System.RecycleBinContent : Constants.System.RecycleBinMedia;
var recycleBinId = category == IndexTypes.Content ? Constants.System.RecycleBinContentString : Constants.System.RecycleBinMediaString;
//check for recycle bin
if (PublishedValuesOnly)

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Examine;
using Umbraco.Cms.Core.Mapping;
@@ -162,17 +163,16 @@ namespace Umbraco.Cms.Infrastructure.Search
}
);
var intId = entity.Id.TryConvertTo<int>();
if (intId.Success)
if (int.TryParse(entity.Id.ToString(),NumberStyles.Integer, CultureInfo.InvariantCulture, out var intId))
{
//if it varies by culture, return the default language URL
if (result.Values.TryGetValue(UmbracoExamineFieldNames.VariesByCultureFieldName, out var varies) && varies == "y")
{
entity.AdditionalData["Url"] = _publishedUrlProvider.GetUrl(intId.Result, culture: culture ?? defaultLang);
entity.AdditionalData["Url"] = _publishedUrlProvider.GetUrl(intId, culture: culture ?? defaultLang);
}
else
{
entity.AdditionalData["Url"] = _publishedUrlProvider.GetUrl(intId.Result);
entity.AdditionalData["Url"] = _publishedUrlProvider.GetUrl(intId);
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Events;
@@ -946,11 +947,7 @@ namespace Umbraco.Cms.Core.Services.Implement
public IEnumerable<EntityContainer> GetContainers(TItem item)
{
var ancestorIds = item.Path.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries)
.Select(x =>
{
var asInt = x.TryConvertTo<int>();
return asInt ? asInt.Result : int.MinValue;
})
.Select(x => int.TryParse(x, NumberStyles.Integer, CultureInfo.InvariantCulture, out var asInt) ? asInt : int.MinValue)
.Where(x => x != int.MinValue && x != item.Id)
.ToArray();

View File

@@ -568,11 +568,11 @@ namespace Umbraco.Cms.Core.Services.Implement
private XElement SerializeContentBase(IContentBase contentBase, string urlValue, string nodeName, bool published)
{
var xml = new XElement(nodeName,
new XAttribute("id", contentBase.Id),
new XAttribute("id", contentBase.Id.ToInvariantString()),
new XAttribute("key", contentBase.Key),
new XAttribute("parentID", contentBase.Level > 1 ? contentBase.ParentId : -1),
new XAttribute("parentID", (contentBase.Level > 1 ? contentBase.ParentId : -1).ToInvariantString()),
new XAttribute("level", contentBase.Level),
new XAttribute("creatorID", contentBase.CreatorId),
new XAttribute("creatorID", contentBase.CreatorId.ToInvariantString()),
new XAttribute("sortOrder", contentBase.SortOrder),
new XAttribute("createDate", contentBase.CreateDate.ToString("s")),
new XAttribute("updateDate", contentBase.UpdateDate.ToString("s")),