Sanitize _aliasname by removing protocols

This commit is contained in:
Cody 2024-01-15 09:56:11 -08:00 committed by GitHub
parent 7744099ee5
commit 3a5dc62908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -818,24 +818,21 @@
{
if (!string.IsNullOrEmpty(_aliasname))
{
// Remove 'http://' and 'https://' from the alias name
string cleanedAliasName = _aliasname.Replace("http://", "").Replace("https://", "");
_aliasname = _aliasname.Replace("http://", "").Replace("https://", "");
var aliases = await AliasService.GetAliasesAsync();
// Check if the cleaned alias name exists in the database
var alias = aliases.Where(item => item.Name == cleanedAliasName).FirstOrDefault();
var alias = aliases.Where(item => item.Name == _aliasname).FirstOrDefault();
bool unique = (alias == null || alias.AliasId == _aliasid);
if (unique)
{
if (_aliasid == 0)
{
alias = new Alias { SiteId = PageState.Site.SiteId, TenantId = PageState.Site.TenantId, Name = cleanedAliasName, IsDefault = bool.Parse(_defaultalias) };
alias = new Alias { SiteId = PageState.Site.SiteId, TenantId = PageState.Site.TenantId, Name = _aliasname, IsDefault = bool.Parse(_defaultalias) };
await AliasService.AddAliasAsync(alias);
}
else
{
alias = _aliases.Single(item => item.AliasId == _aliasid);
alias.Name = cleanedAliasName;
alias.Name = _aliasname;
alias.IsDefault = bool.Parse(_defaultalias);
await AliasService.UpdateAliasAsync(alias);
}