Make sure the culture is valid.

Resolve #14174
pull/14179/head
maliming 3 years ago
parent 15a8bbce85
commit ba902f4edb

@ -118,6 +118,12 @@ public class MultiTenancyMiddleware : IMiddleware, ITransientDependency
uiCulture = defaultLanguage;
}
return new RequestCulture(culture, uiCulture);
if (CultureHelper.IsValidCultureCode(culture) &&
CultureHelper.IsValidCultureCode(uiCulture))
{
return new RequestCulture(culture, uiCulture);
}
return null;
}
}

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.AspNetCore.RequestLocalization;
using Volo.Abp.Auditing;
@ -30,6 +31,11 @@ public class AbpLanguagesController : AbpController
throw new AbpException("The selected culture is not valid! Make sure you enter a valid culture code.");
}
if (!CultureHelper.IsValidCultureCode(uiCulture))
{
throw new AbpException("The selected uiCulture is not valid! Make sure you enter a valid culture code.");
}
AbpRequestCultureCookieHelper.SetCultureCookie(
HttpContext,
new RequestCulture(culture, uiCulture)

@ -47,7 +47,7 @@ public static class CultureHelper
try
{
CultureInfo.GetCultureInfo(cultureCode);
_ = CultureInfo.GetCultureInfo(cultureCode);
return true;
}
catch (CultureNotFoundException)

Loading…
Cancel
Save