mirror of
https://github.com/renbaoshuo/UOJ-Luogu-RemoteJudge.git
synced 2024-12-28 10:52:00 +00:00
12 lines
211 B
JavaScript
12 lines
211 B
JavaScript
|
export default function htmlspecialchars(text) {
|
||
|
const map = {
|
||
|
'&': '&',
|
||
|
'<': '<',
|
||
|
'>': '>',
|
||
|
'"': '"',
|
||
|
"'": ''',
|
||
|
};
|
||
|
|
||
|
return text.replace(/[&<>"']/g, m => map[m]);
|
||
|
}
|