Ugliness to support escaped backslashes in windows
971095
function matches(url, command) {
		var cap;
		if (cap = commandReg.exec(url)) return cap[1] === command;
	}
284088
def check_backslashes(self, definition, docstring):
        

        '''
        # Just check that docstring is raw, check_triple_double_quotes
        # ensures the correct quotes.
        if docstring and '\\' in docstring and not docstring.startswith(
                ('r', 'ur')):
            return violations.D301()
557401
def escape(url):
    '''
    
    '''
    if salt.utils.platform.is_windows():
        return url

    scheme = urlparse(url).scheme
    if not scheme:
        if url.startswith('|'):
            return url
        else:
            return '|{0}'.format(url)
    elif scheme == 'salt':
        path, saltenv = parse(url)
        if path.startswith('|'):
            return create(path, saltenv)
        else:
            return create('|{0}'.format(path), saltenv)
    else:
        return url
1160534
@Override
    protected String escapeCharacter(char ch, char previousChar) {
      if(ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r') {
          return "";
      }
      switch(ch) {
          case '&': return ESCAPED_AMP;
          case '<': return ESCAPED_LT;
          case '>': return ESCAPED_GT;
          case '"': return ESCAPED_QUOTE;
          case '\'': return  ESCAPED_APOS;
          case '\\': return  ESCAPED_BACKSLASH;
          case '@': return ESCAPED_AT;
          case '`': return ESCAPED_BACKTICK;
          case NBSP: return ESCAPED_NON_BREAKING_SPACE;
          case LINE_SEPARATOR: return ESCAPED_LINE_SEPARATOR;
          case PARAGRAPH_SEPARATOR: return ESCAPED_PARAGRAPH_SEPARATOR;
      }
      return null;
    }
956083
function escapeCharacters(params) {
    return params;
    var find = new Array('.','-','%','/','\\\\',':','*','\\','<','>','|','?',' ','&','#');
    var replace = new Array('.0','.1','.2','.3','.4','.5','.6','.7','.8','.9','.a','.b','.c','.d','.e'); 
    var escaped = {};
    for (var param in params) {
        if(typeof(params[param]) == 'string') {
            escaped[param] = replaceCharacter(find, replace, params[param]);
        }
        else {
            escaped[param] = params[param];
        }
    }
    return escaped;
}
823222
def sanitize_win_path(winpath):
    '''
    
    '''
    intab = '<>:|?*'
    if isinstance(winpath, six.text_type):
        winpath = winpath.translate(dict((ord(c), '_') for c in intab))
    elif isinstance(winpath, six.string_types):
        outtab = '_' * len(intab)
        trantab = ''.maketrans(intab, outtab) if six.PY3 else string.maketrans(intab, outtab)  # pylint: disable=no-member
        winpath = winpath.translate(trantab)
    return winpath
1163450
def _escape_string(text, _map={}):
    
    if isinstance(text, str):
        text = text.encode('ascii')
    assert isinstance(text, (bytes, bytearray))

    if not _map:
        for ch in range(256):
            if ch in _VALID_CHARS:
                _map[ch] = chr(ch)
            else:
                _map[ch] = '\\%02x' % ch
            if six.PY2:
                _map[chr(ch)] = _map[ch]

    buf = [_map[ch] for ch in text]
    return ''.join(buf)
886891
def back_slash_to_front_converter(string):
    
    try:
        if not string or not isinstance(string, str):
            return string
        return string.replace('\\', '/')
    except Exception:
        return string
1247661
function escapeFormat(t) {
  return (
    t
      // Inline single underscore.
      .replace(/([^_])_([^_])/g, '$1 $2')
      // Leading or trailing underscore.
      .replace(/([^_])_$/, '$1 ')
      .replace(/^_([^_])/, ' $1')
      // Double underscore and double dash.
      .replace(/__/g, '_')
      .replace(/--/g, '-')
  )
}
1078707
def shellsafe(s, quote='', doescape=True):
    """"""
    if sys.version[0] == '2' and not isinstance(s,unicode): #pylint: disable=undefined-variable
        s = unicode(s,'utf-8') #pylint: disable=undefined-variable
    if len(s) > 1024:
        raise ValueError("Variable value rejected for security reasons: too long")
    if quote:
        if quote in s:
            if doescape:
                s = escape(s,quote)
            else:
                raise ValueError("Variable value rejected for security reasons: " + s)
        return quote + s + quote
    else:
        for c in s:
            if c in DISALLOWINSHELLSAFE:
                raise ValueError("Variable value rejected for security reasons: " + s)
        return s
665909
def _escape_char(c):
    ""
    if isinstance(c, int):
        c = _unichr(c)
    return c if c in LEGAL_CHARS else ESCAPE_FMT % ord(c)
809876
function escapeShellArg(value) {
    if (is.number(value)) {
        return value;
    }

    value = String(value);
    value = value.replace(/"/g, '\\"');

    return '"' + value + '"';
}
3889
public static String escapeAppVersion(String s) {
        s = cleanWS(s);
        s = replaceAll(s, BackSlashPtn, EscBackSlash);
        s = replaceAll(s, LParenPtn, EscLParen);
        return s;
    }
315802
function escapeString(str) {

    if(str === undefined) {
        throw new Error('\'str\' is required');
    }

    if(str === null) {
        throw new Error('\'str\' must not be null');
    }

    if(typeof str !== 'string') {
        throw new Error('\'str\' must be a string');
    }

    /*
     * Need to escape backslashes (\) first because escaping ' and " will also 
     * add a \, which interferes with \ escaping.
     */
    var escaped_str = str;
    // regex replace all \ to \\
    escaped_str = escaped_str.replace(/\\/g, '\\\\');
    // regex replace all ' to \'
    escaped_str = escaped_str.replace(/'/g, '\\\'');
    // regex replace all " to \"
    escaped_str = escaped_str.replace(/"/g, '\\"');

    return escaped_str;

}
961856
private static String escapeString(String s, char quote,
                          String doublequoteEscape,
                          String singlequoteEscape,
                          String backslashEscape) {
    StringBuilder sb = new StringBuilder(s.length() + 2);
    sb.append(quote);
    for (int i = 0; i < s.length(); i++) {
      char c = s.charAt(i);
      switch (c) {
        case '\n': sb.append("\\n"); break;
        case '\r': sb.append("\\r"); break;
        case '\t': sb.append("\\t"); break;
        case '\\': sb.append(backslashEscape); break;
        case '\"': sb.append(doublequoteEscape); break;
        case '\'': sb.append(singlequoteEscape); break;
        case '>':
          // Unicode-escape the '>' in '-->' and ']]>'
          if (i >= 2
              && ((s.charAt(i - 1) == '-' && s.charAt(i - 2) == '-')
                  || (s.charAt(i - 1) == ']' && s.charAt(i - 2) == ']'))) {
            sb.append("\\u003e");
          } else {
            sb.append(c);
          }
          break;
        case '<':
          // Unicode-escape the '<' in '</script' and '<!--'
          final String END_SCRIPT = "/script";
          final String START_COMMENT = "!--";

          if (s.regionMatches(true, i + 1, END_SCRIPT, 0,
                              END_SCRIPT.length())) {
            sb.append("\\u003c");
          } else if (s.regionMatches(false, i + 1, START_COMMENT, 0,
                                     START_COMMENT.length())) {
            sb.append("\\u003c");
          } else {
            sb.append(c);
          }
          break;
        default:
          // No charsetEncoder provided - pass straight Latin characters
          // through, and escape the rest.  Doing the explicit character
          // check is measurably faster than using the CharsetEncoder.
          if (c > 0x1f && c <= 0x7f) {
            sb.append(c);
          } else {
            // Other characters can be misinterpreted by some JS parsers,
            // or perhaps mangled by proxies along the way,
            // so we play it safe and Unicode escape them.
            appendHexJavaScriptRepresentation(sb, c);
          }
      }
    }
    sb.append(quote);
    return sb.toString();
  }
916754
public static String escapeWithBackslash(String value, String metachars) {
        StringBuffer sb = new StringBuffer();
        int i, n = value.length();
        char ch;
        for (i=0; i<n; i++) {
            ch = value.charAt(i);
            if (ch=='\\' || metachars.indexOf(ch)>=0) {
                sb.append('\\');
            }
            sb.append(ch);
        }
        return sb.toString();
    }
935457
def shell_escape(s):
    
    """
    if isinstance(s, PosixPath):
        s = unicode_(s)
    elif isinstance(s, bytes):
        s = s.decode('utf-8')
    if not s or any(c not in safe_shell_chars for c in s):
        return '"%s"' % (s.replace('\\', '\\\\')
                          .replace('"', '\\"')
                          .replace('`', '\\`')
                          .replace('$', '\\$'))
    else:
        return s