summaryrefslogtreecommitdiff
path: root/packages/backend/src/misc/escape-html.ts
blob: 819aeeed525f17d34dd70617dec54000ff433bde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

export function escapeHtml(text: string): string {
	return text
		.replace(/&/g, '&')
		.replace(/</g, '&lt;')
		.replace(/>/g, '&gt;')
		.replace(/"/g, '&quot;')
		.replace(/'/g, '&#039;');
}