mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 00:07:57 -05:00
Clean up lowercase duplications of request.GET/request.POST.
This commit is contained in:
@@ -411,11 +411,11 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
form.set_error(errors.QUOTA_FILLED, None)
|
||||
return
|
||||
|
||||
if not c.user.gold or not hasattr(request.post, 'sendreplies'):
|
||||
if not c.user.gold or not request.POST.get('sendreplies'):
|
||||
sendreplies = kind == 'self'
|
||||
|
||||
# get rid of extraneous whitespace in the title
|
||||
cleaned_title = re.sub(r'\s+', ' ', request.post.title, flags=re.UNICODE)
|
||||
cleaned_title = re.sub(r'\s+', ' ', title, flags=re.UNICODE)
|
||||
cleaned_title = cleaned_title.strip()
|
||||
|
||||
# well, nothing left to do but submit it
|
||||
@@ -1584,7 +1584,7 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
# None/Undefined and an empty string. The validators use a default
|
||||
# value with both of those cases and would need to be changed.
|
||||
# In order to avoid breaking functionality, this was done instead.
|
||||
prevstyle = request.post.get('prevstyle')
|
||||
prevstyle = request.POST.get('prevstyle')
|
||||
if not report:
|
||||
return abort(403, 'forbidden')
|
||||
|
||||
@@ -1891,9 +1891,9 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
# None/Undefined and an empty string. The validators use a default
|
||||
# value with both of those cases and would need to be changed.
|
||||
# In order to avoid breaking functionality, this was done instead.
|
||||
prev_desc = request.post.get('prev_description_id')
|
||||
prev_pubdesc = request.post.get('prev_public_description_id')
|
||||
prev_submit_text = request.post.get('prev_submit_text_id')
|
||||
prev_desc = request.POST.get('prev_description_id')
|
||||
prev_pubdesc = request.POST.get('prev_public_description_id')
|
||||
prev_submit_text = request.POST.get('prev_submit_text_id')
|
||||
|
||||
def update_wiki_text(sr):
|
||||
error = False
|
||||
@@ -3405,9 +3405,9 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
form.has_errors('redirect_uri', errors.BAD_URL, errors.NO_URL)):
|
||||
return
|
||||
|
||||
description = request.post.get('description', '')
|
||||
description = request.POST.get('description', '')
|
||||
|
||||
client_id = request.post.get('client_id')
|
||||
client_id = request.POST.get('client_id')
|
||||
if client_id:
|
||||
# client_id was specified, updating existing OAuth2Client
|
||||
client = OAuth2Client.get_token(client_id)
|
||||
|
||||
@@ -98,7 +98,7 @@ class FrontController(RedditController, OAuth2ResourceController):
|
||||
if c.extension:
|
||||
new_url = new_url + "/.%s" % c.extension
|
||||
|
||||
new_url = new_url + query_string(request.get)
|
||||
new_url = new_url + query_string(request.GET)
|
||||
|
||||
# redirect should be smarter and handle extensions, etc.
|
||||
return self.redirect(new_url, code=301)
|
||||
@@ -256,7 +256,7 @@ class FrontController(RedditController, OAuth2ResourceController):
|
||||
|
||||
# check if we just came from the submit page
|
||||
infotext = None
|
||||
if request.get.get('already_submitted'):
|
||||
if request.GET.get('already_submitted'):
|
||||
infotext = strings.already_submitted % article.resubmit_link()
|
||||
|
||||
check_cheating('comments')
|
||||
@@ -947,7 +947,7 @@ class FrontController(RedditController, OAuth2ResourceController):
|
||||
then=VOneOf('then', ('tb','comments'), default='comments'))
|
||||
def GET_submit(self, url, title, text, selftext, then):
|
||||
"""Submit form."""
|
||||
resubmit = request.get.get('resubmit')
|
||||
resubmit = request.GET.get('resubmit')
|
||||
if url and not resubmit:
|
||||
# check to see if the url has already been submitted
|
||||
links = link_from_url(url)
|
||||
@@ -987,7 +987,7 @@ class FrontController(RedditController, OAuth2ResourceController):
|
||||
extra_subreddits=extra_subreddits,
|
||||
show_link=c.default_sr or c.site.link_type != 'self',
|
||||
show_self=((c.default_sr or c.site.link_type != 'link')
|
||||
and not request.get.get('no_self')),
|
||||
and not request.GET.get('no_self')),
|
||||
then=then,
|
||||
)
|
||||
|
||||
@@ -1268,7 +1268,7 @@ class FormsController(RedditController):
|
||||
content = None
|
||||
infotext = None
|
||||
if not location or location == 'options':
|
||||
content = PrefOptions(done=request.get.get('done'))
|
||||
content = PrefOptions(done=request.GET.get('done'))
|
||||
elif location == 'friends':
|
||||
content = PaneStack()
|
||||
infotext = strings.friends % Friends.path
|
||||
|
||||
@@ -386,8 +386,8 @@ class HotController(FixListing, ListingController):
|
||||
@require_oauth2_scope("read")
|
||||
@listing_api_doc(uri='/hot', uses_site=True)
|
||||
def GET_listing(self, **env):
|
||||
self.requested_ad = request.get.get('ad')
|
||||
self.infotext = request.get.get('deleted') and strings.user_deleted
|
||||
self.requested_ad = request.GET.get('ad')
|
||||
self.infotext = request.GET.get('deleted') and strings.user_deleted
|
||||
return ListingController.GET_listing(self, **env)
|
||||
|
||||
class NewController(ListingController):
|
||||
@@ -641,7 +641,7 @@ class UserController(ListingController):
|
||||
q = queries.get_hidden(self.vuser)
|
||||
|
||||
elif self.where == 'saved':
|
||||
srname = request.get.get('sr')
|
||||
srname = request.GET.get('sr')
|
||||
if srname and c.user.gold:
|
||||
try:
|
||||
sr_id = Subreddit._by_name(srname)._id
|
||||
|
||||
@@ -42,7 +42,7 @@ class PostController(ApiController):
|
||||
elif all_langs == 'some':
|
||||
langs = []
|
||||
for lang in g.all_languages:
|
||||
if request.post.get('lang-' + lang):
|
||||
if request.POST.get('lang-' + lang):
|
||||
langs.append(str(lang)) #unicode
|
||||
if langs:
|
||||
langs.sort()
|
||||
@@ -183,7 +183,7 @@ class PostController(ApiController):
|
||||
response.content_type = "text/html"
|
||||
|
||||
if c.errors:
|
||||
return LoginPage(user_login = request.post.get('user'),
|
||||
return LoginPage(user_login = request.POST.get('user'),
|
||||
dest = dest).render()
|
||||
|
||||
return self.redirect(dest)
|
||||
@@ -195,7 +195,7 @@ class PostController(ApiController):
|
||||
response.content_type = "text/html"
|
||||
|
||||
if c.errors:
|
||||
return LoginPage(user_reg = request.post.get('user'),
|
||||
return LoginPage(user_reg = request.POST.get('user'),
|
||||
dest = dest).render()
|
||||
|
||||
return self.redirect(dest)
|
||||
|
||||
@@ -556,10 +556,10 @@ def set_colors():
|
||||
theme_rx = re.compile(r'')
|
||||
color_rx = re.compile(r'\A([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\Z')
|
||||
c.theme = None
|
||||
if color_rx.match(request.get.get('bgcolor') or ''):
|
||||
c.bgcolor = request.get.get('bgcolor')
|
||||
if color_rx.match(request.get.get('bordercolor') or ''):
|
||||
c.bordercolor = request.get.get('bordercolor')
|
||||
if color_rx.match(request.GET.get('bgcolor') or ''):
|
||||
c.bgcolor = request.GET.get('bgcolor')
|
||||
if color_rx.match(request.GET.get('bordercolor') or ''):
|
||||
c.bordercolor = request.GET.get('bordercolor')
|
||||
|
||||
|
||||
def ratelimit_agent(agent, limit=10, slice_size=10):
|
||||
@@ -924,7 +924,7 @@ class MinimalController(BaseController):
|
||||
self.check_cors()
|
||||
|
||||
def update_qstring(self, dict):
|
||||
merged = copy(request.get)
|
||||
merged = copy(request.GET)
|
||||
merged.update(dict)
|
||||
return request.path + utils.query_string(merged)
|
||||
|
||||
|
||||
@@ -325,7 +325,7 @@ class WikiApiController(WikiController):
|
||||
# None/Undefined and an empty string. The validators use a default
|
||||
# value with both of those cases and would need to be changed.
|
||||
# In order to avoid breaking functionality, this was done instead.
|
||||
previous = previous._id if previous else request.post.get('previous')
|
||||
previous = previous._id if previous else request.POST.get('previous')
|
||||
try:
|
||||
if page.name == 'config/stylesheet':
|
||||
report, parsed = c.site.parse_css(content, verify=False)
|
||||
|
||||
@@ -26,7 +26,7 @@ from pylons.i18n import N_, _, ungettext, get_lang
|
||||
from webob.exc import HTTPException, status_map
|
||||
from r2.lib.filters import spaceCompress, _force_unicode
|
||||
from r2.lib.template_helpers import get_domain
|
||||
from utils import storify, string2js, read_http_date
|
||||
from utils import string2js, read_http_date
|
||||
|
||||
import re, hashlib
|
||||
from urllib import quote
|
||||
@@ -105,8 +105,6 @@ class BaseController(WSGIController):
|
||||
if environ.get('HTTP_X_DONT_DECODE'):
|
||||
request.charset = None
|
||||
|
||||
request.get = storify(request.GET)
|
||||
request.post = storify(request.POST)
|
||||
request.referer = environ.get('HTTP_REFERER')
|
||||
request.user_agent = environ.get('HTTP_USER_AGENT')
|
||||
request.fullpath = environ.get('FULLPATH', request.path)
|
||||
|
||||
@@ -718,7 +718,7 @@ class ClickGadget(Templated):
|
||||
|
||||
def make_content(self):
|
||||
#this will disable the hardcoded widget styles
|
||||
request.get.style = "off"
|
||||
request.GET["style"] = "off"
|
||||
wrapper = default_thing_wrapper(embed_voting_style = 'votable',
|
||||
style = "htmllite")
|
||||
content = wrap_links(self.links, wrapper = wrapper)
|
||||
@@ -3271,7 +3271,7 @@ class Cnameframe(Templated):
|
||||
self.title = "%s - %s" % (subreddit.title, sub_domain)
|
||||
u = UrlParser(subreddit.path + original_path)
|
||||
u.hostname = get_domain(cname = False, subreddit = False)
|
||||
u.update_query(**request.get.copy())
|
||||
u.update_query(**request.GET.copy())
|
||||
u.put_in_frame()
|
||||
self.frame_target = u.unparse()
|
||||
else:
|
||||
@@ -3921,7 +3921,7 @@ class PromoteReport(Templated):
|
||||
self.end = end
|
||||
if links:
|
||||
self.make_reports()
|
||||
p = request.get.copy()
|
||||
p = request.GET.copy()
|
||||
self.csv_url = '%s.csv?%s' % (request.path, urlencode(p))
|
||||
else:
|
||||
self.link_report = None
|
||||
|
||||
@@ -650,7 +650,7 @@ class PromotedLinkTraffic(Templated):
|
||||
display_start = display_end - self.period
|
||||
|
||||
if display_start > start:
|
||||
p = request.get.copy()
|
||||
p = request.GET.copy()
|
||||
p.update({
|
||||
'after': None,
|
||||
'before': display_start.strftime('%Y%m%d%H'),
|
||||
@@ -660,7 +660,7 @@ class PromotedLinkTraffic(Templated):
|
||||
display_start = start
|
||||
|
||||
if display_end < end:
|
||||
p = request.get.copy()
|
||||
p = request.GET.copy()
|
||||
p.update({
|
||||
'after': display_end.strftime('%Y%m%d%H'),
|
||||
'before': None,
|
||||
|
||||
@@ -103,68 +103,6 @@ class Storage(dict):
|
||||
|
||||
storage = Storage
|
||||
|
||||
def storify(mapping, *requireds, **defaults):
|
||||
"""
|
||||
Creates a `storage` object from dictionary `mapping`, raising `KeyError` if
|
||||
d doesn't have all of the keys in `requireds` and using the default
|
||||
values for keys found in `defaults`.
|
||||
|
||||
For example, `storify({'a':1, 'c':3}, b=2, c=0)` will return the equivalent of
|
||||
`storage({'a':1, 'b':2, 'c':3})`.
|
||||
|
||||
If a `storify` value is a list (e.g. multiple values in a form submission),
|
||||
`storify` returns the last element of the list, unless the key appears in
|
||||
`defaults` as a list. Thus:
|
||||
|
||||
>>> storify({'a':[1, 2]}).a
|
||||
2
|
||||
>>> storify({'a':[1, 2]}, a=[]).a
|
||||
[1, 2]
|
||||
>>> storify({'a':1}, a=[]).a
|
||||
[1]
|
||||
>>> storify({}, a=[]).a
|
||||
[]
|
||||
|
||||
Similarly, if the value has a `value` attribute, `storify will return _its_
|
||||
value, unless the key appears in `defaults` as a dictionary.
|
||||
|
||||
>>> storify({'a':storage(value=1)}).a
|
||||
1
|
||||
>>> storify({'a':storage(value=1)}, a={}).a
|
||||
<Storage {'value': 1}>
|
||||
>>> storify({}, a={}).a
|
||||
{}
|
||||
|
||||
"""
|
||||
def getvalue(x):
|
||||
if hasattr(x, 'value'):
|
||||
return x.value
|
||||
else:
|
||||
return x
|
||||
|
||||
stor = Storage()
|
||||
for key in requireds + tuple(mapping.keys()):
|
||||
value = mapping[key]
|
||||
if isinstance(value, list):
|
||||
if isinstance(defaults.get(key), list):
|
||||
value = [getvalue(x) for x in value]
|
||||
else:
|
||||
value = value[-1]
|
||||
if not isinstance(defaults.get(key), dict):
|
||||
value = getvalue(value)
|
||||
if isinstance(defaults.get(key), list) and not isinstance(value, list):
|
||||
value = [value]
|
||||
setattr(stor, key, value)
|
||||
|
||||
for (key, value) in defaults.iteritems():
|
||||
result = value
|
||||
if hasattr(stor, key):
|
||||
result = stor[key]
|
||||
if value == () and not isinstance(result, tuple):
|
||||
result = (result,)
|
||||
setattr(stor, key, result)
|
||||
|
||||
return stor
|
||||
|
||||
class Enum(Storage):
|
||||
def __init__(self, *a):
|
||||
|
||||
@@ -112,10 +112,10 @@ class Validator(object):
|
||||
a = []
|
||||
if self.param:
|
||||
for p in utils.tup(self.param):
|
||||
if self.post and request.post.get(p):
|
||||
val = request.post[p]
|
||||
elif self.get and request.get.get(p):
|
||||
val = request.get[p]
|
||||
if self.post and request.POST.get(p):
|
||||
val = request.POST[p]
|
||||
elif self.get and request.GET.get(p):
|
||||
val = request.GET[p]
|
||||
elif self.url and url.get(p):
|
||||
val = url[p]
|
||||
else:
|
||||
|
||||
@@ -288,7 +288,7 @@ class Link(Thing, Printable):
|
||||
c.user_is_sponsor,
|
||||
wrapped.url, repr(wrapped.title)])
|
||||
if style == "htmllite":
|
||||
s.extend([request.get.has_key('twocolumn'),
|
||||
s.extend([request.GET.has_key('twocolumn'),
|
||||
c.link_target])
|
||||
elif style == "xml":
|
||||
s.append(request.GET.has_key("nothumbs"))
|
||||
|
||||
@@ -76,15 +76,15 @@ class Listing(object):
|
||||
self.before = None
|
||||
|
||||
if self.nextprev and self.prev_link and prev and bcount > 1:
|
||||
p = request.get.copy()
|
||||
p = request.GET.copy()
|
||||
p.update({'after':None, 'before':prev._fullname, 'count':bcount})
|
||||
self.before = prev._fullname
|
||||
self.prev = (request.path + utils.query_string(p))
|
||||
p_first = request.get.copy()
|
||||
p_first = request.GET.copy()
|
||||
p_first.update({'after':None, 'before':None, 'count':None})
|
||||
self.first = (request.path + utils.query_string(p_first))
|
||||
if self.nextprev and self.next_link and next:
|
||||
p = request.get.copy()
|
||||
p = request.GET.copy()
|
||||
p.update({'after':next._fullname, 'before':None, 'count':acount})
|
||||
self.after = next._fullname
|
||||
self.next = (request.path + utils.query_string(p))
|
||||
|
||||
@@ -83,7 +83,7 @@ class Printable(object):
|
||||
|
||||
if style == 'htmllite':
|
||||
s.extend([c.bgcolor, c.bordercolor,
|
||||
request.get.has_key('style'),
|
||||
request.get.get("expanded"),
|
||||
request.GET.has_key('style'),
|
||||
request.GET.get("expanded"),
|
||||
getattr(wrapped, 'embed_voting_style', None)])
|
||||
return s
|
||||
|
||||
@@ -48,8 +48,8 @@
|
||||
from r2.lib.strings import Score
|
||||
domain = get_domain(subreddit=False)
|
||||
permalink = "http://%s%s" % (domain, thing.permalink)
|
||||
expanded = request.get.get("expanded")
|
||||
two_col = request.get.has_key("twocolumn") if l else False
|
||||
expanded = request.GET.get("expanded")
|
||||
two_col = request.GET.has_key("twocolumn") if l else False
|
||||
%>
|
||||
${self.arrows(thing)}
|
||||
<div class="reddit-entry entry ${thing.like_cls}"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<%
|
||||
t = thing.things
|
||||
l = len(t)
|
||||
two_col = request.get.has_key("twocolumn") if l else False
|
||||
two_col = request.GET.has_key("twocolumn") if l else False
|
||||
%>
|
||||
%for i, a in enumerate(t):
|
||||
<%
|
||||
|
||||
@@ -103,7 +103,7 @@ ${self.Child()}
|
||||
<%def name="arrows(thing)">
|
||||
%if getattr(thing, 'embed_voting_style',None) == 'votable':
|
||||
${self.real_arrows(thing)}
|
||||
%elif request.get.get("expanded") or getattr(thing, 'embed_voting_style',None) == 'expanded':
|
||||
%elif request.GET.get("expanded") or getattr(thing, 'embed_voting_style', None) == 'expanded':
|
||||
${self.iframe_arrows(thing)}
|
||||
%else:
|
||||
${self.static_arrows(thing)}
|
||||
|
||||
@@ -261,7 +261,7 @@ ${unsafe(txt)}
|
||||
</%def>
|
||||
|
||||
<%def name="optionalstyle(style)">
|
||||
%if request.get.get('style') != "off":
|
||||
%if request.GET.get('style') != "off":
|
||||
style="${style}"
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
Reference in New Issue
Block a user