Skip to content

Commit fb577b7

Browse files
committed
Add safe url parsing and fix openapi converter comments
1 parent 1bd9399 commit fb577b7

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

plugins/communication_protocols/http/src/utcp_http/http_communication_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def _build_url_with_path_params(self, url_template: str, tool_args: Dict[str, An
396396
if param_name in tool_args:
397397
# Replace the parameter in the URL
398398
# URL-encode the parameter value to prevent path injection
399-
param_value = quote(str(tool_args[param_name]))
399+
param_value = quote(str(tool_args[param_name]), safe="")
400400
url = url.replace(f'{{{param_name}}}', param_value)
401401
# Remove the parameter from arguments so it's not used as a query parameter
402402
tool_args.pop(param_name)

plugins/communication_protocols/http/src/utcp_http/openapi_converter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,13 @@ def __init__(self, openapi_spec: Dict[str, Any], spec_url: Optional[str] = None,
6565
openapi_spec: Parsed OpenAPI specification as a dictionary.
6666
spec_url: Optional URL where the specification was retrieved from.
6767
Used for base URL determination if servers are not specified.
68-
call_template_name: Optional custom name for the call_template. If not
69-
provided, derives name from the specification title.
68+
call_template_name: Optional custom name for the call_template if
69+
the specification title is not provided.
7070
"""
7171
self.spec = openapi_spec
7272
self.spec_url = spec_url
7373
# Single counter for all placeholder variables
7474
self.placeholder_counter = 0
75-
# If call_template_name is None then get the first word in spec.info.title
7675
if call_template_name is None:
7776
call_template_name = "openapi_call_template_" + uuid.uuid4().hex
7877
title = openapi_spec.get("info", {}).get("title", call_template_name)

plugins/communication_protocols/http/src/utcp_http/sse_communication_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def _build_url_with_path_params(self, url_template: str, tool_args: Dict[str, An
329329
if param_name in tool_args:
330330
# Replace the parameter in the URL
331331
# URL-encode the parameter value to prevent path injection
332-
param_value = quote(str(tool_args[param_name]))
332+
param_value = quote(str(tool_args[param_name]), safe="")
333333
url = url.replace(f'{{{param_name}}}', param_value)
334334
# Remove the parameter from arguments so it's not used as a query parameter
335335
tool_args.pop(param_name)

plugins/communication_protocols/http/src/utcp_http/streamable_http_communication_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def _build_url_with_path_params(self, url_template: str, tool_args: Dict[str, An
354354
if param_name in tool_args:
355355
# Replace the parameter in the URL
356356
# URL-encode the parameter value to prevent path injection
357-
param_value = quote(str(tool_args[param_name]))
357+
param_value = quote(str(tool_args[param_name]), safe="")
358358
url = url.replace(f'{{{param_name}}}', param_value)
359359
# Remove the parameter from arguments so it's not used as a query parameter
360360
tool_args.pop(param_name)

0 commit comments

Comments
 (0)