From a74d9a5cfaabca8e941f2da81b434d488dd7d68e Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 31 Dec 2013 12:01:13 -0600
Subject: [PATCH] Honor ticket number in subject line without brackets

We introduced a glitch in 29b3714, which was the patch that introduced
matching on email headers other than the Subject.

I misinterpreted the original `preg_match()` regex, thinking that it was
requiring brackets. Looking at it again today, I see that it didn't. The
current one does, however, require surrounding brackets.

This patch also allows for extra letters or dashes between the `#` and the
ticket number. Eventually we should allow the ticket number itself to have
extra characters -- be formattable.

Fixes osTicket/osTicket-1.8#342
---
 include/class.thread.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/class.thread.php b/include/class.thread.php
index fb1e1431a..34c5e14a6 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -728,7 +728,7 @@ Class ThreadEntry {
         $subject = $mailinfo['subject'];
         $match = array();
         if ($subject && $mailinfo['email']
-                && preg_match("/\[#([0-9]{1,10})\]/", $subject, $match)
+                && preg_match("/#[\p{L}-]+?([0-9]{1,10})/u", $subject, $match)
                 && ($tid = Ticket::getIdByExtId((int)$match[1], $mailinfo['email']))
                 )
             // Return last message for the thread
-- 
GitLab