sanitzie XML characters

This commit is contained in:
Bryan Clark
2019-12-10 09:26:51 -08:00
parent 9d56a3bd35
commit 551e2a2770
3 changed files with 41 additions and 6 deletions

14
dist/index.js generated vendored
View File

@ -4145,15 +4145,23 @@ function configAuthentication(id, username, password) {
});
}
exports.configAuthentication = configAuthentication;
function escapeXML(value) {
return value
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
}
// only exported for testing purposes
function generate(id, username, password) {
return `
<settings>
<servers>
<server>
<id>${id}</id>
<username>${username}</username>
<password>${password}</password>
<id>${escapeXML(id)}</id>
<username>${escapeXML(username)}</username>
<password>${escapeXML(password)}</password>
</server>
</servers>
</settings>