Skip to content

Commit 9c680bd

Browse files
author
Florence Yeun
committed
Remove cnameframe
Remove dependencies on the query parameter `cnameframe`, as it is no longer used to trigger `c.cname` behavior or for url parsing with frames. Remove `UrlParser.cname_get`, `UrlParser.mk_cname()`, `UrlParser.is_in_frame()`, and `UrlParser.put_in_frame()`.
1 parent 13db867 commit 9c680bd

File tree

5 files changed

+1
-57
lines changed

5 files changed

+1
-57
lines changed

r2/r2/config/middleware.py

-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ def error_mapper(code, message, environ, global_conf=None, **kw):
107107
if error_data:
108108
environ['extra_error_data'] = error_data
109109

110-
if environ.get('REDDIT_CNAME'):
111-
d['cnameframe'] = 1
112110
if environ.get('REDDIT_NAME'):
113111
d['srname'] = environ.get('REDDIT_NAME')
114112
if environ.get('REDDIT_TAKEDOWN'):

r2/r2/controllers/front.py

-2
Original file line numberDiff line numberDiff line change
@@ -1361,8 +1361,6 @@ def GET_framebuster(self, what=None, blah=None):
13611361
if c.user_is_loggedin:
13621362
path += "login/"
13631363
u = UrlParser(path + str(random.random()))
1364-
u.mk_cname(require_frame=False, subreddit=c.site,
1365-
port=request.port)
13661364
return self.redirect(u.unparse())
13671365
# the user is not logged in or there is no cname.
13681366
return FrameBuster(login=False).render()

r2/r2/lib/base.py

-4
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ def format_output_url(cls, url, **kw):
195195
if not kw.has_key('port'):
196196
kw['port'] = request.port
197197

198-
# disentangle the cname (for urls that would have
199-
# cnameframe=1 in them)
200-
u.mk_cname(**kw)
201-
202198
# make sure the extensions agree with the current page
203199
if preserve_extension and c.extension:
204200
u.set_extension(c.extension)

r2/r2/lib/pages/pages.py

-1
Original file line numberDiff line numberDiff line change
@@ -4247,7 +4247,6 @@ def __init__(self, original_path, subreddit, sub_domain):
42474247
u = UrlParser(subreddit.path + original_path)
42484248
u.hostname = get_domain(cname = False, subreddit = False)
42494249
u.update_query(**request.GET.copy())
4250-
u.put_in_frame()
42514250
self.frame_target = u.unparse()
42524251
else:
42534252
self.title = ""

r2/r2/lib/utils/utils.py

+1-48
Original file line numberDiff line numberDiff line change
@@ -479,16 +479,14 @@ class UrlParser(object):
479479
path can also be set and queried.
480480
481481
The class also contains reddit-specific functions for setting,
482-
checking, and getting a path's subreddit. It also can convert
483-
paths between in-frame and out of frame cname'd forms.
482+
checking, and getting a path's subreddit.
484483
"""
485484

486485
__slots__ = ['scheme', 'path', 'params', 'query',
487486
'fragment', 'username', 'password', 'hostname', 'port',
488487
'_orig_url', '_orig_netloc', '_query_dict']
489488

490489
valid_schemes = ('http', 'https', 'ftp', 'mailto')
491-
cname_get = "cnameframe"
492490

493491
def __init__(self, url):
494492
u = urlparse(url)
@@ -781,51 +779,6 @@ def netloc(self):
781779
return self.hostname + ":" + str(self.port)
782780
return self.hostname
783781

784-
def mk_cname(self, require_frame = True, subreddit = None, port = None):
785-
"""
786-
Converts a ?cnameframe url into the corresponding cnamed
787-
domain if applicable. Useful for frame-busting on redirect.
788-
"""
789-
790-
# make sure the url is indeed in a frame
791-
if require_frame and not self.query_dict.has_key(self.cname_get):
792-
return self
793-
794-
# fetch the subreddit and make sure it
795-
subreddit = subreddit or self.get_subreddit()
796-
if subreddit and subreddit.domain:
797-
798-
# no guarantee there was a scheme
799-
self.scheme = self.scheme or "http"
800-
801-
# update the domain (preserving the port)
802-
self.hostname = subreddit.domain
803-
self.port = getattr(self, 'port', None) or port
804-
805-
# and remove any cnameframe GET parameters
806-
if self.query_dict.has_key(self.cname_get):
807-
del self._query_dict[self.cname_get]
808-
809-
# remove the subreddit reference
810-
self.path = lstrips(self.path, subreddit.path)
811-
if not self.path.startswith('/'):
812-
self.path = '/' + self.path
813-
814-
return self
815-
816-
def is_in_frame(self):
817-
"""
818-
Checks if the url is in a frame by determining if
819-
cls.cname_get is present.
820-
"""
821-
return self.query_dict.has_key(self.cname_get)
822-
823-
def put_in_frame(self):
824-
"""
825-
Adds the cls.cname_get get parameter to the query string.
826-
"""
827-
self.update_query(**{self.cname_get:random.random()})
828-
829782
def __repr__(self):
830783
return "<URL %s>" % repr(self.unparse())
831784

0 commit comments

Comments
 (0)