Skip to content

Node.js based forum software built for the modern web

Fixes #3852

Julian Lam34725ec3e5df
diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js
index 7ecca84789..29e353b084 100644
--- a/src/controllers/accounts/profile.js
+++ b/src/controllers/accounts/profile.js
@@ -2,6 +2,7 @@
var nconf = require('nconf'),
async = require('async'),
+ S = require('string'),
user = require('../../user'),
posts = require('../../posts'),
@@ -80,6 +81,42 @@ profileController.get = function(req, res, callback) {
userData.profileviews = 1;
}
+ var plainAboutMe = S(userData.aboutme).decodeHTMLEntities().stripTags().s;
+
+ res.locals.metaTags = [
+ {
+ name: "title",
+ content: userData.fullname || userData.username
+ },
+ {
+ name: "description",
+ content: plainAboutMe
+ },
+ {
+ property: 'og:title',
+ content: userData.fullname || userData.username
+ },
+ {
+ property: 'og:description',
+ content: plainAboutMe
+ }
+ ];
+
+ if (userData.picture) {
+ res.locals.metaTags.push(
+ {
+ property: 'og:image',
+ content: userData.picture,
+ noEscape: true
+ },
+ {
+ property: "og:image:url",
+ content: userData.picture,
+ noEscape: true
+ }
+ );
+ }
+
plugins.fireHook('filter:user.account', {userData: userData, uid: req.uid}, next);
}
], function(err, results) {
diff --git a/src/controllers/topics.js b/src/controllers/topics.js
index f5fb015c15..aa3da51053 100644
--- a/src/controllers/topics.js
+++ b/src/controllers/topics.js
@@ -203,15 +203,18 @@ topicsController.get = function(req, res, callback) {
},
{
property: "og:url",
- content: nconf.get('url') + '/topic/' + topicData.slug + (req.params.post_index ? ('/' + req.params.post_index) : '')
+ content: nconf.get('url') + '/topic/' + topicData.slug + (req.params.post_index ? ('/' + req.params.post_index) : ''),
+ noEscape: true
},
{
property: 'og:image',
- content: ogImageUrl
+ content: ogImageUrl,
+ noEscape: true
},
{
property: "og:image:url",
- content: ogImageUrl
+ content: ogImageUrl,
+ noEscape: true
},
{
property: "article:published_time",
diff --git a/src/meta/tags.js b/src/meta/tags.js
index d571038cc4..55e5bd32d2 100644
--- a/src/meta/tags.js
+++ b/src/meta/tags.js
@@ -32,10 +32,12 @@ module.exports = function(Meta) {
content: Meta.config.keywords || ''
}, {
name: 'msapplication-badge',
- content: 'frequency=30; polling-uri=' + nconf.get('url') + '/sitemap.xml'
+ content: 'frequency=30; polling-uri=' + nconf.get('url') + '/sitemap.xml',
+ noEscape: true
}, {
name: 'msapplication-square150x150logo',
- content: Meta.config['brand:logo'] || ''
+ content: Meta.config['brand:logo'] || '',
+ noEscape: true
}];
plugins.fireHook('filter:meta.getMetaTags', defaultTags, next);
},
@@ -89,7 +91,10 @@ module.exports = function(Meta) {
return tag;
}
- tag.content = validator.escape(tag.content);
+ if (!tag.noEscape) {
+ tag.content = validator.escape(tag.content);
+ }
+
return tag;
});