Skip to content

Commit b4050e5

Browse files
committed
fix(run.py): enhance _remove_backticks to strip invisible Unicode control characters
The _remove_backticks function now removes not only backticks but also invisible Unicode control characters. This change improves text sanitization by ensuring that any non-printable characters are stripped, which can prevent potential issues with text processing and display.
1 parent 317c6b1 commit b4050e5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/tux/modules/utility/run.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _remove_ansi(text: str) -> str:
136136

137137
def _remove_backticks(text: str) -> str:
138138
"""
139-
Remove backticks from text.
139+
Remove backticks and invisible Unicode control characters from text.
140140
141141
Parameters
142142
----------
@@ -146,9 +146,11 @@ def _remove_backticks(text: str) -> str:
146146
Returns
147147
-------
148148
str
149-
Text with backticks removed.
149+
Text with backticks and control characters removed.
150150
"""
151-
return BACKTICKS_PATTERN.sub("", text)
151+
text = BACKTICKS_PATTERN.sub("", text)
152+
# Remove invisible Unicode control characters (e.g., U+2068)
153+
return "".join(c for c in text if c.isprintable() or c in "\n\t\r")
152154

153155

154156
class CodeDispatch(ABC):

0 commit comments

Comments
 (0)