def is_valid_repository(self): """Checks if this is a valid Git repository.""" url_parts = urlsplit(self.path) if (url_parts.scheme.lower() in ('http', 'https') and url_parts.username is None and self.username): # Git URLs, especially HTTP(s), that require authentication should # be entered without the authentication info in the URL (because # then it would be visible), but we need it in the URL when testing # to make sure it exists. Reformat the path here to include them. new_netloc = urlquote(self.username, safe='') if self.password: new_netloc += ':' + urlquote(self.password, safe='') new_netloc += '@' + url_parts.netloc path = urlunsplit((url_parts[0], new_netloc, url_parts[2], url_parts[3], url_parts[4])) else: path = self.path p = self._run_git(['ls-remote', path, 'HEAD']) errmsg = p.stderr.read() failure = p.wait() if failure: logging.error("Git: Failed to find valid repository %s: %s" % (self.path, errmsg)) return False return True
def get_success_url(self): """Continue on task or redirect back to task list.""" url = self.flow_task.get_task_url(self.task, url_type='guess', user=self.request.user) back = self.request.GET.get('back', None) if back and not is_safe_url(url=back, host=self.request.get_host()): back = '/' if '_continue' in self.request.POST and back: url = "{}?back={}".format(url, urlquote(back)) elif back: url = back return url
def get_success_url(self): """Continue on task or redirect back to task list.""" url = self.activation.flow_task.get_task_url( self.activation.task, url_type='guess', user=self.request.user, namespace=self.request.resolver_match.namespace) back = self.request.GET.get('back', None) if back and not is_safe_url(url=back, allowed_hosts={self.request.get_host()}): back = '/' if '_continue' in self.request.POST and back: url = "{}?back={}".format(url, urlquote(back)) elif back: url = back return url
def _build_raw_url(self, path, revision): url = self.raw_file_url url = url.replace("<revision>", revision) url = url.replace("<filename>", urlquote(path)) return url