fix(msteams): remove hardcoded quote test fallback

This commit is contained in:
Bob Johnson 2026-04-07 21:11:16 -05:00 committed by T3chC0wb0y
parent f73b5e26a2
commit 8e042aea0d
2 changed files with 18 additions and 8 deletions

View File

@ -358,17 +358,19 @@ class MSTeamsChannel(BaseChannel):
if quoted and reply:
return self._format_reply_with_quote(quoted, reply)
# Observed compact fallback where the relay flattens everything into one line
# and appends the literal reply text marker at the end.
# Observed compact fallback where the relay flattens quote and reply into
# a single line after the synthetic FWDIOC-BOT prefix.
compact = re.sub(r"\s+", " ", normalized_newlines).strip()
if compact.startswith("FWDIOC-BOT "):
compact = compact[len("FWDIOC-BOT ") :].strip()
marker = " Reply with quote test"
if compact.endswith(marker):
quoted = compact[: -len(marker)].strip()
reply = marker.strip()
return self._format_reply_with_quote(quoted, reply)
for boundary in (". ", "! ", "? ", ""):
idx = compact.rfind(boundary)
if idx == -1:
continue
quoted = compact[: idx + 1].strip()
reply = compact[idx + len(boundary) :].strip()
if quoted and reply and len(reply) <= 160:
return self._format_reply_with_quote(quoted, reply)
return cleaned

View File

@ -264,6 +264,14 @@ def test_sanitize_inbound_text_structures_live_fwdioc_quote_shape(make_channel):
)
def test_normalize_teams_reply_quote_leaves_plain_text_test_phrase_untouched(make_channel):
ch = make_channel()
text = "Normal message ending with Reply with quote test"
assert ch._normalize_teams_reply_quote(text) == text
def test_sanitize_inbound_text_structures_multiline_fwdioc_quote_shape(make_channel):
ch = make_channel()