Merge pull request #3137 from sbwalker/dev

fix #3134 improve parsing of headcontent to handle space delimiters
This commit is contained in:
Shaun Walker 2023-08-11 15:53:43 -04:00 committed by GitHub
commit 0aeb1a62b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -96,7 +96,7 @@
{
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetPackage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
}
@if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl))
@if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl) && string.IsNullOrEmpty(context.PackageUrl))
{
<a class="btn btn-success ms-2" style="text-decoration: none !important" href="@context.PaymentUrl" target="_new">@SharedLocalizer["Buy"]</a>
}

View File

@ -98,7 +98,7 @@
{
<button type="button" class="btn btn-primary" @onclick=@(async () => await GetPackage(context.PackageId, context.Version))>@SharedLocalizer["Download"]</button>
}
@if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl))
@if (context.Price != null && !string.IsNullOrEmpty(context.PaymentUrl) && string.IsNullOrEmpty(context.PackageUrl))
{
<a class="btn btn-success ms-2" style="text-decoration: none !important" href="@context.PaymentUrl" target="_new">@SharedLocalizer["Buy"]</a>
}

View File

@ -67,16 +67,19 @@
if (!string.IsNullOrEmpty(content))
{
// format head content, remove scripts, and filter duplicate elements
var elements = (">" + content.Replace("\n", "") + "<").Split("><");
foreach (var element in elements)
content = content.Replace("\n", "");
var index = content.IndexOf("<");
while (index >= 0)
{
if (!string.IsNullOrEmpty(element) && !element.ToLower().StartsWith("script"))
var element = content.Substring(index, content.IndexOf(">", index) - index + 1);
if (!string.IsNullOrEmpty(element) && !element.ToLower().StartsWith("<script"))
{
if (!headcontent.Contains("<" + element + ">"))
if (!headcontent.Contains(element))
{
headcontent += "<" + element + ">" + "\n";
headcontent += element + "\n";
}
}
index = content.IndexOf("<", index + 1);
}
}
return headcontent;