Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not isinstance(value, basestring): # None or other non-splitable
return value
default_query = self.ticketlink_query.startswith('?') and \
self.ticketlink_query[1:] or self.ticketlink_query
args = arg_list_to_args(parse_arg_list(default_query))
items = []
for i, word in enumerate(re.split(r'([;,\s]+)', value)):
if i % 2:
items.append(word)
elif word:
rendered = name != 'cc' and word \
or Chrome(self.env).format_emails(context, word)
if rendered == word:
word_args = args.copy()
word_args[name] = '~' + word
items.append(tag.a(word,
href=context.href.query(word_args)))
else:
items.append(rendered)
return tag(items)
pagename = pagename.rstrip('/') or 'WikiStart'
referrer = ''
if formatter.resource and formatter.resource.realm == 'wiki':
referrer = formatter.resource.id
if pagename.startswith('/'):
pagename = pagename.lstrip('/')
elif pagename.startswith(('./', '../')) or pagename in ('.', '..'):
pagename = self._resolve_relative_name(pagename, referrer)
else:
pagename = self._resolve_scoped_name(pagename, referrer)
label = unquote_label(label)
if 'WIKI_VIEW' in formatter.perm('wiki', pagename, version):
href = formatter.href.wiki(pagename, version=version) + query \
+ fragment
if self.has_page(pagename):
return tag.a(label, href=href, class_='wiki')
else:
if ignore_missing:
return original_label or label
if 'WIKI_CREATE' in formatter.perm('wiki', pagename, version):
return tag.a(label + '?', class_='missing wiki',
href=href, rel='nofollow')
else:
return tag.a(label + '?', class_='missing wiki')
elif ignore_missing and not self.has_page(pagename):
return original_label or label
else:
return tag.a(label, class_='forbidden wiki',
title=_("no permission to view this wiki page"))
if path != '/':
add_link(req, 'up', path_links[-2]['href'], _('Parent directory'))
rss_href = make_log_href(path, format='rss', revs=revs,
stop_rev=stop_rev)
add_link(req, 'alternate', auth_link(req, rss_href), _('RSS Feed'),
'application/rss+xml', 'rss')
changelog_href = make_log_href(path, format='changelog', revs=revs,
stop_rev=stop_rev)
add_link(req, 'alternate', changelog_href, _('ChangeLog'), 'text/plain')
add_ctxtnav(req, _('View Latest Revision'),
href=req.href.browser(repos.reponame or None, path))
if 'next' in req.chrome['links']:
next = req.chrome['links']['next'][0]
add_ctxtnav(req, tag.span(tag.a(_('Older Revisions'),
href=next['href']),
Markup(' →')))
return 'revisionlog.html', data, None
def _render_link(self, context, name, label, extra=''):
try:
milestone = Milestone(self.env, name)
except TracError:
milestone = None
# Note: the above should really not be needed, `Milestone.exists`
# should simply be false if the milestone doesn't exist in the db
# (related to #4130)
href = context.href.milestone(name)
if milestone and milestone.exists:
if 'MILESTONE_VIEW' in context.perm(milestone.resource):
closed = 'closed ' if milestone.is_completed else ''
return tag.a(label, class_='%smilestone' % closed,
href=href + extra)
elif 'MILESTONE_CREATE' in context.perm('milestone', name):
return tag.a(label, class_='missing milestone', href=href + extra,
rel='nofollow')
return tag.a(label, class_='missing milestone')
def _format_revision_link(self, formatter, ns, reponame, rev, label,
fullmatch=None):
rev, params, fragment = formatter.split_link(rev)
try:
repos = RepositoryManager(self.env).get_repository(reponame)
if repos:
changeset = repos.get_changeset(rev)
return tag.a(label, class_="changeset",
title=shorten_line(changeset.message),
href=(formatter.href.changeset(rev) +
params + fragment))
except NoSuchChangeset:
pass
return tag.a(label, class_="missing changeset", rel="nofollow",
href=formatter.href.changeset(rev))
p.owner_link = Query.from_string(self.env,
'status!=closed&col=id&col=summary&col=owner'
'&col=status&col=priority&order=priority'
'&group=product&owner=%s' % (p._data['owner'] or '', )
).get_href(phref)
p.href = phref()
data.setdefault('product_list', []).append(p)
title = _('Products')
data['colseq'] = itertools.cycle(xrange(cols - 1, -1, -1)) if cols \
else itertools.repeat(1)
return 'widget_product.html', {
'title': title,
'data': data,
'ctxtnav': [tag.a(_('More'), href=req.href('products'))],
}, context
revs = None
if 'LOG_VIEW' in formatter.perm:
if revranges:
href = formatter.href.log(repos.reponame or None,
path or '/',
revs=str(revranges))
else:
try:
rev = repos.normalize_rev(revs)
except NoSuchChangeset:
rev = None
href = formatter.href.log(repos.reponame or None,
path or '/', rev=rev)
if query and (revranges or revs):
query = '&' + query[1:]
return tag.a(label, class_='source',
href=href + query + fragment)
errmsg = _("No permission to view change log")
elif reponame:
errmsg = _("Repository '%(repo)s' not found", repo=reponame)
else:
errmsg = _("No default repository defined")
except TracError, e:
errmsg = to_unicode(e)
return tag.a(label, class_='missing source', title=errmsg)
break
prev_rev = rev
if build:
build_data = _get_build_data(self.env, req, build)
if build_data['status'] == 'failed':
status='bittenfailed'
break
if build_data['status'] == 'in progress':
status='bitteninprogress'
elif not status:
if (build_data['status'] == 'completed'):
status='bittencompleted'
if not status:
status='bittenpending'
yield ('mainnav', 'build',
tag.a('Build Status', href=req.href.build(), accesskey=5,
class_=status))
def _do_create(self, req, ticket):
ticket.insert()
# Notify
try:
tn = TicketNotifyEmail(self.env)
tn.notify(ticket, newticket=True)
except Exception, e:
self.log.error("Failure sending notification on creation of "
"ticket #%s: %s", ticket.id, exception_to_unicode(e))
add_warning(req, _("The ticket has been created, but an error "
"occurred while sending notifications: "
"%(message)s", message=to_unicode(e)))
# Redirect the user to the newly created ticket or add attachment
ticketref=tag.a('#', ticket.id, href=req.href.ticket(ticket.id))
if 'attachment' in req.args:
add_notice(req, tag_("The ticket %(ticketref)s has been created. "
"You can now attach the desired files.",
ticketref=ticketref))
req.redirect(req.href.attachment('ticket', ticket.id,
action='new'))
if 'TICKET_VIEW' not in req.perm('ticket', ticket.id):
add_notice(req, tag_("The ticket %(ticketref)s has been created, "
"but you don't have permission to view it.",
ticketref=ticketref))
req.redirect(req.href.newticket())
req.redirect(req.href.ticket(ticket.id))