Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bestpractical/rt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsunnavy <sunnavy@bestpractical.com>2022-09-03 01:12:06 +0300
committersunnavy <sunnavy@bestpractical.com>2022-09-03 01:12:06 +0300
commit7e0ee709551c1c8d8be0e9895c007a795384d3d8 (patch)
treeee2a5bf352140667bbf247beff9c496678e00983
parentd32618f376b059f3442bb689acbda86cc1e2a8fa (diff)
parent434a45c7a14873280474e75627b6e60755e912c5 (diff)
Merge branch '4.4-trunk' into 5.0-trunk
-rw-r--r--.github/workflows/github-action.yml31
-rw-r--r--lib/RT/Attachment.pm10
-rw-r--r--t/mail/rfc822-attachment.t40
3 files changed, 61 insertions, 20 deletions
diff --git a/.github/workflows/github-action.yml b/.github/workflows/github-action.yml
index af95b96f39..f3d514c8bd 100644
--- a/.github/workflows/github-action.yml
+++ b/.github/workflows/github-action.yml
@@ -15,6 +15,12 @@ jobs:
echo "RT_GA_START_TIME=$(date +%s)" >> $GITHUB_ENV
- name: Check out RT
uses: actions/checkout@v2
+ - name: Cache .prove state
+ id: cache-prove-state
+ uses: actions/cache@v3
+ with:
+ path: .prove
+ key: ${{ runner.os }}-sqlite
- name: Build RT
shell: bash
run: |
@@ -23,8 +29,9 @@ jobs:
docker exec rt bash -c "cd /rt && ./configure.ac --with-db-type=SQLite --with-my-user-group --enable-layout=inplace --enable-developer --enable-externalauth --enable-gpg --enable-smime && mkdir -p /rt/var && make testdeps"
- name: Run RT tests
shell: bash
- run: docker exec rt bash -c "cd /rt && prove -rlj6 t/*"
+ run: docker exec rt bash -c "cd /rt && RT_TEST_PARALLEL_NUM=5 make test-parallel"
- name: Get run time
+ # Default is success(), we want to always() get the time
if: always()
shell: bash
run: |
@@ -37,7 +44,7 @@ jobs:
export RT_GA_TEST_TIME=$(date -u -d @"$RT_GA_TEST_TIME" +"%T")
echo "RT_GA_TEST_TIME=$RT_GA_TEST_TIME" >> $GITHUB_ENV
- name: Post results to Slack
- if: always()
+ if: ${{ always() && github.repository_owner == 'bestpractical' }}
uses: edge/simple-slack-notify@v1.1.1
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATIONS }}
@@ -60,6 +67,12 @@ jobs:
echo "RT_GA_START_TIME=$(date +%s)" >> $GITHUB_ENV
- name: Checkout RT
uses: actions/checkout@v2
+ - name: Cache .prove state
+ id: cache-prove-state
+ uses: actions/cache@v3
+ with:
+ path: .prove
+ key: ${{ runner.os }}-mariadb
- name: Build RT
shell: bash
run: |
@@ -70,7 +83,7 @@ jobs:
docker exec rt bash -c "cd /rt && ./configure.ac --with-db-type=mysql --with-my-user-group --enable-layout=inplace --enable-developer --enable-externalauth --enable-gpg --enable-smime && mkdir -p /rt/var && make testdeps"
- name: Run RT tests
shell: bash
- run: docker exec rt bash -c "cd /rt && prove -rlj6 t/*"
+ run: docker exec rt bash -c "cd /rt && RT_TEST_PARALLEL_NUM=5 make test-parallel"
- name: Get run time
if: always()
shell: bash
@@ -84,7 +97,7 @@ jobs:
export RT_GA_TEST_TIME=$(date -u -d @"$RT_GA_TEST_TIME" +"%T")
echo "RT_GA_TEST_TIME=$RT_GA_TEST_TIME" >> $GITHUB_ENV
- name: Post results to Slack
- if: always()
+ if: ${{ always() && github.repository_owner == 'bestpractical' }}
uses: edge/simple-slack-notify@v1.1.1
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATIONS }}
@@ -107,6 +120,12 @@ jobs:
echo "RT_GA_START_TIME=$(date +%s)" >> $GITHUB_ENV
- name: Checkout RT
uses: actions/checkout@v2
+ - name: Cache .prove state
+ id: cache-prove-state
+ uses: actions/cache@v3
+ with:
+ path: .prove
+ key: ${{ runner.os }}-pg-fcgid
- name: Build RT
shell: bash
run: |
@@ -118,7 +137,7 @@ jobs:
docker exec -e USER=rt-user -u rt-user rt bash -c "cd /rt && ./configure.ac --with-db-type=Pg --with-my-user-group --enable-layout=inplace --with-web-handler=fcgid --enable-developer --enable-externalauth --enable-gpg --enable-smime && mkdir -p /rt/var && make testdeps && chmod a+rX /rt/sbin/*"
- name: Run RT tests
shell: bash
- run: docker exec -e RT_DBA_USER=postgres -e RT_TEST_WEB_HANDLER=apache+fcgid -e HTTPD_ROOT=/etc/apache2 -e RT_TEST_APACHE=/usr/sbin/apache2 -e RT_TEST_APACHE_MODULES=/usr/lib/apache2/modules -u rt-user rt bash -c "cd /rt && prove -rlj6 t/*"
+ run: docker exec -e RT_DBA_USER=postgres -e RT_TEST_WEB_HANDLER=apache+fcgid -e HTTPD_ROOT=/etc/apache2 -e RT_TEST_APACHE=/usr/sbin/apache2 -e RT_TEST_APACHE_MODULES=/usr/lib/apache2/modules -u rt-user rt bash -c "cd /rt && RT_TEST_PARALLEL_NUM=5 make test-parallel"
- name: Get run time
if: always()
shell: bash
@@ -132,7 +151,7 @@ jobs:
export RT_GA_TEST_TIME=$(date -u -d @"$RT_GA_TEST_TIME" +"%T")
echo "RT_GA_TEST_TIME=$RT_GA_TEST_TIME" >> $GITHUB_ENV
- name: Post results to Slack
- if: always()
+ if: ${{ always() && github.repository_owner == 'bestpractical' }}
uses: edge/simple-slack-notify@v1.1.1
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATIONS }}
diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index b0b2fc66cc..8b6dc5ea0f 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -376,8 +376,14 @@ sub OriginalContent {
if ($self->IsMessageContentType) {
# There shouldn't be more than one "subpart" to a message/* attachment
my $child = $self->Children->First;
- return $self->Content unless $child and $child->id;
- return $child->ContentAsMIME(Children => 1)->as_string;
+ if ( $child and $child->id ) {
+ return $child->ContentAsMIME( Children => 1 )->as_string;
+ }
+ else {
+ # No children could happen if $TreatAttachedEmailAsFiles is true.
+ # Can't indiscriminately return $self->Content as it might be decoded(for textual messages).
+ # Leave it to the follwing code, which covers this case.
+ }
}
return $self->Content unless RT::I18N::IsTextualContentType($self->ContentType);
diff --git a/t/mail/rfc822-attachment.t b/t/mail/rfc822-attachment.t
index f498ec55ae..f66584f737 100644
--- a/t/mail/rfc822-attachment.t
+++ b/t/mail/rfc822-attachment.t
@@ -19,21 +19,24 @@ diag "simple rfc822 attachment";
From => 'foo@localhost',
To => 'bar@localhost',
Subject => 'rfc822',
- Data => ['rfc822 attachment'],
+ Data => ['rfc822 attachment 测试'],
+ Charset => 'UTF-8',
'X-Brokenness' => 'high',
);
$top->attach(
Data => $rfc822->stringify,
Type => 'message/rfc822',
+ Charset => 'UTF-8',
);
- my $parsed = content_as_mime($top);
-
- for my $mime ($top, $parsed) {
+ for my $mime ( $top, contents_as_mime($top) ) {
diag "testing mail";
is $mime->parts, 2, 'two mime parts';
+ eval { $mime->as_string };
+ ok( !$@, 'stringifying mime does not die' );
+
like $mime->head->get('Subject'), qr/this is top/, 'top subject';
like $mime->head->get('From'), qr/root\@localhost/, 'top From';
like $mime->parts(0)->bodyhandle->as_string, qr/top mail/, 'content of top';
@@ -42,7 +45,7 @@ diag "simple rfc822 attachment";
my $body = $attach->bodyhandle->as_string;
like $attach->head->mime_type, qr/message\/rfc822/, 'attach of type message/rfc822';
- like $body, qr/rfc822 attachment/, 'attach content';
+ like $body, qr/rfc822 attachment 测试/, 'attach content';
headers_like(
$attach,
@@ -67,25 +70,28 @@ diag "multipart rfc822 attachment";
From => 'foo@localhost',
To => 'bar@localhost',
Subject => 'rfc822',
- Data => ['rfc822 attachment'],
+ Data => ['rfc822 attachment 测试附件'],
+ Charset => 'UTF-8',
'X-Brokenness' => 'high',
);
$rfc822->attach(
- Data => '<b>attachment of rfc822 attachment</b>',
+ Data => ['<b>attachment of rfc822 attachment 测试</b>'],
Type => 'text/html',
+ Charset => 'UTF-8',
);
$top->attach(
Data => $rfc822->stringify,
Type => 'message/rfc822',
+ Charset => 'UTF-8',
);
-
- my $parsed = content_as_mime($top);
- for my $mime ($top, $parsed) {
+ for my $mime ( $top, contents_as_mime($top) ) {
diag "testing mail";
is $mime->parts, 2, 'two mime parts';
+ eval { $mime->as_string };
+ ok( !$@, 'stringifying mime does not die' );
like $mime->head->get('Subject'), qr/this is top/, 'top subject';
like $mime->head->get('From'), qr/root\@localhost/, 'top From';
@@ -95,8 +101,9 @@ diag "multipart rfc822 attachment";
my $body = $attach->bodyhandle->as_string;
like $attach->head->mime_type, qr/message\/rfc822/, 'attach of type message/rfc822';
- like $body, qr/rfc822 attachment/, 'attach content';
- like $body, qr/attachment of rfc822 attachment/, 'attach content';
+ like $body, qr/rfc822 attachment 测试附件/, 'attach content';
+
+ like $body, qr/attachment of rfc822 attachment 测试/, 'attach content';
headers_like(
$attach,
@@ -119,6 +126,15 @@ sub content_as_mime {
return RT::Test->last_ticket->Transactions->First->Attachments->First->ContentAsMIME(Children => 1);
}
+sub contents_as_mime {
+ my $entity = shift;
+ RT->Config->Set( 'TreatAttachedEmailAsFiles', 1 );
+ my @contents = content_as_mime($entity);
+ RT->Config->Set( 'TreatAttachedEmailAsFiles', 0 );
+ push @contents, content_as_mime($entity);
+ return @contents;
+}
+
sub headers_like {
my $attach = shift;
my %header = (@_);