fix(views): fail-safe opengraph tag HTML rendering

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson
2026-06-18 23:42:40 +02:00
parent 4007201575
commit f115b2d084
2 changed files with 4 additions and 4 deletions

View File

@@ -6,9 +6,9 @@
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<%- include('../includes/favicon') %> <%- include('../includes/favicon') %>
<% for (var og in opengraph) { %> <% for (var og in opengraph) { %>
<% if (opengraph.hasOwnProperty(og) && String(opengraph[og]).trim() !== '') { %> <% if (Object.keys(opengraph).includes(og) && typeof opengraph[og] === 'string' && opengraph[og].trim() !== '') { %>
<meta property="og:<%= og %>" content="<%= String(opengraph[og]) %>"> <meta property="og:<%= og %>" content="<%= String(opengraph[og]) %>">
<% }} if (!opengraph.hasOwnProperty('image')) { %> <% }} if (!Object.keys(opengraph).includes('image')) { %>
<meta property="og:image" content="<%- serverURL %>/icons/android-chrome-512x512.png"> <meta property="og:image" content="<%- serverURL %>/icons/android-chrome-512x512.png">
<meta property="og:image:alt" content="HedgeDoc logo"> <meta property="og:image:alt" content="HedgeDoc logo">
<meta property="og:image:type" content="image/png"> <meta property="og:image:type" content="image/png">

View File

@@ -15,9 +15,9 @@
<meta name="description" content="<%= description %>"> <meta name="description" content="<%= description %>">
<% } %> <% } %>
<% for (var og in opengraph) { %> <% for (var og in opengraph) { %>
<% if (opengraph.hasOwnProperty(og) && typeof opengraph[og] === 'string' && opengraph[og].trim() !== '') { %> <% if (Object.keys(opengraph).includes(og) && typeof opengraph[og] === 'string' && opengraph[og].trim() !== '') { %>
<meta property="og:<%= og %>" content="<%= opengraph[og] %>"> <meta property="og:<%= og %>" content="<%= opengraph[og] %>">
<% }} if (!opengraph.hasOwnProperty('image')) { %> <% }} if (!Object.keys(opengraph).includes('image')) { %>
<meta property="og:image" content="<%- serverURL %>/icons/android-chrome-512x512.png"> <meta property="og:image" content="<%- serverURL %>/icons/android-chrome-512x512.png">
<meta property="og:image:alt" content="HedgeDoc logo"> <meta property="og:image:alt" content="HedgeDoc logo">
<meta property="og:image:type" content="image/png"> <meta property="og:image:type" content="image/png">