btcpayserver/BTCPayServer/Views/Invoice/PosData.cshtml
Wouter Samaey f1a222fbb3
New unit test to scan for external links/forms and if they have rel="noreferrer noopener" (#2668)
* Unit test to check for (possibly) external links

* Add rel="noreferrer noopener" to all external links so unit test passes

* Update BTCPayServer.Tests/UnitTest1.cs

Co-authored-by: Andrew Camilleri <evilkukka@gmail.com>

* Update BTCPayServer.Tests/UnitTest1.cs

Co-authored-by: Andrew Camilleri <evilkukka@gmail.com>

* Fixed bad merge from master

* PascalCasing

Co-authored-by: Andrew Camilleri <evilkukka@gmail.com>
2021-07-06 10:35:42 +02:00

52 lines
1.5 KiB
Text

@model (Dictionary<string, object> Items, int Level)
@functions{
void DisplayValue(object value)
{
if (value is string str && str.StartsWith("http"))
{
<a href="@str" target="_blank" rel="noreferrer noopener">@str</a>
}
else
{
@value
}
}
}
<table class="table table-sm table-responsive-md removetopborder">
@foreach (var (key, value) in Model.Items)
{
<tr>
@if (value is string)
{
if (!string.IsNullOrEmpty(key))
{
<th class="w-150px">@key</th>
}
<td>
@{ DisplayValue(value); }
</td>
}
else if (value is Dictionary<string, object>subItems)
{
@* This is the array case *@
if (subItems.Count == 1 && subItems.First().Value is string)
{
<th class="w-150px">@key</th>
<td>
@{ DisplayValue(subItems.First().Value); }
</td>
}
else
{
<td colspan="2">
@Html.Raw($"<h{Model.Level + 3} class='mt-3'>{key}</h{Model.Level + 3}>")
<partial name="PosData" model="(subItems, Model.Level + 1)"/>
</td>
}
}
</tr>
}
</table>