Blame view
node_modules/eslint/lib/util/xml-escape.js
935 Bytes
f7563de62
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/** * @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]/g, c => { // eslint-disable-line no-control-regex switch (c) { case "<": return "<"; case ">": return ">"; case "&": return "&"; case "\"": return """; case "'": return "'"; default: return `&#${c.charCodeAt(0)};`; } }); }; |