Keep line breaks in values, handle scalar and string-array JSON

- esc() helper escapes free-text values and converts newlines to <br>;
  used for commit messages, SMS text, annotations, and all JSON values
- JSON parser accepts scalar bodies (string, number, bool, null) and
  renders them as a one-row table instead of falling back to the
  default template
- Arrays of plain values render as one table under their path
  breadcrumb, so nested string lists are no longer anonymous
- GitHub commits render as cards with a sha pill linked to the commit
This commit is contained in:
Andy Dixon
2026-09-12 18:55:21 +01:00
parent b3da9fbb25
commit 64c51d4f2b
5 changed files with 50 additions and 22 deletions
+5 -5
View File
@@ -95,7 +95,7 @@ HTML;
$labelsContent .= '<div class="subsection-title">Group Labels</div><table class="metadata" role="presentation" cellspacing="0" cellpadding="0" width="100%">';
foreach ($groupLabels as $key => $value) {
$keySafe = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
$valueSafe = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$valueSafe = esc($value);
$labelsContent .= <<<HTML
<tr>
<td class="metadata-label">$keySafe</td>
@@ -110,7 +110,7 @@ HTML;
$labelsContent .= '<div class="subsection-title">Common Labels</div><table class="metadata" role="presentation" cellspacing="0" cellpadding="0" width="100%">';
foreach ($commonLabels as $key => $value) {
$keySafe = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
$valueSafe = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$valueSafe = esc($value);
$labelsContent .= <<<HTML
<tr>
<td class="metadata-label">$keySafe</td>
@@ -130,7 +130,7 @@ HTML;
$annotationsContent .= '<div class="section"><div class="section-title">Common Annotations</div><table class="metadata" role="presentation" cellspacing="0" cellpadding="0" width="100%">';
foreach ($commonAnnotations as $key => $value) {
$keySafe = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
$valueSafe = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$valueSafe = esc($value);
$annotationsContent .= <<<HTML
<tr>
<td class="metadata-label">$keySafe</td>
@@ -180,7 +180,7 @@ HTML;
$alertsContent .= '</table><div class="subsection-title">Labels</div><table class="metadata" role="presentation" cellspacing="0" cellpadding="0" width="100%">';
foreach ($alertLabels as $key => $value) {
$keySafe = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
$valueSafe = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$valueSafe = esc($value);
$alertsContent .= <<<HTML
<tr>
<td class="metadata-label">$keySafe</td>
@@ -196,7 +196,7 @@ HTML;
$alertsContent .= '</table><div class="subsection-title">Annotations</div><table class="metadata" role="presentation" cellspacing="0" cellpadding="0" width="100%">';
foreach ($alertAnnotations as $key => $value) {
$keySafe = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
$valueSafe = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$valueSafe = esc($value);
$alertsContent .= <<<HTML
<tr>
<td class="metadata-label">$keySafe</td>