File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,6 +78,10 @@ def _validate_operation_name(operation_name: str) -> None:
7878
7979def build_operation_name (prefix : object , identifier : object ) -> str :
8080 normalized_prefix = _coerce_operation_name_component (prefix , fallback = "" )
81+ normalized_prefix = "" .join (
82+ "?" if ord (character ) < 32 or ord (character ) == 127 else character
83+ for character in normalized_prefix
84+ )
8185 raw_identifier = _coerce_operation_name_component (identifier , fallback = "unknown" )
8286 normalized_identifier = raw_identifier .strip ()
8387 if not normalized_identifier :
Original file line number Diff line number Diff line change @@ -118,6 +118,15 @@ def __str__(self) -> str:
118118 assert operation_name == "identifier"
119119
120120
121+ def test_build_operation_name_sanitizes_control_characters_in_prefix ():
122+ operation_name = build_operation_name (
123+ "crawl\n job\t " ,
124+ "identifier" ,
125+ )
126+
127+ assert operation_name == "crawl?job? identifier"
128+
129+
121130def test_poll_until_terminal_status_allows_immediate_terminal_on_zero_max_wait ():
122131 status = poll_until_terminal_status (
123132 operation_name = "sync immediate zero wait" ,
You can’t perform that action at this time.
0 commit comments