[Rt-commit] rt branch, 5.0/rest2-base64-encode-attachment-content, repushed
Dianne Skoll
dianne at bestpractical.com
Wed Oct 21 15:48:37 EDT 2020
The branch 5.0/rest2-base64-encode-attachment-content was deleted and repushed:
was e75be21c8e4bee4c7e6d535cba1b55b21ab8ad33
now 8e58a3f43d3d13ac3bdc60f44de9446f71c31b4f
1: 9976d75124 ! 1: f1724f9566 Make GET .../REST2/attachment/:id base64-encode the Content field.
@@ -25,11 +25,11 @@
+ my ($orig, $self) = @_;
+ my $data = $self->$orig(@_);
+
-+ # Encode as UTF-8 if it's textual content, OR if the raw data
++ # Encode as UTF-8 if it's an internal Perl Unicode string, or if it
+ # contains wide characters. If the raw data does indeed contain
-+ # wide characters, encode_base64 will die anyway
-+ if (RT::I18N::IsTextualContentType($self->record->ContentType) ||
-+ $data->{Content} =~ /[^\x00-\xFF]/) {
++ # wide characters, encode_base64 will die anyway, so encoding
++ # seems like a safer choice.
++ if (utf8::is_utf8($data->{Content}) || $data->{Content} =~ /[^\x00-\xFF]/) {
+ # Encode internal Perl string to UTF-8
+ $data->{Content} = encode('UTF-8', $data->{Content}, Encode::FB_PERLQQ);
+ }
2: e75be21c8e = 2: 8e58a3f43d Document that GET /attachment/:id base64-encodes the content.
More information about the rt-commit
mailing list