[Rt-commit] rt branch, 4.4/munge-more-attachments, updated. rt-4.4.3-199-gd62e36c75
? sunnavy
sunnavy at bestpractical.com
Wed Jan 23 16:24:37 EST 2019
The branch, 4.4/munge-more-attachments has been updated
via d62e36c75ee6d3037b37255c8820d5828a5f23a1 (commit)
from a342442b329311d1cc82179aa973fc31f9758312 (commit)
Summary of changes:
lib/RT/Attachment.pm | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
- Log -----------------------------------------------------------------
commit d62e36c75ee6d3037b37255c8820d5828a5f23a1
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jan 24 05:12:13 2019 +0800
Re-encode decoded attachment content on update for content replacement
As we substitute the decoded content, to store it back to db, we need to
encode it first accordingly.
diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index ed9771e1c..e443020d2 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -800,7 +800,28 @@ sub ReplaceContent {
my $content = $self->Content;
if ( $content && $content =~ s/\Q$args{Search}\E/$args{Replacement}/ig ) {
- my ( $ret, $msg ) = $self->_Set( Field => 'Content', Value => $content );
+ my ( $encoding, $encoded_content, undef, undef, $note_args )
+ = $self->_EncodeLOB( Encode::encode( 'UTF-8', $content ) );
+
+ $RT::Handle->BeginTransaction;
+ if ($note_args) {
+ $self->TransactionObj->Object->_NewTransaction(%$note_args);
+ }
+
+ my ( $ret, $msg ) = $self->_Set( Field => 'Content', Value => $encoded_content );
+ unless ($ret) {
+ $RT::Handle->Rollback;
+ return ( $ret, $msg );
+ }
+
+ if ( ( $self->ContentEncoding // '' ) ne $encoding ) {
+ my ( $ret, $msg ) = $self->_Set( Field => 'ContentEncoding', Value => $encoding );
+ unless ($ret) {
+ $RT::Handle->Rollback;
+ return ( $ret, $msg );
+ }
+ }
+ $RT::Handle->Commit;
return ( $ret, 'Content replaced' );
}
return ( 1, $self->loc('No content matches found') );
-----------------------------------------------------------------------
More information about the rt-commit
mailing list