From 9b04db8503c2cf4501bf88d588e2b901916c7490 Mon Sep 17 00:00:00 2001 From: yehudah Date: Thu, 26 Sep 2019 07:29:28 +0000 Subject: 2.0.5 released - Few notifications errors, export logs and minor improvements --- .../registered-domain-libs-master/.gitignore | 3 -- .../vendor/google/apiclient-services/.gitignore | 4 -- .../vendor/google/auth/.gitignore | 3 -- .../google-api-client/vendor/psr/log/.gitignore | 1 - .../mailgun/vendor/clue/stream-filter/.gitignore | 2 - .../vendor/symfony/options-resolver/.gitignore | 3 -- .../mailgun/vendor/webmozart/assert/.gitignore | 2 - Postman/Postman-Mail/sendgrid/.gitignore | 7 --- .../vendor/sendgrid/php-http-client/.gitignore | 11 ---- .../sendgrid/vendor/sendgrid/sendgrid/.gitignore | 19 ------- Postman/PostmanLogFields.php | 62 ++++++++++++++++++---- Postman/PostmanViewController.php | 4 +- postman-smtp.php | 7 ++- readme.txt | 9 ++-- 14 files changed, 64 insertions(+), 73 deletions(-) delete mode 100644 Postman/Postman-Connectivity-Test/registered-domain-libs-master/.gitignore delete mode 100644 Postman/Postman-Mail/google-api-client/vendor/google/apiclient-services/.gitignore delete mode 100644 Postman/Postman-Mail/google-api-client/vendor/google/auth/.gitignore delete mode 100644 Postman/Postman-Mail/google-api-client/vendor/psr/log/.gitignore delete mode 100644 Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.gitignore delete mode 100644 Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/.gitignore delete mode 100644 Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.gitignore delete mode 100644 Postman/Postman-Mail/sendgrid/.gitignore delete mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.gitignore delete mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.gitignore diff --git a/Postman/Postman-Connectivity-Test/registered-domain-libs-master/.gitignore b/Postman/Postman-Connectivity-Test/registered-domain-libs-master/.gitignore deleted file mode 100644 index 7886a27..0000000 --- a/Postman/Postman-Connectivity-Test/registered-domain-libs-master/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -C/*.o -C/libregdom.so.1 -C/test-regdom diff --git a/Postman/Postman-Mail/google-api-client/vendor/google/apiclient-services/.gitignore b/Postman/Postman-Mail/google-api-client/vendor/google/apiclient-services/.gitignore deleted file mode 100644 index 01150f6..0000000 --- a/Postman/Postman-Mail/google-api-client/vendor/google/apiclient-services/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -vendor -composer.lock -src/Google/Service/Compute/HTTPHealthCheck.php -src/Google/Service/Compute/HTTPSHealthCheck.php diff --git a/Postman/Postman-Mail/google-api-client/vendor/google/auth/.gitignore b/Postman/Postman-Mail/google-api-client/vendor/google/auth/.gitignore deleted file mode 100644 index 1cb030a..0000000 --- a/Postman/Postman-Mail/google-api-client/vendor/google/auth/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*~ -vendor -composer.lock diff --git a/Postman/Postman-Mail/google-api-client/vendor/psr/log/.gitignore b/Postman/Postman-Mail/google-api-client/vendor/psr/log/.gitignore deleted file mode 100644 index 22d0d82..0000000 --- a/Postman/Postman-Mail/google-api-client/vendor/psr/log/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendor diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.gitignore b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.gitignore deleted file mode 100644 index de4a392..0000000 --- a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/vendor -/composer.lock diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/.gitignore b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/.gitignore deleted file mode 100644 index c49a5d8..0000000 --- a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.gitignore b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.gitignore deleted file mode 100644 index 3a9875b..0000000 --- a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/vendor/ -composer.lock diff --git a/Postman/Postman-Mail/sendgrid/.gitignore b/Postman/Postman-Mail/sendgrid/.gitignore deleted file mode 100644 index 6df0272..0000000 --- a/Postman/Postman-Mail/sendgrid/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -test/coverage/* -examples/* -dist/ -composer.lock -vendor -.env* -sendgrid-php.php diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.gitignore b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.gitignore deleted file mode 100644 index b90ffc5..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -# Composer -vendor/ -*.phar -*.lock - -# Jetbrains Idea -*.old -.idea/ - -# Environment files -.env/*.* \ No newline at end of file diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.gitignore b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.gitignore deleted file mode 100644 index efe514c..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -test/coverage/* -dist/ -composer.lock -vendor -.env -sendgrid.env -composer.phar -.editorconfig -test.php -.idea/ -test/prism_linux_amd64 -test/prism/* -!test/prim -*.code-workspace -.vscode -prism* -temp.php -example*.php -TODO.txt diff --git a/Postman/PostmanLogFields.php b/Postman/PostmanLogFields.php index 6e04b8d..04d24a4 100644 --- a/Postman/PostmanLogFields.php +++ b/Postman/PostmanLogFields.php @@ -3,17 +3,17 @@ class PostmanLogFields { private $fields = array( 'success' => 'sanitize_text_field', - 'from_header' => '', - 'to_header' => '', - 'cc_header' => '', - 'bcc_header' => '', - 'reply_to_header' => '', + 'from_header' => [ 'PostmanLogFields', 'email_header_sanitize' ], + 'to_header' => [ 'PostmanLogFields', 'email_header_sanitize' ], + 'cc_header' => [ 'PostmanLogFields', 'email_header_sanitize' ], + 'bcc_header' => [ 'PostmanLogFields', 'email_header_sanitize' ], + 'reply_to_header' => [ 'PostmanLogFields', 'email_header_sanitize' ], 'transport_uri' => 'sanitize_text_field', 'original_to' => 'sanitize_text_field', 'original_subject' => 'sanitize_text_field', - 'original_message' => null, - 'original_headers' => 'sanitize_text_field', - 'session_transcript' => 'sanitize_textarea_field', + 'original_message' => '', // only sent to viewed + 'original_headers' => '', // only sent to viewed + 'session_transcript' => '', // escaped when viewed ); private static $instance = null; @@ -28,7 +28,7 @@ class PostmanLogFields { private function __construct() { - $this->fields['original_message'] = array( $this, 'sanitize_message' ); + } public function get( $post_id ) { @@ -73,13 +73,14 @@ class PostmanLogFields { } private function sanitize( $key, $value ) { + $callback = is_array( $value ) ? 'array_map' : 'call_user_func'; if ( ! empty( $this->fields[$key] ) ) { return $callback( $this->fields[$key], $value ); } - return filter_var( $value, FILTER_SANITIZE_STRING | FILTER_SANITIZE_SPECIAL_CHARS ); + return $value; } private function sanitize_message( $message ) { @@ -96,4 +97,43 @@ class PostmanLogFields { return $value; } -} \ No newline at end of file + + public function get_string_between($string, $start, $end){ + $string = ' ' . $string; + $ini = strpos($string, $start); + + if ($ini == 0) { + return ''; + } + + $ini += strlen($start); + $len = strpos($string, $end, $ini) - $ini; + + return substr($string, $ini, $len); + } + + public function email_header_sanitize($value) { + + $parts = explode( ',', $value ); + + $sanitized = []; + foreach ( $parts as $part ) { + + if ( strpos( $part, '<' ) !== false ) { + $email = $this->get_string_between( $part, '<', '>' ); + $clean_email = $this->sanitize_email($email); + preg_match('/(.*)"; + } + } + + return ! empty( $sanitized ) ? implode( ',', $sanitized ) : implode( ',', array_map( [ $this, 'sanitize_email'], $parts ) ); + } + + public function sanitize_email( $email ) { + return filter_var( $email, FILTER_SANITIZE_EMAIL ); + } +} + diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php index 050033f..dfd4207 100644 --- a/Postman/PostmanViewController.php +++ b/Postman/PostmanViewController.php @@ -319,11 +319,11 @@ if ( ! class_exists( 'PostmanViewController' ) ) { $show = get_option('postman_release_version' ); printf( '

%s

', sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ) ); - if ( ! $show ) { + if ( ! $show && POST_SMTP_SHOW_RELEASE_MESSAGE ) { echo '

- Version ' . $version . ' Sendgrid code fix and default delivery changes: Read Here + Version ' . $version . ' ' . POST_SMTP_RELEASE_MESSAGE . ': Read Here