Fix: mail collector attaches reply to the wrong ticket when subject holds a foreign reference - #25213
Open
Megachip wants to merge 9 commits into
Open
Fix: mail collector attaches reply to the wrong ticket when subject holds a foreign reference#25213Megachip wants to merge 9 commits into
Megachip wants to merge 9 commits into
Conversation
#BUG On location view, I can assign documents to a location, on document view there is no option to choose a location
Fix: mail collector attaches reply to the wrong ticket when subject holds a foreign reference
Added a test case for GLPI subject fallback handling.
trasher
approved these changes
Aug 21, 2026
trasher
requested changes
Aug 21, 2026
Contributor
There was a problem hiding this comment.
Please fix and add test case following @AdrienClairembault comments
Member
Rom1-B
reviewed
Aug 21, 2026
Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
Match ticket id against configured notification subject tags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
Description
When matching an incoming reply to an existing ticket via the subject, the
fallback pattern
\[.+#(\d+)\]inMailCollector::getItemFromHeaders()wasgreedy and could span several bracketed tokens. If the subject contained a
second, unrelated reference — e.g. a hoster's
[Ticket#2026072803024161]— GLPIextracted that number instead of its own
[<tag> #<id>]id.getFromDB()then failed on the non-existent id and a new ticket was created instead of
adding a followup to the existing one.
Example subject that triggered it:
Re: [B45 #0000054] [Ticket#2026072803024161] DNS Request→ matched
2026072803024161instead of0000054.Fix: restrict the pattern to a single bracketed token (
[^\]]) and requirethe whitespace that GLPI always inserts before
#when building the subject(see
NotificationTargetCommonITILObject). Foreign[Ticket#...]referenceswithout that space are ignored, and the correct id is matched regardless of its
position in the subject. A regression test is added.