escapeShellCmd.js 383 B

123456789101112131415161718192021
  1. 'use strict';
  2. const BASIC_ALPHABETS = new Set('#&;`|*?~<>^()[]{}$;\'",\x0A\xFF'.split(''));
  3. function escapeShellCmd(string) {
  4. const str = '' + string;
  5. let res = '';
  6. let ascii;
  7. for (let index = 0; index < str.length; index++) {
  8. ascii = str[index];
  9. if (!BASIC_ALPHABETS.has(ascii)) {
  10. res += ascii;
  11. }
  12. }
  13. return res;
  14. }
  15. module.exports = escapeShellCmd;