Redact password in urls.
171578
def sanitize_url(url):
    """"""
    parts = urlparse(url)
    if parts.password is None:
        return url
    host_info = parts.netloc.rsplit('@', 1)[-1]
    parts = parts._replace(netloc='{}:{}@{}'.format(
        parts.username, REDACTED, host_info))
    return parts.geturl()
1163561
def _padd_password(self):
        """"""
        password = self.session._auth_password
        if isinstance(password, str):
            password = str.encode(password)
        return password.ljust(16, b'\x00')
280256
private String stripPassword(String str)
   {
      if (str.indexOf("<password>") == -1)
         return str;

      Pattern pattern = Pattern.compile("<password>[^<]*</password>");
      String[] strs = pattern.split(str);

      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < strs.length; i++)
      {
         String s = strs[i];
         sb.append(s);
         if (i < strs.length - 1)
            sb.append("<password>****</password>");
      }

      return sb.toString();
   }
971044
def make_regex(self, url):
        '''
            
        '''
        return r"^%s/%s%s$" % (self.object_getter.regex, self.app_name, url)
1034938
function (url) {
            var tmp = url.replace(/\burl\s*/gi, "");    // removing url word
            tmp = tmp.charAt(0) === "(" ? tmp.substring(1, tmp.length - 1) : tmp; // removing brackets
            tmp = tmp.charAt(0) === "\'" || tmp.charAt(0) === "\"" ? tmp.substring(1, tmp.length - 1) : tmp; // removing quotes
            return tmp;
        }
527357
def get_auth_from_url(url):
    
    parsed = urlparse(url)

    try:
        auth = (unquote(parsed.username), unquote(parsed.password))
    except (AttributeError, TypeError):
        auth = ('', '')

    return auth
888796
def CheckPasswordReuse(skipUserInput):
  
  goodlogging.Log.Info("EXTRACT", "RAR files needs password to extract")
  if skipUserInput is False:
    prompt = "Enter 't' to reuse the last password for just this file, " \
             "'a' to reuse for all subsequent files, " \
             "'n' to enter a new password for this file " \
             "or 's' to enter a new password for all files: "
    response = goodlogging.Log.Input("EXTRACT", prompt)
    response = util.ValidUserResponse(response, ('t','a','n','s'))
  else:
    response = 'a'

  if response.lower() == 's':
    return -1
  if response.lower() == 'n':
    return 0
  elif response.lower() == 't':
    return 1
  elif response.lower() == 'a':
    return 2
50908
protected final List<RedisURI> parseURLs(String[] urls, String password, boolean secure) {
		ArrayList<RedisURI> list = new ArrayList<>(urls.length);
		for (String url : urls) {
			url = url.trim();
			if ((password == null || password.isEmpty()) && !secure) {

				// URL contains all of the connection parameters
				try {
					list.add(RedisURI.create(url));
					continue;
				} catch (Exception ignored) {

					// Ignore, use old parsing below.
				}
			}

			// Simple "host" or "host:port" or "redis://host:port" syntax
			if (url.startsWith("redis://")) {
				url = url.substring(8);
			}
			if (url.endsWith("/")) {
				url = url.substring(0, url.length() - 1);
			}
			int i = url.indexOf(':');
			String host = "localhost";
			int port = 6379;
			if (i > -1) {
				host = url.substring(0, i);
				port = Integer.parseInt(url.substring(i + 1));
			} else {
				host = url;
			}
			RedisURI.Builder builder = RedisURI.builder().withHost(host).withPort(port).withSsl(secure);
			if (password != null && !password.isEmpty()) {
				builder.withPassword(password);
			}
			list.add(builder.build());
		}
		return list;
	}
1200958
def redact(digest=:sha1)
      raise "Unknown Digest type: #{digest}" unless %i(sha1 md5).include?(digest)
      return self.to_s if self.local.redacted?
      r = %Q({#{send(digest)}})
      r += "@" + self.host.to_s if self.host.to_s && self.host.to_s > " "
      r
    end
193736
def redirect_uris(self, value):
        """"""
        if isinstance(value, six.text_type):
            value = value.split("\n")

        value = [v.strip() for v in value]

        for v in value:
            validate_redirect_uri(v)

        self._redirect_uris = "\n".join(value) or ""
1014892
def extract_urls(url, data, unescape=HTMLParser.HTMLParser().unescape):
    """"""
    parts = urlparse.urlparse(url)
    prefix = '%s://%s' % (parts.scheme, parts.netloc)

    accessed_dir = os.path.dirname(parts.path)
    if not accessed_dir.endswith('/'):
        accessed_dir += '/'

    for pattern, replacement in REPLACEMENT_REGEXES:
        fixed = replacement % {
            'base': prefix,
            'accessed_dir': accessed_dir,
        }
        data = re.sub(pattern, fixed, data)

    result = set()
    for match in re.finditer(MAYBE_HTML_URL_REGEX, data):
        found_url = unescape(match.groupdict()['absurl'])
        found_url = clean_url(
            found_url,
            force_scheme=parts[0])  # Use the main page's scheme
        result.add(found_url)

    return result
953747
def get_url_with_auth(self, url) -> str:
        """"""
        if not self._username:
            return url

        url += '&user={:s}'.format(self._username)

        if not self._password:
            return url

        return url + '&pass={:s}'.format(self._password)
636707
def extract_credentials(self, url):
        
        if isinstance(url, urllib2.Request):
            result = urlparse.urlsplit(url.get_full_url())
        else:
            result = urlparse.urlsplit(url)
        scheme, netloc, path, query, frag = result

        username, password = self.parse_credentials(netloc)
        if username is None:
            return url, None, None
        elif password is None and self.prompting:
            # remove the auth credentials from the url part
            netloc = netloc.replace('%s@' % username, '', 1)
            # prompt for the password
            prompt = 'Password for %s@%s: ' % (username, netloc)
            password = urllib.quote(getpass.getpass(prompt))
        else:
            # remove the auth credentials from the url part
            netloc = netloc.replace('%s:%s@' % (username, password), '', 1)

        target_url = urlparse.urlunsplit((scheme, netloc, path, query, frag))
        return target_url, username, password
1015293
function maskPassword(connectionString) {
    return connectionString.replace(/:(?![/])([^@]+)/, (_, m) => {
        return ':' + new Array(m.length + 1).join('#');
    });
}
172439
public static function removeJavaScriptHardRedirects($string)
    {
        $bad = array(
            'document.cookie' => '',
            'document.write'  => '',
            'window.location' => '',
            "javascript\s*:"  => '',
            "Redirect\s+302"  => '',
            '<!--'            => '&lt;!--',
            '-->'             => '--&gt;'
        );
        foreach ($bad as $key => $val) {
            $string = preg_replace("#" . $key . "#i", $val, $string);
        }

        return $string;
    }
723487
def stripped_db_url(url):
    """"""
    parsed = urlparse(url)

    if parsed.password is None:
        return url

    return parsed._replace(
        netloc="{}:***@{}".format(parsed.username, parsed.hostname)
    ).geturl()
1272411
def make_http_credentials(username=None, password=None):
    """"""
    credentials = ''
    if username is None:
        return credentials
    if username is not None:
        if ':' in username:
            return credentials
        credentials += username
    if credentials and password is not None:
        credentials += ":%s" % password
    return "%s@" % credentials