0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-04 02:01:58 -05:00

🐛 Fixed trailing slash and space in HTML metadata elements (#16778)

This commit is contained in:
Benjamin Rancourt 2023-05-17 02:51:32 -04:00 committed by GitHub
parent d61249a335
commit 5841f30d30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 833 additions and 833 deletions

View file

@ -19,7 +19,7 @@ const {get: getMetaData, getAssetUrl} = metaData;
function writeMetaTag(property, content, type) {
type = type || property.substring(0, 7) === 'twitter' ? 'name' : 'property';
return '<meta ' + type + '="' + property + '" content="' + content + '" />';
return '<meta ' + type + '="' + property + '" content="' + content + '">';
}
function finaliseStructuredData(meta) {
@ -126,7 +126,7 @@ function getWebmentionDiscoveryLink() {
try {
const siteUrl = urlUtils.getSiteUrl();
const webmentionUrl = new URL('webmentions/receive/', siteUrl);
return `<link href="${webmentionUrl.href}" rel="webmention" />`;
return `<link href="${webmentionUrl.href}" rel="webmention">`;
} catch (err) {
logging.warn(err);
return '';
@ -208,15 +208,15 @@ module.exports = async function ghost_head(options) { // eslint-disable-line cam
if (context) {
// head is our main array that holds our meta data
if (meta.metaDescription && meta.metaDescription.length > 0) {
head.push('<meta name="description" content="' + escapeExpression(meta.metaDescription) + '" />');
head.push('<meta name="description" content="' + escapeExpression(meta.metaDescription) + '">');
}
// no output in head if a publication icon is not set
if (settingsCache.get('icon')) {
head.push('<link rel="icon" href="' + favicon + '" type="image/' + iconType + '" />');
head.push('<link rel="icon" href="' + favicon + '" type="image/' + iconType + '">');
}
head.push('<link rel="canonical" href="' + escapeExpression(meta.canonicalUrl) + '" />');
head.push('<link rel="canonical" href="' + escapeExpression(meta.canonicalUrl) + '">');
if (_.includes(context, 'preview')) {
head.push(writeMetaTag('robots', 'noindex,nofollow', 'name'));
@ -228,17 +228,17 @@ module.exports = async function ghost_head(options) { // eslint-disable-line cam
// show amp link in post when 1. we are not on the amp page and 2. amp is enabled
if (_.includes(context, 'post') && !_.includes(context, 'amp') && settingsCache.get('amp')) {
head.push('<link rel="amphtml" href="' +
escapeExpression(meta.ampUrl) + '" />');
escapeExpression(meta.ampUrl) + '">');
}
if (meta.previousUrl) {
head.push('<link rel="prev" href="' +
escapeExpression(meta.previousUrl) + '" />');
escapeExpression(meta.previousUrl) + '">');
}
if (meta.nextUrl) {
head.push('<link rel="next" href="' +
escapeExpression(meta.nextUrl) + '" />');
escapeExpression(meta.nextUrl) + '">');
}
if (!_.includes(context, 'paged') && useStructuredData) {
@ -255,11 +255,11 @@ module.exports = async function ghost_head(options) { // eslint-disable-line cam
}
head.push('<meta name="generator" content="Ghost ' +
escapeExpression(safeVersion) + '" />');
escapeExpression(safeVersion) + '">');
head.push('<link rel="alternate" type="application/rss+xml" title="' +
escapeExpression(meta.site.title) + '" href="' +
escapeExpression(meta.rssUrl) + '" />');
escapeExpression(meta.rssUrl) + '">');
// no code injection for amp context!!!
if (!_.includes(context, 'amp')) {