Merge branch 'main' into avm99963-monorail
Merged commit cd4b3b336f1f14afa02990fdc2eec5d9467a827e
GitOrigin-RevId: e67bbf185d5538e1472bb42e0abb2a141f88bac1
diff --git a/framework/monorailrequest.py b/framework/monorailrequest.py
index 94dd9d6..7fe2918 100644
--- a/framework/monorailrequest.py
+++ b/framework/monorailrequest.py
@@ -16,7 +16,7 @@
import endpoints
import logging
import re
-import urllib
+from six.moves import urllib
import ezt
import six
@@ -240,8 +240,10 @@
"""
with self.profiler.Phase('basic parsing'):
self.request = request
+ self.request_path = request.path
self.current_page_url = request.url
- self.current_page_url_encoded = urllib.quote_plus(self.current_page_url)
+ self.current_page_url_encoded = urllib.parse.quote_plus(
+ self.current_page_url)
# Only accept a hostport from the request that looks valid.
if not _HOSTPORT_RE.match(request.host):
@@ -251,9 +253,8 @@
logging.info('Request: %s', self.current_page_url)
with self.profiler.Phase('path parsing'):
- (viewed_user_val, self.project_name,
- self.hotlist_id, self.hotlist_name) = _ParsePathIdentifiers(
- self.request.path)
+ (viewed_user_val, self.project_name, self.hotlist_id,
+ self.hotlist_name) = _ParsePathIdentifiers(self.request_path)
self.viewed_username = _GetViewedEmail(
viewed_user_val, self.cnxn, services)
with self.profiler.Phase('qs parsing'):
@@ -296,8 +297,10 @@
"""
with self.profiler.Phase('basic parsing'):
self.request = request
+ self.request_path = request.base_url[len(request.host_url) - 1:]
self.current_page_url = request.url
- self.current_page_url_encoded = urllib.quote_plus(self.current_page_url)
+ self.current_page_url_encoded = urllib.parse.quote_plus(
+ self.current_page_url)
# Only accept a hostport from the request that looks valid.
if not _HOSTPORT_RE.match(request.host):
@@ -308,7 +311,7 @@
with self.profiler.Phase('path parsing'):
(viewed_user_val, self.project_name, self.hotlist_id,
- self.hotlist_name) = _ParsePathIdentifiers(self.request.url)
+ self.hotlist_name) = _ParsePathIdentifiers(self.request_path)
self.viewed_username = _GetViewedEmail(
viewed_user_val, self.cnxn, services)
with self.profiler.Phase('qs parsing'):
@@ -335,10 +338,10 @@
prod_debug_allowed = self.perms.HasPerm(
permissions.VIEW_DEBUG, self.auth.user_id, None)
self.debug_enabled = (
- request.args.get('debug') and
+ request.values.get('debug') and
(settings.local_mode or prod_debug_allowed))
# temporary option for perf testing on staging instance.
- if request.args.get('disable_cache'):
+ if request.values.get('disable_cache'):
if settings.local_mode or 'staging' in request.host:
self.use_cached_searches = False
@@ -597,7 +600,7 @@
if hasattr(self.request, 'params'):
value = self.request.params.get(query_param_name)
else:
- value = self.request.args.get(query_param_name)
+ value = self.request.values.get(query_param_name)
assert value is None or isinstance(value, six.text_type)
using_default = value is None
if using_default:
@@ -620,7 +623,7 @@
if hasattr(self.request, 'params'):
value = self.request.params.get(query_param_name)
else:
- value = self.request.args.get(query_param_name)
+ value = self.request.values.get(query_param_name)
if value is None or value == '':
return default_value
@@ -641,7 +644,7 @@
if hasattr(self.request, 'params'):
params = self.request.params.get(query_param_name)
else:
- params = self.request.args.get(query_param_name)
+ params = self.request.values.get(query_param_name)
if params is None:
return default_value
if not params:
@@ -665,7 +668,7 @@
if hasattr(self.request, 'params'):
value = self.request.params.get(query_param_name)
else:
- value = self.request.args.get(query_param_name)
+ value = self.request.values.get(query_param_name)
if value is None:
return default_value
@@ -698,15 +701,14 @@
if split_path[0] == 'p':
project_name = split_path[1]
if split_path[0] == 'u' or split_path[0] == 'users':
- viewed_user_val = urllib.unquote(split_path[1])
+ viewed_user_val = urllib.parse.unquote(split_path[1])
if len(split_path) >= 4 and split_path[2] == 'hotlists':
try:
- hotlist_id = int(
- urllib.unquote(split_path[3].split('.')[0]))
+ hotlist_id = int(urllib.parse.unquote(split_path[3].split('.')[0]))
except ValueError:
raw_last_path = (split_path[3][:-3] if
split_path[3].endswith('.do') else split_path[3])
- last_path = urllib.unquote(raw_last_path)
+ last_path = urllib.parse.unquote(raw_last_path)
match = framework_bizobj.RE_HOTLIST_NAME.match(
last_path)
if not match:
@@ -716,7 +718,7 @@
hotlist_name = last_path.lower()
if split_path[0] == 'g':
- viewed_user_val = urllib.unquote(split_path[1])
+ viewed_user_val = urllib.parse.unquote(split_path[1])
return viewed_user_val, project_name, hotlist_id, hotlist_name