Urara-Blog/node_modules/.pnpm-store/v3/files/cf/b592c164c4626b4851ad1434eb5ae190a3189e6eb6fcb21f1e571077c76b7fd13c2fadc40eaa8016651924bd7ce10a9128a3c97862aba6ff6c3e8a6d6031a9
2022-08-14 01:14:53 +08:00

34 lines
971 B
Text

/**
* @fileoverview XML character escaper
* @author George Chung
*/
"use strict";
//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------
/**
* Returns the escaped value for a character
* @param {string} s string to examine
* @returns {string} severity level
* @private
*/
module.exports = function(s) {
return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/gu, c => { // eslint-disable-line no-control-regex -- Converting controls to entities
switch (c) {
case "<":
return "&lt;";
case ">":
return "&gt;";
case "&":
return "&amp;";
case "\"":
return "&quot;";
case "'":
return "&apos;";
default:
return `&#${c.charCodeAt(0)};`;
}
});
};