Skip to content

Node.js based forum software built for the modern web

refactor: 2 more href checks

Barış Soner Uşaklı1d922dbb4cf8
diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.js
index cf2fd32873..acbe40a661 100644
--- a/src/controllers/accounts/helpers.js
+++ b/src/controllers/accounts/helpers.js
@@ -150,6 +150,9 @@ helpers.getCustomUserFields = async function (callerUID, userData) {
require_valid_protocol: true,
require_tld: true,
});
+ if (isUrl && !utils.isSafeHref(value)) {
+ value = '';
+ }
memo.push({
key: slugify(name),
name,
@@ -194,6 +197,7 @@ helpers.getCustomUserFields = async function (callerUID, userData) {
userValue = JSON.parse(userValue || '[]');
}
if (f.type === 'input-link' && userValue) {
+ userValue = utils.isSafeHref(userValue) ? userValue : '';
f.linkValue = String(userValue.replace('http://', '').replace('https://', ''));
}
f['select-options'] = (f['select-options'] || '').split('\n').filter(Boolean);