mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-30 18:46:01 +01:00 
			
		
		
		
	fix: strip html from remote custom fields, linkify if url detected in now-plaintext field value
This commit is contained in:
		| @@ -72,7 +72,11 @@ Mocks.profile = async (actors, hostMap) => { | |||||||
| 		const customFields = actor.attachment && Array.isArray(actor.attachment) && actor.attachment.length ? | 		const customFields = actor.attachment && Array.isArray(actor.attachment) && actor.attachment.length ? | ||||||
| 			actor.attachment | 			actor.attachment | ||||||
| 				.filter(attachment => attachment.type === 'PropertyValue') | 				.filter(attachment => attachment.type === 'PropertyValue') | ||||||
| 				.reduce((map, { name, value }) => map.set(name, value), new Map()) : | 				.reduce((map, { name, value }) => { | ||||||
|  | 					// Strip html from received values (for security) | ||||||
|  | 					value = utils.stripHTMLTags(value); | ||||||
|  | 					return map.set(name, value); | ||||||
|  | 				}, new Map()) : | ||||||
| 			undefined; | 			undefined; | ||||||
|  |  | ||||||
| 		const payload = { | 		const payload = { | ||||||
|   | |||||||
| @@ -151,11 +151,12 @@ helpers.getCustomUserFields = async function (userData) { | |||||||
| 		const fields = Array | 		const fields = Array | ||||||
| 			.from(new URLSearchParams(customFields)) | 			.from(new URLSearchParams(customFields)) | ||||||
| 			.reduce((memo, [name, value]) => { | 			.reduce((memo, [name, value]) => { | ||||||
|  | 				const isUrl = validator.isURL(value); | ||||||
| 				memo.push({ | 				memo.push({ | ||||||
| 					key: slugify(name), | 					key: slugify(name), | ||||||
| 					name, | 					name, | ||||||
| 					value, | 					value, | ||||||
| 					type: 'input-text', | 					type: isUrl ? 'input-link' : 'input-text', | ||||||
| 					'min-rep': '', | 					'min-rep': '', | ||||||
| 					icon: 'fa-solid fa-circle-info', | 					icon: 'fa-solid fa-circle-info', | ||||||
| 				}); | 				}); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user