From b0dab0ed1e52448033555fc6781d30bc645d2aea Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Thu, 3 Oct 2024 15:57:22 +0200 Subject: [PATCH 1/2] Don't try to upload code coverage report if CODECOV_TOKEN secret is absent --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cf4c7120a8..80701d44b2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -168,7 +168,7 @@ jobs: run: vendor/bin/phpunit - name: Send coverage report to Codecov - if: ${{ success() && matrix.coverage == true }} + if: ${{ success() && matrix.coverage == true && env.token != '' }} uses: codecov/codecov-action@v3 with: files: ./build/logs/clover.xml @@ -176,3 +176,5 @@ jobs: verbose: true # see https://github.com/codecov/codecov-action/issues/557 token: ${{ secrets.CODECOV_TOKEN }} + env: + token: ${{secrets.TESTKEY1}} From 6182c50348f66edab79c86df4e3e8e65be574517 Mon Sep 17 00:00:00 2001 From: Bart Butler Date: Thu, 21 May 2020 15:00:57 -0700 Subject: [PATCH 2/2] Add Content-Location attachment header support --- src/PHPMailer.php | 30 +++++++++++++++---- test/PHPMailer/AddEmbeddedImageTest.php | 1 + test/PHPMailer/AddStringAttachmentTest.php | 1 + test/PHPMailer/AddStringEmbeddedImageTest.php | 1 + 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/PHPMailer.php b/src/PHPMailer.php index ba4bcd4728..763599be09 100644 --- a/src/PHPMailer.php +++ b/src/PHPMailer.php @@ -60,6 +60,9 @@ class PHPMailer const ICAL_METHOD_COUNTER = 'COUNTER'; const ICAL_METHOD_DECLINECOUNTER = 'DECLINECOUNTER'; + const CONTENT_ID = 'Content-ID'; + const CONTENT_LOCATION = 'Content-Location'; + /** * Email priority. * Options: null (default), 1 = High, 3 = Normal, 5 = low. @@ -3292,6 +3295,7 @@ public function addAttachment( 5 => false, //isStringAttachment 6 => $disposition, 7 => $name, + 8 => static::CONTENT_ID, ]; } catch (Exception $exc) { $this->setError($exc->getMessage()); @@ -3358,6 +3362,7 @@ protected function attachAll($disposition_type, $boundary) $type = $attachment[4]; $disposition = $attachment[6]; $cid = $attachment[7]; + $cidType = $attachment[8]; if ('inline' === $disposition && array_key_exists($cid, $cidUniq)) { continue; } @@ -3384,9 +3389,17 @@ protected function attachAll($disposition_type, $boundary) $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, static::$LE); } - //Only set Content-IDs on inline attachments - if ((string) $cid !== '' && $disposition === 'inline') { - $mime[] = 'Content-ID: <' . $this->encodeHeader($this->secureHeader($cid)) . '>' . static::$LE; + //Only set Content-ID/Content-Location headers on inline attachments + if ( + (string) $cid !== '' + && $disposition === 'inline' + && in_array($cidType, [static::CONTENT_ID, static::CONTENT_LOCATION], true) + ) { + $encodedCid = $this->encodeHeader($this->secureHeader($cid)); + if ($cidType === static::CONTENT_ID) { + $encodedCid = '<' . $encodedCid . '>'; + } + $mime[] = $cidType . ': ' . $encodedCid . static::$LE; } //Allow for bypassing the Content-Disposition header @@ -3782,6 +3795,7 @@ public function addStringAttachment( 5 => true, //isStringAttachment 6 => $disposition, 7 => 0, + 8 => '', ]; } catch (Exception $exc) { $this->setError($exc->getMessage()); @@ -3813,6 +3827,7 @@ public function addStringAttachment( * @param string $type File MIME type (by default mapped from the `$path` filename's extension) * @param string $disposition Disposition to use: `inline` (default) or `attachment` * (unlikely you want this – {@see `addAttachment()`} instead) + * @param string $cidType static::CONTENT_ID (default) or static::CONTENT_LOCATION * * @return bool True on successfully adding an attachment * @throws Exception @@ -3824,7 +3839,8 @@ public function addEmbeddedImage( $name = '', $encoding = self::ENCODING_BASE64, $type = '', - $disposition = 'inline' + $disposition = 'inline', + $cidType = self::CONTENT_ID ) { try { if (!static::fileIsAccessible($path)) { @@ -3855,6 +3871,7 @@ public function addEmbeddedImage( 5 => false, //isStringAttachment 6 => $disposition, 7 => $cid, + 8 => $cidType, ]; } catch (Exception $exc) { $this->setError($exc->getMessage()); @@ -3883,6 +3900,7 @@ public function addEmbeddedImage( * @param string $encoding File encoding (see $Encoding), defaults to 'base64' * @param string $type MIME type - will be used in preference to any automatically derived type * @param string $disposition Disposition to use + * @param string $cidType static::CONTENT_ID (default) or static::CONTENT_LOCATION * * @throws Exception * @@ -3894,7 +3912,8 @@ public function addStringEmbeddedImage( $name = '', $encoding = self::ENCODING_BASE64, $type = '', - $disposition = 'inline' + $disposition = 'inline', + $cidType = self::CONTENT_ID ) { try { //If a MIME type is not specified, try to work it out from the name @@ -3916,6 +3935,7 @@ public function addStringEmbeddedImage( 5 => true, //isStringAttachment 6 => $disposition, 7 => $cid, + 8 => $cidType, ]; } catch (Exception $exc) { $this->setError($exc->getMessage()); diff --git a/test/PHPMailer/AddEmbeddedImageTest.php b/test/PHPMailer/AddEmbeddedImageTest.php index f3a9906c7f..e288db31bc 100644 --- a/test/PHPMailer/AddEmbeddedImageTest.php +++ b/test/PHPMailer/AddEmbeddedImageTest.php @@ -42,6 +42,7 @@ public function testAddEmbeddedImage() 5 => false, 6 => 'inline', 7 => 'my-attach', + 8 => 'Content-ID', ]; $this->Mail->Body = 'Embedded Image: