Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions gradio/route_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,20 +797,20 @@ def update_example_values_to_use_public_url(api_info: dict[str, Any]) -> dict[st
Updates the example values in the api_info dictionary to use a public url
"""

_is_file_obj_with_url = client_utils.is_file_obj_with_url
_is_http_url_like = client_utils.is_http_url_like
_traverse = client_utils.traverse

def _add_root_url(file_dict: dict):
default_value = file_dict.get("parameter_default")
if default_value is not None and client_utils.is_file_obj_with_url(
default_value
):
if client_utils.is_http_url_like(default_value["url"]):
if default_value is not None and _is_file_obj_with_url(default_value):
url = default_value.get("url")
if url is not None and _is_http_url_like(url):
return file_dict
# If the default value's url is not already a full public url,
# we use the example_input url. This makes it so that the example
# value for images, audio, and video components pass SSRF checks.
default_value["url"] = file_dict["example_input"]["url"]
return file_dict

return client_utils.traverse(
return _traverse(
api_info,
_add_root_url,
lambda d: isinstance(d, dict) and "parameter_default" in d,
Expand Down