1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

ansible-galaxy: fix searching with unicode

This commit is contained in:
Martin Krizek 2018-10-15 14:39:04 +02:00 committed by Brian Coca
parent 06eabc9783
commit 096717edc5
2 changed files with 5 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- ansible-galaxy - Prevent unicode errors when searching - https://github.com/ansible/ansible/issues/42866

View file

@ -30,7 +30,7 @@ from ansible.galaxy.token import GalaxyToken
from ansible.module_utils.six import string_types from ansible.module_utils.six import string_types
from ansible.module_utils.six.moves.urllib.error import HTTPError from ansible.module_utils.six.moves.urllib.error import HTTPError
from ansible.module_utils.six.moves.urllib.parse import quote as urlquote, urlencode from ansible.module_utils.six.moves.urllib.parse import quote as urlquote, urlencode
from ansible.module_utils._text import to_native, to_text from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.module_utils.urls import open_url from ansible.module_utils.urls import open_url
try: try:
@ -178,7 +178,7 @@ class GalaxyAPI(object):
""" """
Find a role by name. Find a role by name.
""" """
role_name = urlquote(role_name) role_name = to_text(urlquote(to_bytes(role_name)))
try: try:
parts = role_name.split(".") parts = role_name.split(".")
@ -246,7 +246,7 @@ class GalaxyAPI(object):
search_url = self.baseurl + '/search/roles/?' search_url = self.baseurl + '/search/roles/?'
if search: if search:
search_url += '&autocomplete=' + urlquote(search) search_url += '&autocomplete=' + to_text(urlquote(to_bytes(search)))
tags = kwargs.get('tags', None) tags = kwargs.get('tags', None)
platforms = kwargs.get('platforms', None) platforms = kwargs.get('platforms', None)