RT6 Inline Images Broken by rtname Containing Whitespace

Hello, I’ve noticed that RT6’s new inline images do not work when the rtname directive contains whitespace. It looks like it breaks the translation in naming from “cid” format to “Attachment”.

Pasted image 20250916121157.png

In the above screenshot, the lower comment includes an inline image which was created when rtname was “RT6 TEST”, containing a space, and results in a broken image link being inserted. The upper comment was made after changing rtname to “RT6_TEST” and restarting the server, and results in the image being inserted as expected.

I’m wondering, is this something that might be fixed, to account for rtnames which contain whitespace? Or is there any workaround to use inline images without changing rtname?

I’m aware of EmailSubjectTagRegex, but I’d prefer to keep our current rtname which contains a space, if possible.

2 Likes

Yes, I’m also encountering this bug in RT 6.0.0. Our RT name also has a space and I’d rather not have to change it as a workaround….

hi guys.I hope this helps. I have created a hotfix by applying the following code to the Web.pm file.

You should modify the ”sub RewriteInlineImages” function. Obviously, this is a temporary fix while we wait for an official patch in the new version.

# --- HOTFIX: tolerate spaces or altered CIDs (rtname with whitespace) ---

my $cid_clean = $cid;
$cid_clean =~ s/\s+//g;
$cid_clean =~ s/%20//g;
$cid_clean =~ s/@.*//;

for my $attach (@{$args{Related}}) {
    my $content_id = ($attach->GetHeader("Content-ID") || "");
    $content_id =~ s/[<>]//g;
    $content_id =~ s/\s+//g;
    $content_id =~ s/%20//g;
    $content_id =~ s/@.*//;

    if (lc($content_id) eq lc($cid_clean)) {
        push @rewritten, $attach->Id;
        RT->Logger->debug("Matched inline image for cleaned cid=$cid_clean (Attachment " . $attach->Id . ")");
        return "$args{AttachmentPath}/" . $attach->TransactionId . "/" . $attach->Id;
    }
}

# No attachments means this is a bogus CID
RT->Logger->debug(qq[Found bogus inline image src="cid:$cid"]);
return "cid:$cid";

Greetings!

After further investigating this error, I found the solution.

When the $rtname variable contains a blank space, the inline images you send are broken due to the way rt parses this variable, resulting in the email recipient being unable to view the images because they are not referenced correctly. To temporarily resolve the issue, you must apply the following code to the RT/Interface/Web.pm file on line 2442 of the ExtractImages function.

sub ExtractImages {
    my %args = (
        Content     => undef,
        CurrentUser => $HTML::Mason::Commands::session{CurrentUser},
        @_,
    );

    my $content = $args{Content};
    my ( @images, %added );
    require HTML::RewriteAttributes::Resources;
    $content = HTML::RewriteAttributes::Resources->rewrite(
        $content,
        sub {
            my $uri  = shift;
            my %meta = @_;
            return $uri unless lc $meta{tag} eq 'img' && lc $meta{attr} eq 'src';

            my ( $content_type, $content );
            if ( $uri =~ m{^data:(.+);base64,(.+)}s ) {
                $content_type = $1;
                $content      = decode_base64($2);
            }
            elsif ( $uri =~ m{^/(?:SelfService|Ticket)/Attachment/\d+/(\d+)} ) {
                my $attachment = RT::Attachment->new( $args{CurrentUser} );
                $attachment->Load($1);
                if ( $attachment->CurrentUserCanSee ) {
                    $content_type = $attachment->ContentType;
                    $content      = $attachment->Content;
                }
                else {
                    RT->Logger->warning( "Attachment #$1 is not visible to current user #" . $args{CurrentUser}->Id );
                }
            }

            if ($content) {

                ## HOTFIX rtname containing whitespace
                my $rtnameclean = RT->Config->Get('rtname');
                $rtnameclean =~ s/\s/_/g ;
                my $cid = sha1_hex($content) . '@' . $rtnameclean;
                push @images, { cid => $cid, content => $content, content_type => $content_type } unless $added{$cid}++;
                return "cid:$cid";
            }

            return $uri;
        }
    );
    return ( $content, @images );
}

I hope this helps, and I will be happy to answer any questions you may have.

Can the broken inline images cause RT to hang on reply or comment ?
Our RT Instance has whitespaces.

We are encountering issues with some tickets with attachments, which hang on reply / comment

I didn’t encounter that error. In my case, the broken image simply appeared and the email recipient couldn’t see it, but it didn’t crash. However, if you can attach the logs so I can take a look, I can help you out.

Attaching the RT and apache error logs.

Kiran from our team has raised a separate one, but I thought is it related to whitepsace in RTNAME so checking.

RT.LOG
ON Comment

[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: About to prepare scrips for transaction #54165 (/opt/rt6/sbin/../lib/RT/Transaction.pm:273)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Found 4 scrips for TransactionCreate stage with applicable type(s) Comment for txn #54165 on ticket #2734 (/opt/rt6/sbin/../lib/RT/Scrips.pm:537)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Skipping Scrip #11 because it isn’t applicable (/opt/rt6/sbin/../lib/RT/Scrips.pm:380)
[82114] [Tue Jan 20 08:32:26 2026] [debug]: Found 0 scrips for TransactionBatch stage with applicable type(s) Comment for txn #54165 on ticket #2734 (/opt/rt6/sbin/../lib/RT/Scrips.pm:537)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: About to prepare scrips for transaction #54166 (/opt/rt6/sbin/../lib/RT/Transaction.pm:273)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Found 4 scrips for TransactionCreate stage with applicable type(s) Comment for txn #54166 on ticket #2734 (/opt/rt6/sbin/../lib/RT/Scrips.pm:537)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Skipping Scrip #11 because it isn’t applicable (/opt/rt6/sbin/../lib/RT/Scrips.pm:380)
[80613] [Tue Jan 20 08:32:26 2026] [debug]: Found 0 scrips for TransactionBatch stage with applicable type(s) Comment for txn #54166 on ticket #2734 (/opt/rt6/sbin/../lib/RT/Scrips.pm:537)

– ON REPLY

[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: About to prepare scrips for transaction #54167 (/opt/rt6/sbin/../lib/RT/Transaction.pm:273)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Found 7 scrips for TransactionCreate stage with applicable type(s) Correspond for txn #54167 on ticket #2734 (/opt/rt6/sbin/../lib/RT/Scrips.pm:537)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [info]: rt-6.0.2-80613-1768898020-1750.2734-5-0@www.example.com CSupport@axistemp.com is blacklisted by notification checkboxes on this ticket’s People page. Skipping (/opt/rt6/sbin/../lib/RT/Action/SendEmail.pm:913)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Skipping Scrip #6 because it didn’t Prepare (/opt/rt6/sbin/../lib/RT/Scrips.pm:394)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Skipping Scrip #11 because it isn’t applicable (/opt/rt6/sbin/../lib/RT/Scrips.pm:380)
[80613] [Tue Jan 20 08:33:40 2026] [debug]: Found 0 scrips for TransactionBatch stage with applicable type(s) Correspond for txn #54167 on ticket #2734 (/opt/rt6/sbin/../lib/RT/Scrips.pm:537)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: About to prepare scrips for transaction #54168 (/opt/rt6/sbin/../lib/RT/Transaction.pm:273)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Found 7 scrips for TransactionCreate stage with applicable type(s) Correspond for txn #54168 on ticket #2734 (/opt/rt6/sbin/../lib/RT/Scrips.pm:537)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/plain - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Converting ‘utf-8’ to ‘utf-8’ for text/html - Subjectless message (/opt/rt6/sbin/../lib/RT/I18N.pm:294)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:40 2026] [debug]: Encode::Guess guessed encoding: ascii (/opt/rt6/sbin/../lib/RT/I18N.pm:583)
[82114] [Tue Jan 20 08:33:41 2026] [info]: rt-6.0.2-82114-1768898021-1160.2734-5-0@www.example.com CSupport@axistemp.com is blacklisted by notification checkboxes on this ticket’s People page. Skipping (/opt/rt6/sbin/../lib/RT/Action/SendEmail.pm:913)

From what I can see in your colleague’s other post, it only happens with specific tickets: “We have a test instance of RT where we only get an error for a single ticket.” This has happened to me on occasion when attaching a file, for example, an Excel file with lots of IP addresses. RT uses internal scripts that detect those IP addresses and place them in the “Networking” field. What I mean is that if this option is enabled and the file is large, it can crash because it is processing a large number of actions in the background. What content does the ticket have? Is it a simple ticket? Are you using the RTIR plugin? Is it a clean installation or an upgrade from another version?
If a file is being attached to that ticket, I would try to check all the scripts in the configuration that may be reading and performing actions in the background. If it is not related to the attachments, I would try to find a pattern in those tickets that crash and run tests in a controlled environment.

In any case, I don’t think it’s related to the problem of misreferenced images.

Thanks Alberto

The ticket has standard attachments (PDF, PNG, JPG) no networking information.
One thing we observed is this ticket has a linked ticket which has been resolved. Digging further, thanks for the pointer.

We do not use RTIR and do not have that plugin enabled.
It is 6.0.1 installation recently upgraded to 6.0.2 but the issue persists from before.

Will check each attribute in detail as you have suggested. We are a bit weak on perl scrip debugging.

Any tips, commands or scripts that you can share for troubleshooting most appreciated. :folded_hands: