1a107601fa490ca69215facceebe3d0dc5e7f1f8 | 6bcef0037bdb2d139a15065c3f31e872bae79df3 | ||
---|---|---|---|
26 | from r2.lib.filters import unkeep_space, websafe | 26 | from r2.lib.filters import unkeep_space, websafe |
27 | from r2.lib.db.operators import asc, desc | 27 | from r2.lib.db.operators import asc, desc |
28 | from r2.config import cache | 28 | from r2.config import cache |
29 | from r2.lib.template_helpers import reddit_link | 29 | from r2.lib.template_helpers import add_sr |
30 | from r2.lib.jsonresponse import json_respond | 30 | from r2.lib.jsonresponse import json_respond |
31 | 31 | ||
32 | from r2.models import * | 32 | from r2.models import * |
... | ... | ||
77 | return fn(self, *a, **kw) | 77 | return fn(self, *a, **kw) |
78 | 78 | ||
79 | except UserRequiredException: | 79 | except UserRequiredException: |
80 | d = dict(dest=reddit_link(request.path, url = True) | 80 | d = dict(dest=add_sr(request.path) + |
81 | + utils.query_string(request.GET)) | 81 | utils.query_string(request.GET)) |
82 | if c.cname: | ||
83 | d['cnameframe'] = 1 | ||
82 | path = "/login" | 84 | path = "/login" |
83 | if request.environ.get('extension'): | 85 | if request.environ.get('extension'): |
84 | path += ".%s" % request.environ['extension'] | 86 | path += ".%s" % request.environ['extension'] |
... | ... | ||
633 | 635 | ||
634 | if reason.startswith('redirect_'): | 636 | if reason.startswith('redirect_'): |
635 | dest = reason[9:] | 637 | dest = reason[9:] |
638 | if (not dest.startswith(c.site.path) and | ||
639 | not dest.startswith("http:")): | ||
640 | dest = (c.site.path + dest).replace('//', '/') | ||
636 | return ('redirect', dest) | 641 | return ('redirect', dest) |
637 | if reason.startswith('vote_'): | 642 | if reason.startswith('vote_'): |
638 | fullname = reason[5:] | 643 | fullname = reason[5:] |
639 | t = Thing._by_fullname(fullname, data=True) | 644 | t = Thing._by_fullname(fullname, data=True) |
640 | return ('redirect', t.permalink) | 645 | return ('redirect', t.make_permalink_slow()) |
641 | elif reason.startswith('share_'): | 646 | elif reason.startswith('share_'): |
642 | fullname = reason[6:] | 647 | fullname = reason[6:] |
643 | t = Thing._by_fullname(fullname, data=True) | 648 | t = Thing._by_fullname(fullname, data=True) |
644 | return ('redirect', t.permalink) | 649 | return ('redirect', t.make_permalink_slow()) |
645 | elif reason.startswith('reply_'): | 650 | elif reason.startswith('reply_'): |
646 | fullname = reason[6:] | 651 | fullname = reason[6:] |
647 | t = Thing._by_fullname(fullname, data=True) | 652 | t = Thing._by_fullname(fullname, data=True) |
648 | return ('redirect', t.permalink) | 653 | return ('redirect', t.make_permalink_slow()) |
649 | elif reason.startswith('sr_change_'): | 654 | elif reason.startswith('sr_change_'): |
650 | sr_list = reason[10:].split(',') | 655 | sr_list = reason[10:].split(',') |
651 | fullnames = dict(i.split(':') for i in sr_list) | 656 | fullnames = dict(i.split(':') for i in sr_list) |
... | ... | ||
695 | # return single email if one is expected, list otherwise | 700 | # return single email if one is expected, list otherwise |
696 | return list(emails)[0] if self.num == 1 else emails | 701 | return list(emails)[0] if self.num == 1 else emails |
697 | 702 | ||
703 | |||
704 | class VCnameDomain(Validator): | ||
705 | domain_re = re.compile(r'.+\..+') | ||
706 | |||
707 | def run(self, domain): | ||
708 | if (domain | ||
709 | and (not self.domain_re.match(domain) | ||
710 | or domain.endswith('.reddit.com'))): | ||
711 | c.errors.add(errors.BAD_CNAME) | ||
712 | return domain or '' | ||
713 | |||
698 | # NOTE: make sure *never* to have res check these are present | 714 | # NOTE: make sure *never* to have res check these are present |
699 | # otherwise, the response could contain reference to these errors...! | 715 | # otherwise, the response could contain reference to these errors...! |
700 | class ValidIP(Validator): | 716 | class ValidIP(Validator): |