Skip to content

Commit 5da079b

Browse files
authored
Merge pull request #2072 from aryansri05/fix-otr-whitespace-detection
Fix OTR whitespace tag detection to prevent false positives
2 parents 58d130a + cff26a9 commit 5da079b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/otr/otr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ otr_on_message_recv(const char* const barejid, const char* const resource, const
296296
// check for OTR whitespace (opportunistic or always)
297297
if (policy == PROF_OTRPOLICY_OPPORTUNISTIC || policy == PROF_OTRPOLICY_ALWAYS) {
298298
if (whitespace_base) {
299-
if (strstr(message, OTRL_MESSAGE_TAG_V2) || strstr(message, OTRL_MESSAGE_TAG_V1)) {
299+
char* tag_position = whitespace_base + strlen(OTRL_MESSAGE_TAG_BASE);
300+
if (strncmp(tag_position, OTRL_MESSAGE_TAG_V2, strlen(OTRL_MESSAGE_TAG_V2)) == 0 || strncmp(tag_position, OTRL_MESSAGE_TAG_V1, strlen(OTRL_MESSAGE_TAG_V1)) == 0) {
300301
// Remove whitespace pattern for proper display in UI
301302
// Handle both BASE+TAGV1/2(16+8) and BASE+TAGV1+TAGV2(16+8+8)
302303
int tag_length = 24;

0 commit comments

Comments
 (0)