diff --git a/scripts/ci/utils/slash_command_handler.py b/scripts/ci/utils/slash_command_handler.py index dc151aa35..9f760acc3 100644 --- a/scripts/ci/utils/slash_command_handler.py +++ b/scripts/ci/utils/slash_command_handler.py @@ -4,6 +4,7 @@ import os import re import sys import time +import unicodedata from datetime import datetime, timezone import requests @@ -247,6 +248,18 @@ def get_env_var(name): return val +def _strip_format_chars(s): + """Remove Unicode format characters (category Cf: LRM/RLM U+200E/200F, + zero-width space/joiners U+200B-200D, word joiner U+2060, BOM U+FEFF). + + GitHub's copy-path button and rich-text copy inject these invisibly; + a pasted `/rerun-test foo.py` then never matches any test file + (see PR #31059). They are display hints and never legitimate in a + command or path, so dropping them is always safe. + """ + return "".join(c for c in s if unicodedata.category(c) != "Cf") + + def load_permissions(user_login): """ Reads the permissions JSON from the local file system and returns @@ -1348,7 +1361,7 @@ def main(): repo_name = get_env_var("REPO_FULL_NAME") pr_number = int(get_env_var("PR_NUMBER")) comment_id = int(get_env_var("COMMENT_ID")) - comment_body = get_env_var("COMMENT_BODY").strip() + comment_body = _strip_format_chars(get_env_var("COMMENT_BODY")).strip() user_login = get_env_var("USER_LOGIN") # 2. Load Permissions (local file check first to avoid unnecessary API calls)