ashb commented on a change in pull request #4911: [AIRFLOW-3768] Escape search
parameter in pagination controls
URL: https://github.com/apache/airflow/pull/4911#discussion_r265928689
##########
File path: airflow/www/utils.py
##########
@@ -68,17 +69,11 @@ def should_hide_value_for_key(key_name):
def get_params(**kwargs):
- params = []
- for k, v in kwargs.items():
- if k == 'showPaused':
- # True is default or None
- if v or v is None:
- continue
- params.append('{}={}'.format(k, v))
- elif v:
- params.append('{}={}'.format(k, v))
- params = sorted(params, key=lambda x: x.split('=')[0])
- return '&'.join(params)
+ if 'showPaused' in kwargs:
+ v = kwargs['showPaused']
+ if v or v is None:
+ kwargs.pop('showPaused')
+ return urlencode(kwargs)
Review comment:
Good call. Updated so that given `a=100, c=None` it will output `a=100&c=`
(given `c` was passed as an arg I feel it should appear in the output string.
This does mean it will come back in when parsed as `c: ""` but I feel that is
more correct)
This function is only currently used from within generate_pages so we don't
have to worry about this possibly slight change in behaviour
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services