From 4e8546cc57df78079e9a2a96647810c1e9e69db5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 7 Jun 2018 13:49:27 +0000 Subject: [PATCH 1/2] Bump swiftmailer/swiftmailer from 5.4.8 to 6.0.2 Bumps [swiftmailer/swiftmailer](https://github.com/swiftmailer/swiftmailer) from 5.4.8 to 6.0.2. - [Release notes](https://github.com/swiftmailer/swiftmailer/releases) - [Changelog](https://github.com/swiftmailer/swiftmailer/blob/master/CHANGES) - [Commits](https://github.com/swiftmailer/swiftmailer/compare/v5.4.8...v6.0.2) Signed-off-by: dependabot[bot] --- composer.json | 2 +- composer.lock | 78 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 69 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 66a788e34..805797f65 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "punic/punic": "^1.6", "sabre/dav": "^3.2.0", "stecman/symfony-console-completion": "^0.7.0", - "swiftmailer/swiftmailer": "^5.4", + "swiftmailer/swiftmailer": "^6.0", "symfony/console": "3.4.11", "symfony/event-dispatcher": "3.4.11", "symfony/process": "3.4.11", diff --git a/composer.lock b/composer.lock index d3e6bf690..e9741dcf4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e7b1c240bf0e98f9d0f279d2a8abc5ad", + "content-hash": "f3acd0cf49d469ff33383e5ebecb0db7", "packages": [ { "name": "aws/aws-sdk-php", @@ -705,6 +705,63 @@ ], "time": "2014-09-09T13:34:57+00:00" }, + { + "name": "egulias/email-validator", + "version": "2.1.4", + "source": { + "type": "git", + "url": "https://github.com/egulias/EmailValidator.git", + "reference": "8790f594151ca6a2010c6218e09d96df67173ad3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/8790f594151ca6a2010c6218e09d96df67173ad3", + "reference": "8790f594151ca6a2010c6218e09d96df67173ad3", + "shasum": "" + }, + "require": { + "doctrine/lexer": "^1.0.1", + "php": ">= 5.5" + }, + "require-dev": { + "dominicsayers/isemail": "dev-master", + "phpunit/phpunit": "^4.8.35||^5.7||^6.0", + "satooshi/php-coveralls": "^1.0.1" + }, + "suggest": { + "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Egulias\\EmailValidator\\": "EmailValidator" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eduardo Gulias Davis" + } + ], + "description": "A library for validating emails against several RFCs", + "homepage": "https://github.com/egulias/EmailValidator", + "keywords": [ + "email", + "emailvalidation", + "emailvalidator", + "validation", + "validator" + ], + "time": "2018-04-10T10:11:19+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "6.3.0", @@ -2885,29 +2942,30 @@ }, { "name": "swiftmailer/swiftmailer", - "version": "v5.4.8", + "version": "v6.0.2", "source": { "type": "git", "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "9a06dc570a0367850280eefd3f1dc2da45aef517" + "reference": "412333372fb6c8ffb65496a2bbd7321af75733fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/9a06dc570a0367850280eefd3f1dc2da45aef517", - "reference": "9a06dc570a0367850280eefd3f1dc2da45aef517", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/412333372fb6c8ffb65496a2bbd7321af75733fc", + "reference": "412333372fb6c8ffb65496a2bbd7321af75733fc", "shasum": "" }, "require": { - "php": ">=5.3.3" + "egulias/email-validator": "~2.0", + "php": ">=7.0.0" }, "require-dev": { "mockery/mockery": "~0.9.1", - "symfony/phpunit-bridge": "~3.2" + "symfony/phpunit-bridge": "~3.3@dev" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.4-dev" + "dev-master": "6.0-dev" } }, "autoload": { @@ -2929,13 +2987,13 @@ } ], "description": "Swiftmailer, free feature-rich PHP mailer", - "homepage": "http://swiftmailer.org", + "homepage": "http://swiftmailer.symfony.com", "keywords": [ "email", "mail", "mailer" ], - "time": "2017-05-01T15:54:03+00:00" + "time": "2017-09-30T22:39:41+00:00" }, { "name": "symfony/console", From da8e24b48079cec2f9c8be950f7b996bce172190 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 7 Jun 2018 16:34:44 +0200 Subject: [PATCH 2/2] Actually update swiftmailer Signed-off-by: Roeland Jago Douma --- composer/autoload_classmap.php | 63 +++ composer/autoload_psr4.php | 1 + composer/autoload_static.php | 71 ++++ composer/installed.json | 80 +++- .../EmailValidator/EmailLexer.php | 221 ++++++++++ .../EmailValidator/EmailParser.php | 104 +++++ .../EmailValidator/EmailValidator.php | 67 ++++ .../Exception/AtextAfterCFWS.php | 9 + .../EmailValidator/Exception/CRLFAtTheEnd.php | 9 + .../EmailValidator/Exception/CRLFX2.php | 9 + .../EmailValidator/Exception/CRNoLF.php | 9 + .../Exception/CharNotAllowed.php | 9 + .../Exception/CommaInDomain.php | 9 + .../Exception/ConsecutiveAt.php | 9 + .../Exception/ConsecutiveDot.php | 9 + .../Exception/DomainHyphened.php | 9 + .../EmailValidator/Exception/DotAtEnd.php | 9 + .../EmailValidator/Exception/DotAtStart.php | 9 + .../EmailValidator/Exception/ExpectingAT.php | 9 + .../Exception/ExpectingATEXT.php | 9 + .../Exception/ExpectingCTEXT.php | 9 + .../Exception/ExpectingDTEXT.php | 9 + .../Exception/ExpectingDomainLiteralClose.php | 9 + .../Exception/ExpectingQPair.php | 9 + .../EmailValidator/Exception/InvalidEmail.php | 14 + .../EmailValidator/Exception/NoDNSRecord.php | 11 + .../EmailValidator/Exception/NoDomainPart.php | 9 + .../EmailValidator/Exception/NoLocalPart.php | 9 + .../Exception/UnclosedComment.php | 9 + .../Exception/UnclosedQuotedString.php | 9 + .../Exception/UnopenedComment.php | 9 + .../EmailValidator/Parser/DomainPart.php | 368 +++++++++++++++++ .../EmailValidator/Parser/LocalPart.php | 138 +++++++ .../EmailValidator/Parser/Parser.php | 215 ++++++++++ .../Validation/DNSCheckValidation.php | 61 +++ .../Validation/EmailValidation.php | 34 ++ .../Validation/Error/RFCWarnings.php | 11 + .../Validation/Error/SpoofEmail.php | 11 + .../Exception/EmptyValidationList.php | 13 + .../Validation/MultipleErrors.php | 26 ++ .../Validation/MultipleValidationWithAnd.php | 110 +++++ .../Validation/NoRFCWarningsValidation.php | 41 ++ .../Validation/RFCValidation.php | 49 +++ .../Validation/SpoofCheckValidation.php | 45 +++ .../EmailValidator/Warning/AddressLiteral.php | 14 + .../EmailValidator/Warning/CFWSNearAt.php | 13 + .../EmailValidator/Warning/CFWSWithFWS.php | 13 + .../EmailValidator/Warning/Comment.php | 13 + .../Warning/DeprecatedComment.php | 13 + .../EmailValidator/Warning/DomainLiteral.php | 14 + .../EmailValidator/Warning/DomainTooLong.php | 14 + .../EmailValidator/Warning/EmailTooLong.php | 15 + .../EmailValidator/Warning/IPV6BadChar.php | 14 + .../EmailValidator/Warning/IPV6ColonEnd.php | 14 + .../EmailValidator/Warning/IPV6ColonStart.php | 14 + .../EmailValidator/Warning/IPV6Deprecated.php | 14 + .../Warning/IPV6DoubleColon.php | 14 + .../EmailValidator/Warning/IPV6GroupCount.php | 14 + .../EmailValidator/Warning/IPV6MaxGroups.php | 14 + .../EmailValidator/Warning/LabelTooLong.php | 14 + .../EmailValidator/Warning/LocalTooLong.php | 15 + .../EmailValidator/Warning/NoDNSMXRecord.php | 14 + .../EmailValidator/Warning/ObsoleteDTEXT.php | 14 + .../EmailValidator/Warning/QuotedPart.php | 13 + .../EmailValidator/Warning/QuotedString.php | 13 + .../EmailValidator/Warning/TLD.php | 13 + .../EmailValidator/Warning/Warning.php | 30 ++ egulias/email-validator/LICENSE | 19 + swiftmailer/swiftmailer/lib/classes/Swift.php | 3 +- .../lib/classes/Swift/Attachment.php | 20 +- .../AbstractFilterableInputStream.php | 58 +-- .../Swift/ByteStream/ArrayByteStream.php | 52 +-- .../Swift/ByteStream/FileByteStream.php | 131 +++--- .../GenericFixedWidthReader.php | 18 +- .../SimpleCharacterReaderFactory.php | 46 +-- .../CharacterStream/ArrayCharacterStream.php | 112 +++--- .../CharacterStream/NgCharacterStream.php | 102 ++--- .../lib/classes/Swift/ConfigurableSpool.php | 12 +- .../lib/classes/Swift/DependencyContainer.php | 92 ++--- .../lib/classes/Swift/EmbeddedFile.php | 18 +- .../lib/classes/Swift/Encoder/QpEncoder.php | 70 ++-- .../classes/Swift/Encoder/Rfc2231Encoder.php | 14 +- .../lib/classes/Swift/Encoding.php | 62 --- .../lib/classes/Swift/Events/CommandEvent.php | 12 +- .../classes/Swift/Events/EventDispatcher.php | 4 +- .../lib/classes/Swift/Events/EventObject.php | 12 +- .../classes/Swift/Events/ResponseEvent.php | 12 +- .../lib/classes/Swift/Events/SendEvent.php | 30 +- .../Swift/Events/SimpleEventDispatcher.php | 38 +- .../Swift/Events/TransportExceptionEvent.php | 6 +- .../lib/classes/Swift/FailoverTransport.php | 12 - .../lib/classes/Swift/FileSpool.php | 32 +- .../lib/classes/Swift/IdGenerator.php | 22 + .../swiftmailer/lib/classes/Swift/Image.php | 16 +- .../classes/Swift/KeyCache/ArrayKeyCache.php | 42 +- .../classes/Swift/KeyCache/DiskKeyCache.php | 105 ++--- .../KeyCache/SimpleKeyCacheInputStream.php | 28 +- .../classes/Swift/LoadBalancedTransport.php | 12 - .../lib/classes/Swift/MailTransport.php | 47 --- .../swiftmailer/lib/classes/Swift/Mailer.php | 32 +- .../Swift/Mailer/ArrayRecipientIterator.php | 8 +- .../lib/classes/Swift/MemorySpool.php | 4 +- .../swiftmailer/lib/classes/Swift/Message.php | 21 +- .../lib/classes/Swift/Mime/Attachment.php | 36 +- .../ContentEncoder/NativeQpContentEncoder.php | 4 +- .../ContentEncoder/PlainContentEncoder.php | 26 +- .../Mime/ContentEncoder/QpContentEncoder.php | 34 +- .../lib/classes/Swift/Mime/EmbeddedFile.php | 14 +- .../lib/classes/Swift/Mime/Grammar.php | 176 -------- .../Mime/HeaderEncoder/QpHeaderEncoder.php | 2 +- .../lib/classes/Swift/Mime/HeaderFactory.php | 78 ---- .../lib/classes/Swift/Mime/HeaderSet.php | 169 -------- .../Swift/Mime/Headers/AbstractHeader.php | 142 +++---- .../classes/Swift/Mime/Headers/DateHeader.php | 62 ++- .../Mime/Headers/IdentificationHeader.php | 46 ++- .../Swift/Mime/Headers/MailboxHeader.php | 48 ++- .../Swift/Mime/Headers/OpenDKIMHeader.php | 16 +- .../Mime/Headers/ParameterizedHeader.php | 49 ++- .../classes/Swift/Mime/Headers/PathHeader.php | 41 +- .../Swift/Mime/Headers/UnstructuredHeader.php | 14 +- .../lib/classes/Swift/Mime/IdGenerator.php | 53 +++ .../lib/classes/Swift/Mime/Message.php | 223 ----------- .../lib/classes/Swift/Mime/MimeEntity.php | 117 ------ .../lib/classes/Swift/Mime/MimePart.php | 70 ++-- .../Swift/Mime/ParameterizedHeader.php | 34 -- .../Swift/Mime/SimpleHeaderFactory.php | 84 ++-- .../classes/Swift/Mime/SimpleHeaderSet.php | 141 ++++--- .../lib/classes/Swift/Mime/SimpleMessage.php | 110 ++--- .../classes/Swift/Mime/SimpleMimeEntity.php | 379 ++++++++---------- .../lib/classes/Swift/MimePart.php | 14 - .../lib/classes/Swift/NullTransport.php | 10 - .../classes/Swift/Plugins/AntiFloodPlugin.php | 32 +- .../Swift/Plugins/BandwidthMonitorPlugin.php | 30 +- .../classes/Swift/Plugins/DecoratorPlugin.php | 62 +-- .../Swift/Plugins/ImpersonatePlugin.php | 6 +- .../classes/Swift/Plugins/LoggerPlugin.php | 28 +- .../Swift/Plugins/Loggers/ArrayLogger.php | 16 +- .../Swift/Plugins/Loggers/EchoLogger.php | 6 +- .../Swift/Plugins/PopBeforeSmtpPlugin.php | 104 +++-- .../Swift/Plugins/RedirectingPlugin.php | 48 +-- .../lib/classes/Swift/Plugins/Reporter.php | 8 +- .../classes/Swift/Plugins/ReporterPlugin.php | 10 +- .../Swift/Plugins/Reporters/HitReporter.php | 22 +- .../Swift/Plugins/Reporters/HtmlReporter.php | 8 +- .../classes/Swift/Plugins/ThrottlerPlugin.php | 56 +-- .../lib/classes/Swift/Preferences.php | 8 +- .../lib/classes/Swift/SendmailTransport.php | 12 - .../lib/classes/Swift/SignedMessage.php | 23 -- .../lib/classes/Swift/Signers/DKIMSigner.php | 310 +++++++------- .../classes/Swift/Signers/DomainKeySigner.php | 194 +++++---- .../classes/Swift/Signers/HeaderSigner.php | 6 +- .../classes/Swift/Signers/OpenDKIMSigner.php | 71 ++-- .../lib/classes/Swift/Signers/SMimeSigner.php | 25 +- .../lib/classes/Swift/SmtpTransport.php | 16 +- .../swiftmailer/lib/classes/Swift/Spool.php | 4 +- .../lib/classes/Swift/SpoolTransport.php | 12 - .../ByteArrayReplacementFilter.php | 58 +-- .../StreamFilters/StringReplacementFilter.php | 12 +- .../StringReplacementFilterFactory.php | 16 +- .../lib/classes/Swift/Transport.php | 27 +- .../Swift/Transport/AbstractSmtpTransport.php | 230 ++++++----- .../Esmtp/Auth/CramMd5Authenticator.php | 4 +- .../Esmtp/Auth/NTLMAuthenticator.php | 67 +--- .../Esmtp/Auth/XOAuth2Authenticator.php | 2 +- .../Swift/Transport/Esmtp/AuthHandler.php | 46 +-- .../Swift/Transport/EsmtpTransport.php | 114 +++--- .../Swift/Transport/FailoverTransport.php | 50 ++- .../Swift/Transport/LoadBalancedTransport.php | 64 +-- .../classes/Swift/Transport/MailInvoker.php | 32 -- .../classes/Swift/Transport/MailTransport.php | 297 -------------- .../classes/Swift/Transport/NullTransport.php | 24 +- .../Swift/Transport/SendmailTransport.php | 31 +- .../Swift/Transport/SimpleMailInvoker.php | 39 -- .../Swift/Transport/SpoolTransport.php | 34 +- .../classes/Swift/Transport/StreamBuffer.php | 165 ++++---- .../lib/classes/Swift/Validate.php | 43 -- .../lib/dependency_maps/mime_deps.php | 33 +- .../lib/dependency_maps/transport_deps.php | 15 +- swiftmailer/swiftmailer/lib/mime_types.php | 2 +- swiftmailer/swiftmailer/lib/preferences.php | 6 - swiftmailer/swiftmailer/lib/swift_init.php | 28 -- .../swiftmailer/lib/swift_required.php | 26 +- .../swiftmailer/lib/swift_required_pear.php | 30 -- .../lib/swiftmailer_generate_mimes_config.php | 8 +- 184 files changed, 4556 insertions(+), 3865 deletions(-) create mode 100644 egulias/email-validator/EmailValidator/EmailLexer.php create mode 100644 egulias/email-validator/EmailValidator/EmailParser.php create mode 100644 egulias/email-validator/EmailValidator/EmailValidator.php create mode 100644 egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php create mode 100644 egulias/email-validator/EmailValidator/Exception/CRLFAtTheEnd.php create mode 100644 egulias/email-validator/EmailValidator/Exception/CRLFX2.php create mode 100644 egulias/email-validator/EmailValidator/Exception/CRNoLF.php create mode 100644 egulias/email-validator/EmailValidator/Exception/CharNotAllowed.php create mode 100644 egulias/email-validator/EmailValidator/Exception/CommaInDomain.php create mode 100644 egulias/email-validator/EmailValidator/Exception/ConsecutiveAt.php create mode 100644 egulias/email-validator/EmailValidator/Exception/ConsecutiveDot.php create mode 100644 egulias/email-validator/EmailValidator/Exception/DomainHyphened.php create mode 100644 egulias/email-validator/EmailValidator/Exception/DotAtEnd.php create mode 100644 egulias/email-validator/EmailValidator/Exception/DotAtStart.php create mode 100644 egulias/email-validator/EmailValidator/Exception/ExpectingAT.php create mode 100644 egulias/email-validator/EmailValidator/Exception/ExpectingATEXT.php create mode 100644 egulias/email-validator/EmailValidator/Exception/ExpectingCTEXT.php create mode 100644 egulias/email-validator/EmailValidator/Exception/ExpectingDTEXT.php create mode 100644 egulias/email-validator/EmailValidator/Exception/ExpectingDomainLiteralClose.php create mode 100644 egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php create mode 100644 egulias/email-validator/EmailValidator/Exception/InvalidEmail.php create mode 100644 egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php create mode 100644 egulias/email-validator/EmailValidator/Exception/NoDomainPart.php create mode 100644 egulias/email-validator/EmailValidator/Exception/NoLocalPart.php create mode 100644 egulias/email-validator/EmailValidator/Exception/UnclosedComment.php create mode 100644 egulias/email-validator/EmailValidator/Exception/UnclosedQuotedString.php create mode 100644 egulias/email-validator/EmailValidator/Exception/UnopenedComment.php create mode 100644 egulias/email-validator/EmailValidator/Parser/DomainPart.php create mode 100644 egulias/email-validator/EmailValidator/Parser/LocalPart.php create mode 100644 egulias/email-validator/EmailValidator/Parser/Parser.php create mode 100644 egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php create mode 100644 egulias/email-validator/EmailValidator/Validation/EmailValidation.php create mode 100644 egulias/email-validator/EmailValidator/Validation/Error/RFCWarnings.php create mode 100644 egulias/email-validator/EmailValidator/Validation/Error/SpoofEmail.php create mode 100644 egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php create mode 100644 egulias/email-validator/EmailValidator/Validation/MultipleErrors.php create mode 100644 egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php create mode 100644 egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php create mode 100644 egulias/email-validator/EmailValidator/Validation/RFCValidation.php create mode 100644 egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php create mode 100644 egulias/email-validator/EmailValidator/Warning/AddressLiteral.php create mode 100644 egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php create mode 100644 egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php create mode 100644 egulias/email-validator/EmailValidator/Warning/Comment.php create mode 100644 egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php create mode 100644 egulias/email-validator/EmailValidator/Warning/DomainLiteral.php create mode 100644 egulias/email-validator/EmailValidator/Warning/DomainTooLong.php create mode 100644 egulias/email-validator/EmailValidator/Warning/EmailTooLong.php create mode 100644 egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php create mode 100644 egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php create mode 100644 egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php create mode 100644 egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php create mode 100644 egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php create mode 100644 egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php create mode 100644 egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php create mode 100644 egulias/email-validator/EmailValidator/Warning/LabelTooLong.php create mode 100644 egulias/email-validator/EmailValidator/Warning/LocalTooLong.php create mode 100644 egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php create mode 100644 egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php create mode 100644 egulias/email-validator/EmailValidator/Warning/QuotedPart.php create mode 100644 egulias/email-validator/EmailValidator/Warning/QuotedString.php create mode 100644 egulias/email-validator/EmailValidator/Warning/TLD.php create mode 100644 egulias/email-validator/EmailValidator/Warning/Warning.php create mode 100644 egulias/email-validator/LICENSE delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php create mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/IdGenerator.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Mime/Grammar.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php create mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailTransport.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php delete mode 100644 swiftmailer/swiftmailer/lib/classes/Swift/Validate.php delete mode 100644 swiftmailer/swiftmailer/lib/swift_init.php delete mode 100644 swiftmailer/swiftmailer/lib/swift_required_pear.php diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php index 0b5236016..d90d74c82 100644 --- a/composer/autoload_classmap.php +++ b/composer/autoload_classmap.php @@ -698,6 +698,69 @@ 'Doctrine\\DBAL\\Types\\VarDateTimeType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php', 'Doctrine\\DBAL\\Version' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Version.php', 'Doctrine\\DBAL\\VersionAwarePlatformDriver' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php', + 'Egulias\\EmailValidator\\EmailLexer' => $vendorDir . '/egulias/email-validator/EmailValidator/EmailLexer.php', + 'Egulias\\EmailValidator\\EmailParser' => $vendorDir . '/egulias/email-validator/EmailValidator/EmailParser.php', + 'Egulias\\EmailValidator\\EmailValidator' => $vendorDir . '/egulias/email-validator/EmailValidator/EmailValidator.php', + 'Egulias\\EmailValidator\\Exception\\AtextAfterCFWS' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php', + 'Egulias\\EmailValidator\\Exception\\CRLFAtTheEnd' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/CRLFAtTheEnd.php', + 'Egulias\\EmailValidator\\Exception\\CRLFX2' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/CRLFX2.php', + 'Egulias\\EmailValidator\\Exception\\CRNoLF' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/CRNoLF.php', + 'Egulias\\EmailValidator\\Exception\\CharNotAllowed' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/CharNotAllowed.php', + 'Egulias\\EmailValidator\\Exception\\CommaInDomain' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/CommaInDomain.php', + 'Egulias\\EmailValidator\\Exception\\ConsecutiveAt' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/ConsecutiveAt.php', + 'Egulias\\EmailValidator\\Exception\\ConsecutiveDot' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/ConsecutiveDot.php', + 'Egulias\\EmailValidator\\Exception\\DomainHyphened' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/DomainHyphened.php', + 'Egulias\\EmailValidator\\Exception\\DotAtEnd' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/DotAtEnd.php', + 'Egulias\\EmailValidator\\Exception\\DotAtStart' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/DotAtStart.php', + 'Egulias\\EmailValidator\\Exception\\ExpectedQPair' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingAT' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/ExpectingAT.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingATEXT' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/ExpectingATEXT.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingCTEXT' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/ExpectingCTEXT.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingDTEXT' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/ExpectingDTEXT.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingDomainLiteralClose' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/ExpectingDomainLiteralClose.php', + 'Egulias\\EmailValidator\\Exception\\InvalidEmail' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php', + 'Egulias\\EmailValidator\\Exception\\NoDNSRecord' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php', + 'Egulias\\EmailValidator\\Exception\\NoDomainPart' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php', + 'Egulias\\EmailValidator\\Exception\\NoLocalPart' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/NoLocalPart.php', + 'Egulias\\EmailValidator\\Exception\\UnclosedComment' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php', + 'Egulias\\EmailValidator\\Exception\\UnclosedQuotedString' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/UnclosedQuotedString.php', + 'Egulias\\EmailValidator\\Exception\\UnopenedComment' => $vendorDir . '/egulias/email-validator/EmailValidator/Exception/UnopenedComment.php', + 'Egulias\\EmailValidator\\Parser\\DomainPart' => $vendorDir . '/egulias/email-validator/EmailValidator/Parser/DomainPart.php', + 'Egulias\\EmailValidator\\Parser\\LocalPart' => $vendorDir . '/egulias/email-validator/EmailValidator/Parser/LocalPart.php', + 'Egulias\\EmailValidator\\Parser\\Parser' => $vendorDir . '/egulias/email-validator/EmailValidator/Parser/Parser.php', + 'Egulias\\EmailValidator\\Validation\\DNSCheckValidation' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php', + 'Egulias\\EmailValidator\\Validation\\EmailValidation' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/EmailValidation.php', + 'Egulias\\EmailValidator\\Validation\\Error\\RFCWarnings' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/Error/RFCWarnings.php', + 'Egulias\\EmailValidator\\Validation\\Error\\SpoofEmail' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/Error/SpoofEmail.php', + 'Egulias\\EmailValidator\\Validation\\Exception\\EmptyValidationList' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php', + 'Egulias\\EmailValidator\\Validation\\MultipleErrors' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php', + 'Egulias\\EmailValidator\\Validation\\MultipleValidationWithAnd' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php', + 'Egulias\\EmailValidator\\Validation\\NoRFCWarningsValidation' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php', + 'Egulias\\EmailValidator\\Validation\\RFCValidation' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/RFCValidation.php', + 'Egulias\\EmailValidator\\Validation\\SpoofCheckValidation' => $vendorDir . '/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php', + 'Egulias\\EmailValidator\\Warning\\AddressLiteral' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php', + 'Egulias\\EmailValidator\\Warning\\CFWSNearAt' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php', + 'Egulias\\EmailValidator\\Warning\\CFWSWithFWS' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php', + 'Egulias\\EmailValidator\\Warning\\Comment' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/Comment.php', + 'Egulias\\EmailValidator\\Warning\\DeprecatedComment' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php', + 'Egulias\\EmailValidator\\Warning\\DomainLiteral' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php', + 'Egulias\\EmailValidator\\Warning\\DomainTooLong' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php', + 'Egulias\\EmailValidator\\Warning\\EmailTooLong' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php', + 'Egulias\\EmailValidator\\Warning\\IPV6BadChar' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php', + 'Egulias\\EmailValidator\\Warning\\IPV6ColonEnd' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php', + 'Egulias\\EmailValidator\\Warning\\IPV6ColonStart' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php', + 'Egulias\\EmailValidator\\Warning\\IPV6Deprecated' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php', + 'Egulias\\EmailValidator\\Warning\\IPV6DoubleColon' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php', + 'Egulias\\EmailValidator\\Warning\\IPV6GroupCount' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php', + 'Egulias\\EmailValidator\\Warning\\IPV6MaxGroups' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php', + 'Egulias\\EmailValidator\\Warning\\LabelTooLong' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php', + 'Egulias\\EmailValidator\\Warning\\LocalTooLong' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php', + 'Egulias\\EmailValidator\\Warning\\NoDNSMXRecord' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php', + 'Egulias\\EmailValidator\\Warning\\ObsoleteDTEXT' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php', + 'Egulias\\EmailValidator\\Warning\\QuotedPart' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/QuotedPart.php', + 'Egulias\\EmailValidator\\Warning\\QuotedString' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/QuotedString.php', + 'Egulias\\EmailValidator\\Warning\\TLD' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/TLD.php', + 'Egulias\\EmailValidator\\Warning\\Warning' => $vendorDir . '/egulias/email-validator/EmailValidator/Warning/Warning.php', 'GuzzleHttp\\Client' => $vendorDir . '/guzzlehttp/guzzle/src/Client.php', 'GuzzleHttp\\ClientInterface' => $vendorDir . '/guzzlehttp/guzzle/src/ClientInterface.php', 'GuzzleHttp\\Cookie\\CookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php', diff --git a/composer/autoload_psr4.php b/composer/autoload_psr4.php index e73ac0640..a8f6c4c32 100644 --- a/composer/autoload_psr4.php +++ b/composer/autoload_psr4.php @@ -52,6 +52,7 @@ 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), + 'Egulias\\EmailValidator\\' => array($vendorDir . '/egulias/email-validator/EmailValidator'), 'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache'), 'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib/Doctrine/Common'), 'Aws\\' => array($vendorDir . '/aws/aws-sdk-php/src'), diff --git a/composer/autoload_static.php b/composer/autoload_static.php index 2997e9b0c..6ab5f35da 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -113,6 +113,10 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'GuzzleHttp\\Promise\\' => 19, 'GuzzleHttp\\' => 11, ), + 'E' => + array ( + 'Egulias\\EmailValidator\\' => 23, + ), 'D' => array ( 'Doctrine\\Common\\Cache\\' => 22, @@ -310,6 +314,10 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 array ( 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', ), + 'Egulias\\EmailValidator\\' => + array ( + 0 => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator', + ), 'Doctrine\\Common\\Cache\\' => array ( 0 => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache', @@ -1072,6 +1080,69 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\DBAL\\Types\\VarDateTimeType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php', 'Doctrine\\DBAL\\Version' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Version.php', 'Doctrine\\DBAL\\VersionAwarePlatformDriver' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php', + 'Egulias\\EmailValidator\\EmailLexer' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/EmailLexer.php', + 'Egulias\\EmailValidator\\EmailParser' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/EmailParser.php', + 'Egulias\\EmailValidator\\EmailValidator' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/EmailValidator.php', + 'Egulias\\EmailValidator\\Exception\\AtextAfterCFWS' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php', + 'Egulias\\EmailValidator\\Exception\\CRLFAtTheEnd' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/CRLFAtTheEnd.php', + 'Egulias\\EmailValidator\\Exception\\CRLFX2' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/CRLFX2.php', + 'Egulias\\EmailValidator\\Exception\\CRNoLF' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/CRNoLF.php', + 'Egulias\\EmailValidator\\Exception\\CharNotAllowed' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/CharNotAllowed.php', + 'Egulias\\EmailValidator\\Exception\\CommaInDomain' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/CommaInDomain.php', + 'Egulias\\EmailValidator\\Exception\\ConsecutiveAt' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/ConsecutiveAt.php', + 'Egulias\\EmailValidator\\Exception\\ConsecutiveDot' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/ConsecutiveDot.php', + 'Egulias\\EmailValidator\\Exception\\DomainHyphened' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/DomainHyphened.php', + 'Egulias\\EmailValidator\\Exception\\DotAtEnd' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/DotAtEnd.php', + 'Egulias\\EmailValidator\\Exception\\DotAtStart' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/DotAtStart.php', + 'Egulias\\EmailValidator\\Exception\\ExpectedQPair' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingAT' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/ExpectingAT.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingATEXT' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/ExpectingATEXT.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingCTEXT' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/ExpectingCTEXT.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingDTEXT' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/ExpectingDTEXT.php', + 'Egulias\\EmailValidator\\Exception\\ExpectingDomainLiteralClose' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/ExpectingDomainLiteralClose.php', + 'Egulias\\EmailValidator\\Exception\\InvalidEmail' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php', + 'Egulias\\EmailValidator\\Exception\\NoDNSRecord' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php', + 'Egulias\\EmailValidator\\Exception\\NoDomainPart' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php', + 'Egulias\\EmailValidator\\Exception\\NoLocalPart' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/NoLocalPart.php', + 'Egulias\\EmailValidator\\Exception\\UnclosedComment' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php', + 'Egulias\\EmailValidator\\Exception\\UnclosedQuotedString' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/UnclosedQuotedString.php', + 'Egulias\\EmailValidator\\Exception\\UnopenedComment' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Exception/UnopenedComment.php', + 'Egulias\\EmailValidator\\Parser\\DomainPart' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Parser/DomainPart.php', + 'Egulias\\EmailValidator\\Parser\\LocalPart' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Parser/LocalPart.php', + 'Egulias\\EmailValidator\\Parser\\Parser' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Parser/Parser.php', + 'Egulias\\EmailValidator\\Validation\\DNSCheckValidation' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php', + 'Egulias\\EmailValidator\\Validation\\EmailValidation' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/EmailValidation.php', + 'Egulias\\EmailValidator\\Validation\\Error\\RFCWarnings' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/Error/RFCWarnings.php', + 'Egulias\\EmailValidator\\Validation\\Error\\SpoofEmail' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/Error/SpoofEmail.php', + 'Egulias\\EmailValidator\\Validation\\Exception\\EmptyValidationList' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php', + 'Egulias\\EmailValidator\\Validation\\MultipleErrors' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php', + 'Egulias\\EmailValidator\\Validation\\MultipleValidationWithAnd' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php', + 'Egulias\\EmailValidator\\Validation\\NoRFCWarningsValidation' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php', + 'Egulias\\EmailValidator\\Validation\\RFCValidation' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/RFCValidation.php', + 'Egulias\\EmailValidator\\Validation\\SpoofCheckValidation' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php', + 'Egulias\\EmailValidator\\Warning\\AddressLiteral' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php', + 'Egulias\\EmailValidator\\Warning\\CFWSNearAt' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php', + 'Egulias\\EmailValidator\\Warning\\CFWSWithFWS' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php', + 'Egulias\\EmailValidator\\Warning\\Comment' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/Comment.php', + 'Egulias\\EmailValidator\\Warning\\DeprecatedComment' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php', + 'Egulias\\EmailValidator\\Warning\\DomainLiteral' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php', + 'Egulias\\EmailValidator\\Warning\\DomainTooLong' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php', + 'Egulias\\EmailValidator\\Warning\\EmailTooLong' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php', + 'Egulias\\EmailValidator\\Warning\\IPV6BadChar' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php', + 'Egulias\\EmailValidator\\Warning\\IPV6ColonEnd' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php', + 'Egulias\\EmailValidator\\Warning\\IPV6ColonStart' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php', + 'Egulias\\EmailValidator\\Warning\\IPV6Deprecated' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php', + 'Egulias\\EmailValidator\\Warning\\IPV6DoubleColon' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php', + 'Egulias\\EmailValidator\\Warning\\IPV6GroupCount' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php', + 'Egulias\\EmailValidator\\Warning\\IPV6MaxGroups' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php', + 'Egulias\\EmailValidator\\Warning\\LabelTooLong' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php', + 'Egulias\\EmailValidator\\Warning\\LocalTooLong' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php', + 'Egulias\\EmailValidator\\Warning\\NoDNSMXRecord' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php', + 'Egulias\\EmailValidator\\Warning\\ObsoleteDTEXT' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php', + 'Egulias\\EmailValidator\\Warning\\QuotedPart' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/QuotedPart.php', + 'Egulias\\EmailValidator\\Warning\\QuotedString' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/QuotedString.php', + 'Egulias\\EmailValidator\\Warning\\TLD' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/TLD.php', + 'Egulias\\EmailValidator\\Warning\\Warning' => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator/Warning/Warning.php', 'GuzzleHttp\\Client' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Client.php', 'GuzzleHttp\\ClientInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/ClientInterface.php', 'GuzzleHttp\\Cookie\\CookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php', diff --git a/composer/installed.json b/composer/installed.json index 82793dc48..dfd88f683 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -720,6 +720,65 @@ "parser" ] }, + { + "name": "egulias/email-validator", + "version": "2.1.4", + "version_normalized": "2.1.4.0", + "source": { + "type": "git", + "url": "https://github.com/egulias/EmailValidator.git", + "reference": "8790f594151ca6a2010c6218e09d96df67173ad3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/8790f594151ca6a2010c6218e09d96df67173ad3", + "reference": "8790f594151ca6a2010c6218e09d96df67173ad3", + "shasum": "" + }, + "require": { + "doctrine/lexer": "^1.0.1", + "php": ">= 5.5" + }, + "require-dev": { + "dominicsayers/isemail": "dev-master", + "phpunit/phpunit": "^4.8.35||^5.7||^6.0", + "satooshi/php-coveralls": "^1.0.1" + }, + "suggest": { + "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" + }, + "time": "2018-04-10T10:11:19+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Egulias\\EmailValidator\\": "EmailValidator" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eduardo Gulias Davis" + } + ], + "description": "A library for validating emails against several RFCs", + "homepage": "https://github.com/egulias/EmailValidator", + "keywords": [ + "email", + "emailvalidation", + "emailvalidator", + "validation", + "validator" + ] + }, { "name": "guzzlehttp/guzzle", "version": "6.3.0", @@ -2978,31 +3037,32 @@ }, { "name": "swiftmailer/swiftmailer", - "version": "v5.4.8", - "version_normalized": "5.4.8.0", + "version": "v6.0.2", + "version_normalized": "6.0.2.0", "source": { "type": "git", "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "9a06dc570a0367850280eefd3f1dc2da45aef517" + "reference": "412333372fb6c8ffb65496a2bbd7321af75733fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/9a06dc570a0367850280eefd3f1dc2da45aef517", - "reference": "9a06dc570a0367850280eefd3f1dc2da45aef517", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/412333372fb6c8ffb65496a2bbd7321af75733fc", + "reference": "412333372fb6c8ffb65496a2bbd7321af75733fc", "shasum": "" }, "require": { - "php": ">=5.3.3" + "egulias/email-validator": "~2.0", + "php": ">=7.0.0" }, "require-dev": { "mockery/mockery": "~0.9.1", - "symfony/phpunit-bridge": "~3.2" + "symfony/phpunit-bridge": "~3.3@dev" }, - "time": "2017-05-01T15:54:03+00:00", + "time": "2017-09-30T22:39:41+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "5.4-dev" + "dev-master": "6.0-dev" } }, "installation-source": "dist", @@ -3025,7 +3085,7 @@ } ], "description": "Swiftmailer, free feature-rich PHP mailer", - "homepage": "http://swiftmailer.org", + "homepage": "http://swiftmailer.symfony.com", "keywords": [ "email", "mail", diff --git a/egulias/email-validator/EmailValidator/EmailLexer.php b/egulias/email-validator/EmailValidator/EmailLexer.php new file mode 100644 index 000000000..882c96815 --- /dev/null +++ b/egulias/email-validator/EmailValidator/EmailLexer.php @@ -0,0 +1,221 @@ + self::S_OPENPARENTHESIS, + ')' => self::S_CLOSEPARENTHESIS, + '<' => self::S_LOWERTHAN, + '>' => self::S_GREATERTHAN, + '[' => self::S_OPENBRACKET, + ']' => self::S_CLOSEBRACKET, + ':' => self::S_COLON, + ';' => self::S_SEMICOLON, + '@' => self::S_AT, + '\\' => self::S_BACKSLASH, + '/' => self::S_SLASH, + ',' => self::S_COMMA, + '.' => self::S_DOT, + '"' => self::S_DQUOTE, + '-' => self::S_HYPHEN, + '::' => self::S_DOUBLECOLON, + ' ' => self::S_SP, + "\t" => self::S_HTAB, + "\r" => self::S_CR, + "\n" => self::S_LF, + "\r\n" => self::CRLF, + 'IPv6' => self::S_IPV6TAG, + '{' => self::S_OPENQBRACKET, + '}' => self::S_CLOSEQBRACKET, + '' => self::S_EMPTY, + '\0' => self::C_NUL, + ); + + protected $hasInvalidTokens = false; + + protected $previous; + + public function reset() + { + $this->hasInvalidTokens = false; + parent::reset(); + } + + public function hasInvalidTokens() + { + return $this->hasInvalidTokens; + } + + /** + * @param $type + * @throws \UnexpectedValueException + * @return boolean + */ + public function find($type) + { + $search = clone $this; + $search->skipUntil($type); + + if (!$search->lookahead) { + throw new \UnexpectedValueException($type . ' not found'); + } + return true; + } + + /** + * getPrevious + * + * @return array token + */ + public function getPrevious() + { + return $this->previous; + } + + /** + * moveNext + * + * @return boolean + */ + public function moveNext() + { + $this->previous = $this->token; + + return parent::moveNext(); + } + + /** + * Lexical catchable patterns. + * + * @return string[] + */ + protected function getCatchablePatterns() + { + return array( + '[a-zA-Z_]+[46]?', //ASCII and domain literal + '[^\x00-\x7F]', //UTF-8 + '[0-9]+', + '\r\n', + '::', + '\s+?', + '.', + ); + } + + /** + * Lexical non-catchable patterns. + * + * @return string[] + */ + protected function getNonCatchablePatterns() + { + return array('[\xA0-\xff]+'); + } + + /** + * Retrieve token type. Also processes the token value if necessary. + * + * @param string $value + * @throws \InvalidArgumentException + * @return integer + */ + protected function getType(&$value) + { + if ($this->isNullType($value)) { + return self::C_NUL; + } + + if ($this->isValid($value)) { + return $this->charValue[$value]; + } + + if ($this->isUTF8Invalid($value)) { + $this->hasInvalidTokens = true; + return self::INVALID; + } + + return self::GENERIC; + } + + protected function isValid($value) + { + if (isset($this->charValue[$value])) { + return true; + } + + return false; + } + + /** + * @param $value + * @return bool + */ + protected function isNullType($value) + { + if ($value === "\0") { + return true; + } + + return false; + } + + /** + * @param $value + * @return bool + */ + protected function isUTF8Invalid($value) + { + if (preg_match('/\p{Cc}+/u', $value)) { + return true; + } + + return false; + } + + protected function getModifiers() + { + return 'iu'; + } +} diff --git a/egulias/email-validator/EmailValidator/EmailParser.php b/egulias/email-validator/EmailValidator/EmailParser.php new file mode 100644 index 000000000..d0627d824 --- /dev/null +++ b/egulias/email-validator/EmailValidator/EmailParser.php @@ -0,0 +1,104 @@ + + */ +class EmailParser +{ + const EMAIL_MAX_LENGTH = 254; + + protected $warnings; + protected $domainPart = ''; + protected $localPart = ''; + protected $lexer; + protected $localPartParser; + protected $domainPartParser; + + public function __construct(EmailLexer $lexer) + { + $this->lexer = $lexer; + $this->localPartParser = new LocalPart($this->lexer); + $this->domainPartParser = new DomainPart($this->lexer); + $this->warnings = new \SplObjectStorage(); + } + + /** + * @param $str + * @return array + */ + public function parse($str) + { + $this->lexer->setInput($str); + + if (!$this->hasAtToken()) { + throw new NoLocalPart(); + } + + + $this->localPartParser->parse($str); + $this->domainPartParser->parse($str); + + $this->setParts($str); + + if ($this->lexer->hasInvalidTokens()) { + throw new ExpectingATEXT(); + } + + return array('local' => $this->localPart, 'domain' => $this->domainPart); + } + + public function getWarnings() + { + $localPartWarnings = $this->localPartParser->getWarnings(); + $domainPartWarnings = $this->domainPartParser->getWarnings(); + $this->warnings = array_merge($localPartWarnings, $domainPartWarnings); + + $this->addLongEmailWarning($this->localPart, $this->domainPart); + + return $this->warnings; + } + + public function getParsedDomainPart() + { + return $this->domainPart; + } + + protected function setParts($email) + { + $parts = explode('@', $email); + $this->domainPart = $this->domainPartParser->getDomainPart(); + $this->localPart = $parts[0]; + } + + protected function hasAtToken() + { + $this->lexer->moveNext(); + $this->lexer->moveNext(); + if ($this->lexer->token['type'] === EmailLexer::S_AT) { + return false; + } + + return true; + } + + /** + * @param string $localPart + * @param string $parsedDomainPart + */ + protected function addLongEmailWarning($localPart, $parsedDomainPart) + { + if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { + $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); + } + } +} diff --git a/egulias/email-validator/EmailValidator/EmailValidator.php b/egulias/email-validator/EmailValidator/EmailValidator.php new file mode 100644 index 000000000..44b4b93c6 --- /dev/null +++ b/egulias/email-validator/EmailValidator/EmailValidator.php @@ -0,0 +1,67 @@ +lexer = new EmailLexer(); + } + + /** + * @param $email + * @param EmailValidation $emailValidation + * @return bool + */ + public function isValid($email, EmailValidation $emailValidation) + { + $isValid = $emailValidation->isValid($email, $this->lexer); + $this->warnings = $emailValidation->getWarnings(); + $this->error = $emailValidation->getError(); + + return $isValid; + } + + /** + * @return boolean + */ + public function hasWarnings() + { + return !empty($this->warnings); + } + + /** + * @return array + */ + public function getWarnings() + { + return $this->warnings; + } + + /** + * @return InvalidEmail + */ + public function getError() + { + return $this->error; + } +} diff --git a/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php b/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php new file mode 100644 index 000000000..97f41a2ca --- /dev/null +++ b/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php @@ -0,0 +1,9 @@ +lexer->moveNext(); + + if ($this->lexer->token['type'] === EmailLexer::S_DOT) { + throw new DotAtStart(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_EMPTY) { + throw new NoDomainPart(); + } + if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { + throw new DomainHyphened(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); + $this->parseDomainComments(); + } + + $domain = $this->doParseDomainPart(); + + $prev = $this->lexer->getPrevious(); + $length = strlen($domain); + + if ($prev['type'] === EmailLexer::S_DOT) { + throw new DotAtEnd(); + } + if ($prev['type'] === EmailLexer::S_HYPHEN) { + throw new DomainHyphened(); + } + if ($length > self::DOMAIN_MAX_LENGTH) { + $this->warnings[DomainTooLong::CODE] = new DomainTooLong(); + } + if ($prev['type'] === EmailLexer::S_CR) { + throw new CRLFAtTheEnd(); + } + $this->domainPart = $domain; + } + + public function getDomainPart() + { + return $this->domainPart; + } + + public function checkIPV6Tag($addressLiteral, $maxGroups = 8) + { + $prev = $this->lexer->getPrevious(); + if ($prev['type'] === EmailLexer::S_COLON) { + $this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd(); + } + + $IPv6 = substr($addressLiteral, 5); + //Daniel Marschall's new IPv6 testing strategy + $matchesIP = explode(':', $IPv6); + $groupCount = count($matchesIP); + $colons = strpos($IPv6, '::'); + + if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) { + $this->warnings[IPV6BadChar::CODE] = new IPV6BadChar(); + } + + if ($colons === false) { + // We need exactly the right number of groups + if ($groupCount !== $maxGroups) { + $this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount(); + } + return; + } + + if ($colons !== strrpos($IPv6, '::')) { + $this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon(); + return; + } + + if ($colons === 0 || $colons === (strlen($IPv6) - 2)) { + // RFC 4291 allows :: at the start or end of an address + //with 7 other groups in addition + ++$maxGroups; + } + + if ($groupCount > $maxGroups) { + $this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups(); + } elseif ($groupCount === $maxGroups) { + $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated(); + } + } + + protected function doParseDomainPart() + { + $domain = ''; + $openedParenthesis = 0; + do { + $prev = $this->lexer->getPrevious(); + + $this->checkNotAllowedChars($this->lexer->token); + + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->parseComments(); + $openedParenthesis += $this->getOpenedParenthesis(); + $this->lexer->moveNext(); + $tmpPrev = $this->lexer->getPrevious(); + if ($tmpPrev['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + $openedParenthesis--; + } + } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + if ($openedParenthesis === 0) { + throw new UnopenedComment(); + } else { + $openedParenthesis--; + } + } + + $this->checkConsecutiveDots(); + $this->checkDomainPartExceptions($prev); + + if ($this->hasBrackets()) { + $this->parseDomainLiteral(); + } + + $this->checkLabelLength($prev); + + if ($this->isFWS()) { + $this->parseFWS(); + } + + $domain .= $this->lexer->token['value']; + $this->lexer->moveNext(); + } while ($this->lexer->token); + + return $domain; + } + + private function checkNotAllowedChars($token) + { + $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; + if (isset($notAllowed[$token['type']])) { + throw new CharNotAllowed(); + } + } + + protected function parseDomainLiteral() + { + if ($this->lexer->isNextToken(EmailLexer::S_COLON)) { + $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); + } + if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) { + $lexer = clone $this->lexer; + $lexer->moveNext(); + if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) { + $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); + } + } + + return $this->doParseDomainLiteral(); + } + + protected function doParseDomainLiteral() + { + $IPv6TAG = false; + $addressLiteral = ''; + do { + if ($this->lexer->token['type'] === EmailLexer::C_NUL) { + throw new ExpectingDTEXT(); + } + + if ($this->lexer->token['type'] === EmailLexer::INVALID || + $this->lexer->token['type'] === EmailLexer::C_DEL || + $this->lexer->token['type'] === EmailLexer::S_LF + ) { + $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); + } + + if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) { + throw new ExpectingDTEXT(); + } + + if ($this->lexer->isNextTokenAny( + array(EmailLexer::S_HTAB, EmailLexer::S_SP, $this->lexer->token['type'] === EmailLexer::CRLF) + )) { + $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); + $this->parseFWS(); + } + + if ($this->lexer->isNextToken(EmailLexer::S_CR)) { + throw new CRNoLF(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) { + $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); + $addressLiteral .= $this->lexer->token['value']; + $this->lexer->moveNext(); + $this->validateQuotedPair(); + } + if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) { + $IPv6TAG = true; + } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEQBRACKET) { + break; + } + + $addressLiteral .= $this->lexer->token['value']; + + } while ($this->lexer->moveNext()); + + $addressLiteral = str_replace('[', '', $addressLiteral); + $addressLiteral = $this->checkIPV4Tag($addressLiteral); + + if (false === $addressLiteral) { + return $addressLiteral; + } + + if (!$IPv6TAG) { + $this->warnings[DomainLiteral::CODE] = new DomainLiteral(); + return $addressLiteral; + } + + $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); + + $this->checkIPV6Tag($addressLiteral); + + return $addressLiteral; + } + + protected function checkIPV4Tag($addressLiteral) + { + $matchesIP = array(); + + // Extract IPv4 part from the end of the address-literal (if there is one) + if (preg_match( + '/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/', + $addressLiteral, + $matchesIP + ) > 0 + ) { + $index = strrpos($addressLiteral, $matchesIP[0]); + if ($index === 0) { + $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); + return false; + } + // Convert IPv4 part to IPv6 format for further testing + $addressLiteral = substr($addressLiteral, 0, $index) . '0:0'; + } + + return $addressLiteral; + } + + protected function checkDomainPartExceptions($prev) + { + $invalidDomainTokens = array( + EmailLexer::S_DQUOTE => true, + EmailLexer::S_SEMICOLON => true, + EmailLexer::S_GREATERTHAN => true, + EmailLexer::S_LOWERTHAN => true, + ); + + if (isset($invalidDomainTokens[$this->lexer->token['type']])) { + throw new ExpectingATEXT(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_COMMA) { + throw new CommaInDomain(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_AT) { + throw new ConsecutiveAt(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) { + throw new ExpectingATEXT(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + throw new DomainHyphened(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH + && $this->lexer->isNextToken(EmailLexer::GENERIC)) { + throw new ExpectingATEXT(); + } + } + + protected function hasBrackets() + { + if ($this->lexer->token['type'] !== EmailLexer::S_OPENBRACKET) { + return false; + } + + try { + $this->lexer->find(EmailLexer::S_CLOSEBRACKET); + } catch (\RuntimeException $e) { + throw new ExpectingDomainLiteralClose(); + } + + return true; + } + + protected function checkLabelLength($prev) + { + if ($this->lexer->token['type'] === EmailLexer::S_DOT && + $prev['type'] === EmailLexer::GENERIC && + strlen($prev['value']) > 63 + ) { + $this->warnings[LabelTooLong::CODE] = new LabelTooLong(); + } + } + + protected function parseDomainComments() + { + $this->isUnclosedComment(); + while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { + $this->warnEscaping(); + $this->lexer->moveNext(); + } + + $this->lexer->moveNext(); + if ($this->lexer->isNextToken(EmailLexer::S_DOT)) { + throw new ExpectingATEXT(); + } + } + + protected function addTLDWarnings() + { + if ($this->warnings[DomainLiteral::CODE]) { + $this->warnings[TLD::CODE] = new TLD(); + } + } +} diff --git a/egulias/email-validator/EmailValidator/Parser/LocalPart.php b/egulias/email-validator/EmailValidator/Parser/LocalPart.php new file mode 100644 index 000000000..8ab16ab4a --- /dev/null +++ b/egulias/email-validator/EmailValidator/Parser/LocalPart.php @@ -0,0 +1,138 @@ +lexer->token['type'] !== EmailLexer::S_AT && $this->lexer->token) { + if ($this->lexer->token['type'] === EmailLexer::S_DOT && !$this->lexer->getPrevious()) { + throw new DotAtStart(); + } + + $closingQuote = $this->checkDQUOTE($closingQuote); + if ($closingQuote && $parseDQuote) { + $parseDQuote = $this->parseDoubleQuote(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->parseComments(); + $openedParenthesis += $this->getOpenedParenthesis(); + } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + if ($openedParenthesis === 0) { + throw new UnopenedComment(); + } else { + $openedParenthesis--; + } + } + + $this->checkConsecutiveDots(); + + if ($this->lexer->token['type'] === EmailLexer::S_DOT && + $this->lexer->isNextToken(EmailLexer::S_AT) + ) { + throw new DotAtEnd(); + } + + $this->warnEscaping(); + $this->isInvalidToken($this->lexer->token, $closingQuote); + + if ($this->isFWS()) { + $this->parseFWS(); + } + + $this->lexer->moveNext(); + } + + $prev = $this->lexer->getPrevious(); + if (strlen($prev['value']) > LocalTooLong::LOCAL_PART_LENGTH) { + $this->warnings[LocalTooLong::CODE] = new LocalTooLong(); + } + } + + protected function parseDoubleQuote() + { + $parseAgain = true; + $special = array( + EmailLexer::S_CR => true, + EmailLexer::S_HTAB => true, + EmailLexer::S_LF => true + ); + + $invalid = array( + EmailLexer::C_NUL => true, + EmailLexer::S_HTAB => true, + EmailLexer::S_CR => true, + EmailLexer::S_LF => true + ); + $setSpecialsWarning = true; + + $this->lexer->moveNext(); + + while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && $this->lexer->token) { + $parseAgain = false; + if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { + $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); + $setSpecialsWarning = false; + } + if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { + $this->lexer->moveNext(); + } + + $this->lexer->moveNext(); + + if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) { + throw new ExpectingATEXT(); + } + } + + $prev = $this->lexer->getPrevious(); + + if ($prev['type'] === EmailLexer::S_BACKSLASH) { + if (!$this->checkDQUOTE(false)) { + throw new UnclosedQuotedString(); + } + } + + if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) { + throw new ExpectingAT(); + } + + return $parseAgain; + } + + protected function isInvalidToken($token, $closingQuote) + { + $forbidden = array( + EmailLexer::S_COMMA, + EmailLexer::S_CLOSEBRACKET, + EmailLexer::S_OPENBRACKET, + EmailLexer::S_GREATERTHAN, + EmailLexer::S_LOWERTHAN, + EmailLexer::S_COLON, + EmailLexer::S_SEMICOLON, + EmailLexer::INVALID + ); + + if (in_array($token['type'], $forbidden) && !$closingQuote) { + throw new ExpectingATEXT(); + } + } +} diff --git a/egulias/email-validator/EmailValidator/Parser/Parser.php b/egulias/email-validator/EmailValidator/Parser/Parser.php new file mode 100644 index 000000000..e5042e1a8 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Parser/Parser.php @@ -0,0 +1,215 @@ +lexer = $lexer; + } + + public function getWarnings() + { + return $this->warnings; + } + + abstract public function parse($str); + + /** @return int */ + public function getOpenedParenthesis() + { + return $this->openedParenthesis; + } + + /** + * validateQuotedPair + */ + protected function validateQuotedPair() + { + if (!($this->lexer->token['type'] === EmailLexer::INVALID + || $this->lexer->token['type'] === EmailLexer::C_DEL)) { + throw new ExpectedQPair(); + } + + $this->warnings[QuotedPart::CODE] = + new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); + } + + protected function parseComments() + { + $this->openedParenthesis = 1; + $this->isUnclosedComment(); + $this->warnings[Comment::CODE] = new Comment(); + while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { + if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) { + $this->openedParenthesis++; + } + $this->warnEscaping(); + $this->lexer->moveNext(); + } + + $this->lexer->moveNext(); + if ($this->lexer->isNextTokenAny(array(EmailLexer::GENERIC, EmailLexer::S_EMPTY))) { + throw new ExpectingATEXT(); + } + + if ($this->lexer->isNextToken(EmailLexer::S_AT)) { + $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); + } + } + + protected function isUnclosedComment() + { + try { + $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); + return true; + } catch (\RuntimeException $e) { + throw new UnclosedComment(); + } + } + + protected function parseFWS() + { + $previous = $this->lexer->getPrevious(); + + $this->checkCRLFInFWS(); + + if ($this->lexer->token['type'] === EmailLexer::S_CR) { + throw new CRNoLF(); + } + + if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) { + throw new AtextAfterCFWS(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) { + throw new ExpectingCTEXT(); + } + + if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { + $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); + } else { + $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); + } + } + + protected function checkConsecutiveDots() + { + if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + throw new ConsecutiveDot(); + } + } + + protected function isFWS() + { + if ($this->escaped()) { + return false; + } + + if ($this->lexer->token['type'] === EmailLexer::S_SP || + $this->lexer->token['type'] === EmailLexer::S_HTAB || + $this->lexer->token['type'] === EmailLexer::S_CR || + $this->lexer->token['type'] === EmailLexer::S_LF || + $this->lexer->token['type'] === EmailLexer::CRLF + ) { + return true; + } + + return false; + } + + protected function escaped() + { + $previous = $this->lexer->getPrevious(); + + if ($previous['type'] === EmailLexer::S_BACKSLASH + && + $this->lexer->token['type'] !== EmailLexer::GENERIC + ) { + return true; + } + + return false; + } + + protected function warnEscaping() + { + if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + return false; + } + + if ($this->lexer->isNextToken(EmailLexer::GENERIC)) { + throw new ExpectingATEXT(); + } + + if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) { + return false; + } + + $this->warnings[QuotedPart::CODE] = + new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); + return true; + + } + + protected function checkDQUOTE($hasClosingQuote) + { + if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) { + return $hasClosingQuote; + } + if ($hasClosingQuote) { + return $hasClosingQuote; + } + $previous = $this->lexer->getPrevious(); + if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) { + throw new ExpectingATEXT(); + } + + try { + $this->lexer->find(EmailLexer::S_DQUOTE); + $hasClosingQuote = true; + } catch (\Exception $e) { + throw new UnclosedQuotedString(); + } + $this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']); + + return $hasClosingQuote; + } + + protected function checkCRLFInFWS() + { + if ($this->lexer->token['type'] !== EmailLexer::CRLF) { + return; + } + + if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { + throw new CRLFX2(); + } + + if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { + throw new CRLFAtTheEnd(); + } + } +} diff --git a/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php b/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php new file mode 100644 index 000000000..a03a58748 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php @@ -0,0 +1,61 @@ +checkDNS($host); + } + + public function getError() + { + return $this->error; + } + + public function getWarnings() + { + return $this->warnings; + } + + protected function checkDNS($host) + { + $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46), '.') . '.'; + + $Aresult = true; + $MXresult = checkdnsrr($host, 'MX'); + + if (!$MXresult) { + $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); + $Aresult = checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA'); + if (!$Aresult) { + $this->error = new NoDNSRecord(); + } + } + return $MXresult || $Aresult; + } +} diff --git a/egulias/email-validator/EmailValidator/Validation/EmailValidation.php b/egulias/email-validator/EmailValidator/Validation/EmailValidation.php new file mode 100644 index 000000000..d5a015be5 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Validation/EmailValidation.php @@ -0,0 +1,34 @@ +errors = $errors; + parent::__construct(); + } + + public function getErrors() + { + return $this->errors; + } +} diff --git a/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php b/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php new file mode 100644 index 000000000..43fa42a64 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php @@ -0,0 +1,110 @@ +validations = $validations; + $this->mode = $mode; + } + + /** + * {@inheritdoc} + */ + public function isValid($email, EmailLexer $emailLexer) + { + $result = true; + $errors = []; + foreach ($this->validations as $validation) { + $emailLexer->reset(); + $result = $result && $validation->isValid($email, $emailLexer); + $this->warnings = array_merge($this->warnings, $validation->getWarnings()); + $errors = $this->addNewError($validation->getError(), $errors); + + if ($this->shouldStop($result)) { + break; + } + } + + if (!empty($errors)) { + $this->error = new MultipleErrors($errors); + } + + return $result; + } + + private function addNewError($possibleError, array $errors) + { + if (null !== $possibleError) { + $errors[] = $possibleError; + } + + return $errors; + } + + private function shouldStop($result) + { + return !$result && $this->mode === self::STOP_ON_ERROR; + } + + /** + * {@inheritdoc} + */ + public function getError() + { + return $this->error; + } + + /** + * {@inheritdoc} + */ + public function getWarnings() + { + return $this->warnings; + } +} diff --git a/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php b/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php new file mode 100644 index 000000000..e4bf0cc4d --- /dev/null +++ b/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php @@ -0,0 +1,41 @@ +getWarnings())) { + return true; + } + + $this->error = new RFCWarnings(); + + return false; + } + + /** + * {@inheritdoc} + */ + public function getError() + { + return $this->error ?: parent::getError(); + } +} diff --git a/egulias/email-validator/EmailValidator/Validation/RFCValidation.php b/egulias/email-validator/EmailValidator/Validation/RFCValidation.php new file mode 100644 index 000000000..c4ffe3503 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Validation/RFCValidation.php @@ -0,0 +1,49 @@ +parser = new EmailParser($emailLexer); + try { + $this->parser->parse((string)$email); + } catch (InvalidEmail $invalid) { + $this->error = $invalid; + return false; + } + + $this->warnings = $this->parser->getWarnings(); + return true; + } + + public function getError() + { + return $this->error; + } + + public function getWarnings() + { + return $this->warnings; + } +} diff --git a/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php b/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php new file mode 100644 index 000000000..fe712f081 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php @@ -0,0 +1,45 @@ +setChecks(Spoofchecker::SINGLE_SCRIPT); + + if ($checker->isSuspicious($email)) { + $this->error = new SpoofEmail(); + } + + return $this->error === null; + } + + public function getError() + { + return $this->error; + } + + public function getWarnings() + { + return []; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php b/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php new file mode 100644 index 000000000..77e70f7f5 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php @@ -0,0 +1,14 @@ +message = 'Address literal in domain part'; + $this->rfcNumber = 5321; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php b/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php new file mode 100644 index 000000000..be43bbe6f --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php @@ -0,0 +1,13 @@ +message = "Deprecated folding white space near @"; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php b/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php new file mode 100644 index 000000000..dea3450ec --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php @@ -0,0 +1,13 @@ +message = 'Folding whites space followed by folding white space'; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/Comment.php b/egulias/email-validator/EmailValidator/Warning/Comment.php new file mode 100644 index 000000000..704c2908b --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/Comment.php @@ -0,0 +1,13 @@ +message = "Comments found in this email"; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php b/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php new file mode 100644 index 000000000..ad43bd7c9 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php @@ -0,0 +1,13 @@ +message = 'Deprecated comments'; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php b/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php new file mode 100644 index 000000000..6f36b5e29 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php @@ -0,0 +1,14 @@ +message = 'Domain Literal'; + $this->rfcNumber = 5322; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php b/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php new file mode 100644 index 000000000..61ff17a76 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php @@ -0,0 +1,14 @@ +message = 'Domain is too long, exceeds 255 chars'; + $this->rfcNumber = 5322; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php b/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php new file mode 100644 index 000000000..497309dbb --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php @@ -0,0 +1,15 @@ +message = 'Email is too long, exceeds ' . EmailParser::EMAIL_MAX_LENGTH; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php b/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php new file mode 100644 index 000000000..ba2fcc01b --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php @@ -0,0 +1,14 @@ +message = 'Bad char in IPV6 domain literal'; + $this->rfcNumber = 5322; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php b/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php new file mode 100644 index 000000000..41afa78c6 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php @@ -0,0 +1,14 @@ +message = ':: found at the end of the domain literal'; + $this->rfcNumber = 5322; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php b/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php new file mode 100644 index 000000000..1bf754e30 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php @@ -0,0 +1,14 @@ +message = ':: found at the start of the domain literal'; + $this->rfcNumber = 5322; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php b/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php new file mode 100644 index 000000000..d752caaa1 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php @@ -0,0 +1,14 @@ +message = 'Deprecated form of IPV6'; + $this->rfcNumber = 5321; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php b/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php new file mode 100644 index 000000000..4f8239499 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php @@ -0,0 +1,14 @@ +message = 'Double colon found after IPV6 tag'; + $this->rfcNumber = 5322; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php b/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php new file mode 100644 index 000000000..a59d317f2 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php @@ -0,0 +1,14 @@ +message = 'Group count is not IPV6 valid'; + $this->rfcNumber = 5322; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php b/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php new file mode 100644 index 000000000..936274c13 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php @@ -0,0 +1,14 @@ +message = 'Reached the maximum number of IPV6 groups allowed'; + $this->rfcNumber = 5321; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php b/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php new file mode 100644 index 000000000..daf07f408 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php @@ -0,0 +1,14 @@ +message = 'Label too long'; + $this->rfcNumber = 5322; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php b/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php new file mode 100644 index 000000000..0d08d8b35 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php @@ -0,0 +1,15 @@ +message = 'Local part is too long, exceeds 64 chars (octets)'; + $this->rfcNumber = 5322; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php b/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php new file mode 100644 index 000000000..b3c21a1f3 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php @@ -0,0 +1,14 @@ +message = 'No MX DSN record was found for this email'; + $this->rfcNumber = 5321; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php b/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php new file mode 100644 index 000000000..10f19e334 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php @@ -0,0 +1,14 @@ +rfcNumber = 5322; + $this->message = 'Obsolete DTEXT in domain literal'; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/QuotedPart.php b/egulias/email-validator/EmailValidator/Warning/QuotedPart.php new file mode 100644 index 000000000..7be9e6a3f --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/QuotedPart.php @@ -0,0 +1,13 @@ +message = "Deprecated Quoted String found between $prevToken and $postToken"; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/QuotedString.php b/egulias/email-validator/EmailValidator/Warning/QuotedString.php new file mode 100644 index 000000000..e9d56e1e0 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/QuotedString.php @@ -0,0 +1,13 @@ +message = "Quoted String found between $prevToken and $postToken"; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/TLD.php b/egulias/email-validator/EmailValidator/Warning/TLD.php new file mode 100644 index 000000000..2338b9f44 --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/TLD.php @@ -0,0 +1,13 @@ +message = "RFC5321, TLD"; + } +} diff --git a/egulias/email-validator/EmailValidator/Warning/Warning.php b/egulias/email-validator/EmailValidator/Warning/Warning.php new file mode 100644 index 000000000..ec6a365ff --- /dev/null +++ b/egulias/email-validator/EmailValidator/Warning/Warning.php @@ -0,0 +1,30 @@ +message; + } + + public function code() + { + return self::CODE; + } + + public function RFCNumber() + { + return $this->rfcNumber; + } + + public function __toString() + { + return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE; + } +} diff --git a/egulias/email-validator/LICENSE b/egulias/email-validator/LICENSE new file mode 100644 index 000000000..c34d2c197 --- /dev/null +++ b/egulias/email-validator/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013-2016 Eduardo Gulias Davis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/swiftmailer/swiftmailer/lib/classes/Swift.php b/swiftmailer/swiftmailer/lib/classes/Swift.php index 82c381b73..e89703eae 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift.php @@ -16,8 +16,7 @@ */ abstract class Swift { - /** Swift Mailer Version number generated during dist release process */ - const VERSION = '@SWIFT_VERSION_NUMBER@'; + const VERSION = '6.0.2'; public static $initialized = false; public static $inits = array(); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php b/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php index a95bccfdf..1fb232c9f 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php @@ -9,7 +9,7 @@ */ /** - * Attachment class for attaching files to a {@link Swift_Mime_Message}. + * Attachment class for attaching files to a {@link Swift_Mime_SimpleMessage}. * * @author Chris Corbyn */ @@ -39,20 +39,6 @@ public function __construct($data = null, $filename = null, $contentType = null) } } - /** - * Create a new Attachment. - * - * @param string|Swift_OutputByteStream $data - * @param string $filename - * @param string $contentType - * - * @return Swift_Mime_Attachment - */ - public static function newInstance($data = null, $filename = null, $contentType = null) - { - return new self($data, $filename, $contentType); - } - /** * Create a new Attachment from a filesystem path. * @@ -63,9 +49,9 @@ public static function newInstance($data = null, $filename = null, $contentType */ public static function fromPath($path, $contentType = null) { - return self::newInstance()->setFile( + return (new self())->setFile( new Swift_ByteStream_FileByteStream($path), $contentType - ); + ); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php index a7b0e3a62..bfd2c79bc 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php @@ -18,38 +18,38 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I /** * Write sequence. */ - protected $_sequence = 0; + protected $sequence = 0; /** * StreamFilters. * * @var Swift_StreamFilter[] */ - private $_filters = array(); + private $filters = array(); /** * A buffer for writing. */ - private $_writeBuffer = ''; + private $writeBuffer = ''; /** * Bound streams. * * @var Swift_InputByteStream[] */ - private $_mirrors = array(); + private $mirrors = array(); /** * Commit the given bytes to the storage medium immediately. * * @param string $bytes */ - abstract protected function _commit($bytes); + abstract protected function doCommit($bytes); /** * Flush any buffers/content with immediate effect. */ - abstract protected function _flush(); + abstract protected function flush(); /** * Add a StreamFilter to this InputByteStream. @@ -59,7 +59,7 @@ abstract protected function _flush(); */ public function addFilter(Swift_StreamFilter $filter, $key) { - $this->_filters[$key] = $filter; + $this->filters[$key] = $filter; } /** @@ -69,7 +69,7 @@ public function addFilter(Swift_StreamFilter $filter, $key) */ public function removeFilter($key) { - unset($this->_filters[$key]); + unset($this->filters[$key]); } /** @@ -83,15 +83,15 @@ public function removeFilter($key) */ public function write($bytes) { - $this->_writeBuffer .= $bytes; - foreach ($this->_filters as $filter) { - if ($filter->shouldBuffer($this->_writeBuffer)) { + $this->writeBuffer .= $bytes; + foreach ($this->filters as $filter) { + if ($filter->shouldBuffer($this->writeBuffer)) { return; } } - $this->_doWrite($this->_writeBuffer); + $this->doWrite($this->writeBuffer); - return ++$this->_sequence; + return ++$this->sequence; } /** @@ -102,7 +102,7 @@ public function write($bytes) */ public function commit() { - $this->_doWrite($this->_writeBuffer); + $this->doWrite($this->writeBuffer); } /** @@ -115,7 +115,7 @@ public function commit() */ public function bind(Swift_InputByteStream $is) { - $this->_mirrors[] = $is; + $this->mirrors[] = $is; } /** @@ -129,12 +129,12 @@ public function bind(Swift_InputByteStream $is) */ public function unbind(Swift_InputByteStream $is) { - foreach ($this->_mirrors as $k => $stream) { + foreach ($this->mirrors as $k => $stream) { if ($is === $stream) { - if ($this->_writeBuffer !== '') { - $stream->write($this->_writeBuffer); + if ($this->writeBuffer !== '') { + $stream->write($this->writeBuffer); } - unset($this->_mirrors[$k]); + unset($this->mirrors[$k]); } } } @@ -147,20 +147,20 @@ public function unbind(Swift_InputByteStream $is) */ public function flushBuffers() { - if ($this->_writeBuffer !== '') { - $this->_doWrite($this->_writeBuffer); + if ($this->writeBuffer !== '') { + $this->doWrite($this->writeBuffer); } - $this->_flush(); + $this->flush(); - foreach ($this->_mirrors as $stream) { + foreach ($this->mirrors as $stream) { $stream->flushBuffers(); } } /** Run $bytes through all filters */ - private function _filter($bytes) + private function filter($bytes) { - foreach ($this->_filters as $filter) { + foreach ($this->filters as $filter) { $bytes = $filter->filter($bytes); } @@ -168,14 +168,14 @@ private function _filter($bytes) } /** Just write the bytes to the stream */ - private function _doWrite($bytes) + private function doWrite($bytes) { - $this->_commit($this->_filter($bytes)); + $this->doCommit($this->filter($bytes)); - foreach ($this->_mirrors as $stream) { + foreach ($this->mirrors as $stream) { $stream->write($bytes); } - $this->_writeBuffer = ''; + $this->writeBuffer = ''; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php index ef05a6d5e..31b85e0e0 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php @@ -11,7 +11,7 @@ /** * Allows reading and writing of bytes to and from an array. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_OutputByteStream { @@ -20,28 +20,28 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O * * @var string[] */ - private $_array = array(); + private $array = array(); /** * The size of the stack. * * @var int */ - private $_arraySize = 0; + private $arraySize = 0; /** * The internal pointer offset. * * @var int */ - private $_offset = 0; + private $offset = 0; /** * Bound streams. * * @var Swift_InputByteStream[] */ - private $_mirrors = array(); + private $mirrors = array(); /** * Create a new ArrayByteStream. @@ -53,12 +53,12 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O public function __construct($stack = null) { if (is_array($stack)) { - $this->_array = $stack; - $this->_arraySize = count($stack); + $this->array = $stack; + $this->arraySize = count($stack); } elseif (is_string($stack)) { $this->write($stack); } else { - $this->_array = array(); + $this->array = array(); } } @@ -76,16 +76,16 @@ public function __construct($stack = null) */ public function read($length) { - if ($this->_offset == $this->_arraySize) { + if ($this->offset == $this->arraySize) { return false; } // Don't use array slice - $end = $length + $this->_offset; - $end = $this->_arraySize < $end ? $this->_arraySize : $end; + $end = $length + $this->offset; + $end = $this->arraySize < $end ? $this->arraySize : $end; $ret = ''; - for (; $this->_offset < $end; ++$this->_offset) { - $ret .= $this->_array[$this->_offset]; + for (; $this->offset < $end; ++$this->offset) { + $ret .= $this->array[$this->offset]; } return $ret; @@ -100,11 +100,11 @@ public function write($bytes) { $to_add = str_split($bytes); foreach ($to_add as $value) { - $this->_array[] = $value; + $this->array[] = $value; } - $this->_arraySize = count($this->_array); + $this->arraySize = count($this->array); - foreach ($this->_mirrors as $stream) { + foreach ($this->mirrors as $stream) { $stream->write($bytes); } } @@ -126,7 +126,7 @@ public function commit() */ public function bind(Swift_InputByteStream $is) { - $this->_mirrors[] = $is; + $this->mirrors[] = $is; } /** @@ -140,9 +140,9 @@ public function bind(Swift_InputByteStream $is) */ public function unbind(Swift_InputByteStream $is) { - foreach ($this->_mirrors as $k => $stream) { + foreach ($this->mirrors as $k => $stream) { if ($is === $stream) { - unset($this->_mirrors[$k]); + unset($this->mirrors[$k]); } } } @@ -156,13 +156,13 @@ public function unbind(Swift_InputByteStream $is) */ public function setReadPointer($byteOffset) { - if ($byteOffset > $this->_arraySize) { - $byteOffset = $this->_arraySize; + if ($byteOffset > $this->arraySize) { + $byteOffset = $this->arraySize; } elseif ($byteOffset < 0) { $byteOffset = 0; } - $this->_offset = $byteOffset; + $this->offset = $byteOffset; } /** @@ -171,11 +171,11 @@ public function setReadPointer($byteOffset) */ public function flushBuffers() { - $this->_offset = 0; - $this->_array = array(); - $this->_arraySize = 0; + $this->offset = 0; + $this->array = array(); + $this->arraySize = 0; - foreach ($this->_mirrors as $stream) { + foreach ($this->mirrors as $stream) { $stream->flushBuffers(); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php index 9ed852310..61f820e5a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php @@ -11,30 +11,27 @@ /** * Allows reading and writing of bytes to and from a file. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_FileStream { /** The internal pointer offset */ - private $_offset = 0; + private $offset = 0; /** The path to the file */ - private $_path; + private $path; /** The mode this file is opened in for writing */ - private $_mode; + private $mode; /** A lazy-loaded resource handle for reading the file */ - private $_reader; + private $reader; /** A lazy-loaded resource handle for writing the file */ - private $_writer; - - /** If magic_quotes_runtime is on, this will be true */ - private $_quotes = false; + private $writer; /** If stream is seekable true/false, or null if not known */ - private $_seekable = null; + private $seekable = null; /** * Create a new FileByteStream for $path. @@ -47,12 +44,8 @@ public function __construct($path, $writable = false) if (empty($path)) { throw new Swift_IoException('The path cannot be empty'); } - $this->_path = $path; - $this->_mode = $writable ? 'w+b' : 'rb'; - - if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) { - $this->_quotes = true; - } + $this->path = $path; + $this->mode = $writable ? 'w+b' : 'rb'; } /** @@ -62,7 +55,7 @@ public function __construct($path, $writable = false) */ public function getPath() { - return $this->_path; + return $this->path; } /** @@ -75,27 +68,21 @@ public function getPath() * * @param int $length * - * @throws Swift_IoException - * * @return string|bool + * + * @throws Swift_IoException */ public function read($length) { - $fp = $this->_getReadHandle(); + $fp = $this->getReadHandle(); if (!feof($fp)) { - if ($this->_quotes) { - ini_set('magic_quotes_runtime', 0); - } $bytes = fread($fp, $length); - if ($this->_quotes) { - ini_set('magic_quotes_runtime', 1); - } - $this->_offset = ftell($fp); + $this->offset = ftell($fp); // If we read one byte after reaching the end of the file // feof() will return false and an empty string is returned if ($bytes === '' && feof($fp)) { - $this->_resetReadHandle(); + $this->resetReadHandle(); return false; } @@ -103,7 +90,7 @@ public function read($length) return $bytes; } - $this->_resetReadHandle(); + $this->resetReadHandle(); return false; } @@ -117,95 +104,93 @@ public function read($length) */ public function setReadPointer($byteOffset) { - if (isset($this->_reader)) { - $this->_seekReadStreamToPosition($byteOffset); + if (isset($this->reader)) { + $this->seekReadStreamToPosition($byteOffset); } - $this->_offset = $byteOffset; + $this->offset = $byteOffset; } /** Just write the bytes to the file */ - protected function _commit($bytes) + protected function doCommit($bytes) { - fwrite($this->_getWriteHandle(), $bytes); - $this->_resetReadHandle(); + fwrite($this->getWriteHandle(), $bytes); + $this->resetReadHandle(); } /** Not used */ - protected function _flush() + protected function flush() { } /** Get the resource for reading */ - private function _getReadHandle() + private function getReadHandle() { - if (!isset($this->_reader)) { - $pointer = @fopen($this->_path, 'rb'); + if (!isset($this->reader)) { + $pointer = @fopen($this->path, 'rb'); if (!$pointer) { - throw new Swift_IoException( - 'Unable to open file for reading ['.$this->_path.']' - ); + throw new Swift_IoException('Unable to open file for reading ['.$this->path.']'); } - $this->_reader = $pointer; - if ($this->_offset != 0) { - $this->_getReadStreamSeekableStatus(); - $this->_seekReadStreamToPosition($this->_offset); + $this->reader = $pointer; + if ($this->offset != 0) { + $this->getReadStreamSeekableStatus(); + $this->seekReadStreamToPosition($this->offset); } } - return $this->_reader; + return $this->reader; } /** Get the resource for writing */ - private function _getWriteHandle() + private function getWriteHandle() { - if (!isset($this->_writer)) { - if (!$this->_writer = fopen($this->_path, $this->_mode)) { + if (!isset($this->writer)) { + if (!$this->writer = fopen($this->path, $this->mode)) { throw new Swift_IoException( - 'Unable to open file for writing ['.$this->_path.']' + 'Unable to open file for writing ['.$this->path.']' ); } } - return $this->_writer; + return $this->writer; } /** Force a reload of the resource for reading */ - private function _resetReadHandle() + private function resetReadHandle() { - if (isset($this->_reader)) { - fclose($this->_reader); - $this->_reader = null; + if (isset($this->reader)) { + fclose($this->reader); + $this->reader = null; } } /** Check if ReadOnly Stream is seekable */ - private function _getReadStreamSeekableStatus() + private function getReadStreamSeekableStatus() { - $metas = stream_get_meta_data($this->_reader); - $this->_seekable = $metas['seekable']; + $metas = stream_get_meta_data($this->reader); + $this->seekable = $metas['seekable']; } /** Streams in a readOnly stream ensuring copy if needed */ - private function _seekReadStreamToPosition($offset) + private function seekReadStreamToPosition($offset) { - if ($this->_seekable === null) { - $this->_getReadStreamSeekableStatus(); + if ($this->seekable === null) { + $this->getReadStreamSeekableStatus(); } - if ($this->_seekable === false) { - $currentPos = ftell($this->_reader); + if ($this->seekable === false) { + $currentPos = ftell($this->reader); if ($currentPos < $offset) { $toDiscard = $offset - $currentPos; - fread($this->_reader, $toDiscard); + fread($this->reader, $toDiscard); return; } - $this->_copyReadStream(); + $this->copyReadStream(); } - fseek($this->_reader, $offset, SEEK_SET); + fseek($this->reader, $offset, SEEK_SET); } /** Copy a readOnly Stream to ensure seekability */ - private function _copyReadStream() + private function copyReadStream() { if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) { /* We have opened a php:// Stream Should work without problem */ @@ -214,11 +199,11 @@ private function _copyReadStream() } else { throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); } - $currentPos = ftell($this->_reader); - fclose($this->_reader); - $source = fopen($this->_path, 'rb'); + $currentPos = ftell($this->reader); + fclose($this->reader); + $source = fopen($this->path, 'rb'); if (!$source) { - throw new Swift_IoException('Unable to open file for copying ['.$this->_path.']'); + throw new Swift_IoException('Unable to open file for copying ['.$this->path.']'); } fseek($tmpFile, 0, SEEK_SET); while (!feof($source)) { @@ -226,6 +211,6 @@ private function _copyReadStream() } fseek($tmpFile, $currentPos, SEEK_SET); fclose($source); - $this->_reader = $tmpFile; + $this->reader = $tmpFile; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php index 6a18e1dd1..b09bb5b6c 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php @@ -11,8 +11,8 @@ /** * Provides fixed-width byte sizes for reading fixed-width character sets. * - * @author Chris Corbyn - * @author Xavier De Cock + * @author Chris Corbyn + * @author Xavier De Cock */ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterReader { @@ -21,7 +21,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe * * @var int */ - private $_width; + private $width; /** * Creates a new GenericFixedWidthReader using $width bytes per character. @@ -30,7 +30,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe */ public function __construct($width) { - $this->_width = $width; + $this->width = $width; } /** @@ -47,11 +47,11 @@ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredC { $strlen = strlen($string); // % and / are CPU intensive, so, maybe find a better way - $ignored = $strlen % $this->_width; + $ignored = $strlen % $this->width; $ignoredChars = $ignored ? substr($string, -$ignored) : ''; - $currentMap = $this->_width; + $currentMap = $this->width; - return ($strlen - $ignored) / $this->_width; + return ($strlen - $ignored) / $this->width; } /** @@ -80,7 +80,7 @@ public function getMapType() */ public function validateByteSequence($bytes, $size) { - $needed = $this->_width - $size; + $needed = $this->width - $size; return $needed > -1 ? $needed : -1; } @@ -92,6 +92,6 @@ public function validateByteSequence($bytes, $size) */ public function getInitialByteSize() { - return $this->_width; + return $this->width; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php index 9171a0bac..f3641f46b 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php @@ -20,14 +20,14 @@ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift * * @var array */ - private static $_map = array(); + private static $map = array(); /** * Factories which have already been loaded. * * @var Swift_CharacterReaderFactory[] */ - private static $_loaded = array(); + private static $loaded = array(); /** * Creates a new CharacterReaderFactory. @@ -44,7 +44,7 @@ public function __wakeup() public function init() { - if (count(self::$_map) > 0) { + if (count(self::$map) > 0) { return; } @@ -66,32 +66,32 @@ public function init() ); // Utf-8 - self::$_map['utf-?8'] = array( + self::$map['utf-?8'] = array( 'class' => $prefix.'Utf8Reader', 'constructor' => array(), ); //7-8 bit charsets - self::$_map['(us-)?ascii'] = $singleByte; - self::$_map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; - self::$_map['windows-?125[0-9]'] = $singleByte; - self::$_map['cp-?[0-9]+'] = $singleByte; - self::$_map['ansi'] = $singleByte; - self::$_map['macintosh'] = $singleByte; - self::$_map['koi-?7'] = $singleByte; - self::$_map['koi-?8-?.+'] = $singleByte; - self::$_map['mik'] = $singleByte; - self::$_map['(cork|t1)'] = $singleByte; - self::$_map['v?iscii'] = $singleByte; + self::$map['(us-)?ascii'] = $singleByte; + self::$map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; + self::$map['windows-?125[0-9]'] = $singleByte; + self::$map['cp-?[0-9]+'] = $singleByte; + self::$map['ansi'] = $singleByte; + self::$map['macintosh'] = $singleByte; + self::$map['koi-?7'] = $singleByte; + self::$map['koi-?8-?.+'] = $singleByte; + self::$map['mik'] = $singleByte; + self::$map['(cork|t1)'] = $singleByte; + self::$map['v?iscii'] = $singleByte; //16 bits - self::$_map['(ucs-?2|utf-?16)'] = $doubleByte; + self::$map['(ucs-?2|utf-?16)'] = $doubleByte; //32 bits - self::$_map['(ucs-?4|utf-?32)'] = $fourBytes; + self::$map['(ucs-?4|utf-?32)'] = $fourBytes; // Fallback - self::$_map['.*'] = $singleByte; + self::$map['.*'] = $singleByte; } /** @@ -103,21 +103,21 @@ public function init() */ public function getReaderFor($charset) { - $charset = trim(strtolower($charset)); - foreach (self::$_map as $pattern => $spec) { + $charset = strtolower(trim($charset)); + foreach (self::$map as $pattern => $spec) { $re = '/^'.$pattern.'$/D'; if (preg_match($re, $charset)) { - if (!array_key_exists($pattern, self::$_loaded)) { + if (!array_key_exists($pattern, self::$loaded)) { $reflector = new ReflectionClass($spec['class']); if ($reflector->getConstructor()) { $reader = $reflector->newInstanceArgs($spec['constructor']); } else { $reader = $reflector->newInstance(); } - self::$_loaded[$pattern] = $reader; + self::$loaded[$pattern] = $reader; } - return self::$_loaded[$pattern]; + return self::$loaded[$pattern]; } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php index 7213a40d7..fbfbceb01 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php @@ -16,28 +16,28 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStream { /** A map of byte values and their respective characters */ - private static $_charMap; + private static $charMap; /** A map of characters and their derivative byte values */ - private static $_byteMap; + private static $byteMap; /** The char reader (lazy-loaded) for the current charset */ - private $_charReader; + private $charReader; /** A factory for creating CharacterReader instances */ - private $_charReaderFactory; + private $charReaderFactory; /** The character set this stream is using */ - private $_charset; + private $charset; /** Array of characters */ - private $_array = array(); + private $array = array(); /** Size of the array of character */ - private $_array_size = array(); + private $array_size = array(); /** The current character offset in the stream */ - private $_offset = 0; + private $offset = 0; /** * Create a new CharacterStream with the given $chars, if set. @@ -47,7 +47,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea */ public function __construct(Swift_CharacterReaderFactory $factory, $charset) { - self::_initializeMaps(); + self::initializeMaps(); $this->setCharacterReaderFactory($factory); $this->setCharacterSet($charset); } @@ -59,8 +59,8 @@ public function __construct(Swift_CharacterReaderFactory $factory, $charset) */ public function setCharacterSet($charset) { - $this->_charset = $charset; - $this->_charReader = null; + $this->charset = $charset; + $this->charReader = null; } /** @@ -70,7 +70,7 @@ public function setCharacterSet($charset) */ public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) { - $this->_charReaderFactory = $factory; + $this->charReaderFactory = $factory; } /** @@ -80,28 +80,28 @@ public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) */ public function importByteStream(Swift_OutputByteStream $os) { - if (!isset($this->_charReader)) { - $this->_charReader = $this->_charReaderFactory - ->getReaderFor($this->_charset); + if (!isset($this->charReader)) { + $this->charReader = $this->charReaderFactory + ->getReaderFor($this->charset); } - $startLength = $this->_charReader->getInitialByteSize(); + $startLength = $this->charReader->getInitialByteSize(); while (false !== $bytes = $os->read($startLength)) { $c = array(); for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { - $c[] = self::$_byteMap[$bytes[$i]]; + $c[] = self::$byteMap[$bytes[$i]]; } $size = count($c); - $need = $this->_charReader + $need = $this->charReader ->validateByteSequence($c, $size); if ($need > 0 && false !== $bytes = $os->read($need)) { for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { - $c[] = self::$_byteMap[$bytes[$i]]; + $c[] = self::$byteMap[$bytes[$i]]; } } - $this->_array[] = $c; - ++$this->_array_size; + $this->array[] = $c; + ++$this->array_size; } } @@ -127,20 +127,20 @@ public function importString($string) */ public function read($length) { - if ($this->_offset == $this->_array_size) { + if ($this->offset == $this->array_size) { return false; } // Don't use array slice $arrays = array(); - $end = $length + $this->_offset; - for ($i = $this->_offset; $i < $end; ++$i) { - if (!isset($this->_array[$i])) { + $end = $length + $this->offset; + for ($i = $this->offset; $i < $end; ++$i) { + if (!isset($this->array[$i])) { break; } - $arrays[] = $this->_array[$i]; + $arrays[] = $this->array[$i]; } - $this->_offset += $i - $this->_offset; // Limit function calls + $this->offset += $i - $this->offset; // Limit function calls $chars = false; foreach ($arrays as $array) { $chars .= implode('', array_map('chr', $array)); @@ -159,20 +159,20 @@ public function read($length) */ public function readBytes($length) { - if ($this->_offset == $this->_array_size) { + if ($this->offset == $this->array_size) { return false; } $arrays = array(); - $end = $length + $this->_offset; - for ($i = $this->_offset; $i < $end; ++$i) { - if (!isset($this->_array[$i])) { + $end = $length + $this->offset; + for ($i = $this->offset; $i < $end; ++$i) { + if (!isset($this->array[$i])) { break; } - $arrays[] = $this->_array[$i]; + $arrays[] = $this->array[$i]; } - $this->_offset += ($i - $this->_offset); // Limit function calls + $this->offset += ($i - $this->offset); // Limit function calls - return call_user_func_array('array_merge', $arrays); + return array_merge(...$arrays); } /** @@ -182,12 +182,12 @@ public function readBytes($length) */ public function write($chars) { - if (!isset($this->_charReader)) { - $this->_charReader = $this->_charReaderFactory->getReaderFor( - $this->_charset); + if (!isset($this->charReader)) { + $this->charReader = $this->charReaderFactory->getReaderFor( + $this->charset); } - $startLength = $this->_charReader->getInitialByteSize(); + $startLength = $this->charReader->getInitialByteSize(); $fp = fopen('php://memory', 'w+b'); fwrite($fp, $chars); @@ -203,7 +203,7 @@ public function write($chars) // Buffer Filing if ($buf_len - $buf_pos < $startLength) { $buf = array_splice($buffer, $buf_pos); - $new = $this->_reloadBuffer($fp, 100); + $new = $this->reloadBuffer($fp, 100); if ($new) { $buffer = array_merge($buf, $new); $buf_len = count($buffer); @@ -218,11 +218,11 @@ public function write($chars) ++$size; $bytes[] = $buffer[$buf_pos++]; } - $need = $this->_charReader->validateByteSequence( + $need = $this->charReader->validateByteSequence( $bytes, $size); if ($need > 0) { if ($buf_len - $buf_pos < $need) { - $new = $this->_reloadBuffer($fp, $need); + $new = $this->reloadBuffer($fp, $need); if ($new) { $buffer = array_merge($buffer, $new); @@ -233,8 +233,8 @@ public function write($chars) $bytes[] = $buffer[$buf_pos++]; } } - $this->_array[] = $bytes; - ++$this->_array_size; + $this->array[] = $bytes; + ++$this->array_size; } } while ($has_datas); @@ -248,12 +248,12 @@ public function write($chars) */ public function setPointer($charOffset) { - if ($charOffset > $this->_array_size) { - $charOffset = $this->_array_size; + if ($charOffset > $this->array_size) { + $charOffset = $this->array_size; } elseif ($charOffset < 0) { $charOffset = 0; } - $this->_offset = $charOffset; + $this->offset = $charOffset; } /** @@ -261,17 +261,17 @@ public function setPointer($charOffset) */ public function flushContents() { - $this->_offset = 0; - $this->_array = array(); - $this->_array_size = 0; + $this->offset = 0; + $this->array = array(); + $this->array_size = 0; } - private function _reloadBuffer($fp, $len) + private function reloadBuffer($fp, $len) { if (!feof($fp) && ($bytes = fread($fp, $len)) !== false) { $buf = array(); for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { - $buf[] = self::$_byteMap[$bytes[$i]]; + $buf[] = self::$byteMap[$bytes[$i]]; } return $buf; @@ -280,14 +280,14 @@ private function _reloadBuffer($fp, $len) return false; } - private static function _initializeMaps() + private static function initializeMaps() { - if (!isset(self::$_charMap)) { - self::$_charMap = array(); + if (!isset(self::$charMap)) { + self::$charMap = array(); for ($byte = 0; $byte < 256; ++$byte) { - self::$_charMap[$byte] = chr($byte); + self::$charMap[$byte] = chr($byte); } - self::$_byteMap = array_flip(self::$_charMap); + self::$byteMap = array_flip(self::$charMap); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php index 58bd140fd..0d62fa68f 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php @@ -11,7 +11,7 @@ /** * A CharacterStream implementation which stores characters in an internal array. * - * @author Xavier De Cock + * @author Xavier De Cock */ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream { @@ -20,63 +20,63 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream * * @var Swift_CharacterReader */ - private $_charReader; + private $charReader; /** * A factory for creating CharacterReader instances. * * @var Swift_CharacterReaderFactory */ - private $_charReaderFactory; + private $charReaderFactory; /** * The character set this stream is using. * * @var string */ - private $_charset; + private $charset; /** * The data's stored as-is. * * @var string */ - private $_datas = ''; + private $datas = ''; /** * Number of bytes in the stream. * * @var int */ - private $_datasSize = 0; + private $datasSize = 0; /** * Map. * * @var mixed */ - private $_map; + private $map; /** * Map Type. * * @var int */ - private $_mapType = 0; + private $mapType = 0; /** * Number of characters in the stream. * * @var int */ - private $_charCount = 0; + private $charCount = 0; /** * Position in the stream. * * @var int */ - private $_currentPos = 0; + private $currentPos = 0; /** * Constructor. @@ -99,9 +99,9 @@ public function __construct(Swift_CharacterReaderFactory $factory, $charset) */ public function setCharacterSet($charset) { - $this->_charset = $charset; - $this->_charReader = null; - $this->_mapType = 0; + $this->charset = $charset; + $this->charReader = null; + $this->mapType = 0; } /** @@ -111,7 +111,7 @@ public function setCharacterSet($charset) */ public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) { - $this->_charReaderFactory = $factory; + $this->charReaderFactory = $factory; } /** @@ -119,11 +119,11 @@ public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) */ public function flushContents() { - $this->_datas = null; - $this->_map = null; - $this->_charCount = 0; - $this->_currentPos = 0; - $this->_datasSize = 0; + $this->datas = null; + $this->map = null; + $this->charCount = 0; + $this->currentPos = 0; + $this->datasSize = 0; } /** @@ -161,49 +161,49 @@ public function importString($string) */ public function read($length) { - if ($this->_currentPos >= $this->_charCount) { + if ($this->currentPos >= $this->charCount) { return false; } $ret = false; - $length = $this->_currentPos + $length > $this->_charCount ? $this->_charCount - $this->_currentPos : $length; - switch ($this->_mapType) { + $length = ($this->currentPos + $length > $this->charCount) ? $this->charCount - $this->currentPos : $length; + switch ($this->mapType) { case Swift_CharacterReader::MAP_TYPE_FIXED_LEN: - $len = $length * $this->_map; - $ret = substr($this->_datas, - $this->_currentPos * $this->_map, + $len = $length * $this->map; + $ret = substr($this->datas, + $this->currentPos * $this->map, $len); - $this->_currentPos += $length; + $this->currentPos += $length; break; case Swift_CharacterReader::MAP_TYPE_INVALID: $ret = ''; - for (; $this->_currentPos < $length; ++$this->_currentPos) { - if (isset($this->_map[$this->_currentPos])) { + for (; $this->currentPos < $length; ++$this->currentPos) { + if (isset($this->map[$this->currentPos])) { $ret .= '?'; } else { - $ret .= $this->_datas[$this->_currentPos]; + $ret .= $this->datas[$this->currentPos]; } } break; case Swift_CharacterReader::MAP_TYPE_POSITIONS: - $end = $this->_currentPos + $length; - $end = $end > $this->_charCount ? $this->_charCount : $end; + $end = $this->currentPos + $length; + $end = $end > $this->charCount ? $this->charCount : $end; $ret = ''; $start = 0; - if ($this->_currentPos > 0) { - $start = $this->_map['p'][$this->_currentPos - 1]; + if ($this->currentPos > 0) { + $start = $this->map['p'][$this->currentPos - 1]; } $to = $start; - for (; $this->_currentPos < $end; ++$this->_currentPos) { - if (isset($this->_map['i'][$this->_currentPos])) { - $ret .= substr($this->_datas, $start, $to - $start).'?'; - $start = $this->_map['p'][$this->_currentPos]; + for (; $this->currentPos < $end; ++$this->currentPos) { + if (isset($this->map['i'][$this->currentPos])) { + $ret .= substr($this->datas, $start, $to - $start).'?'; + $start = $this->map['p'][$this->currentPos]; } else { - $to = $this->_map['p'][$this->_currentPos]; + $to = $this->map['p'][$this->currentPos]; } } - $ret .= substr($this->_datas, $start, $to - $start); + $ret .= substr($this->datas, $start, $to - $start); break; } @@ -236,10 +236,10 @@ public function readBytes($length) */ public function setPointer($charOffset) { - if ($this->_charCount < $charOffset) { - $charOffset = $this->_charCount; + if ($this->charCount < $charOffset) { + $charOffset = $this->charCount; } - $this->_currentPos = $charOffset; + $this->currentPos = $charOffset; } /** @@ -249,19 +249,19 @@ public function setPointer($charOffset) */ public function write($chars) { - if (!isset($this->_charReader)) { - $this->_charReader = $this->_charReaderFactory->getReaderFor( - $this->_charset); - $this->_map = array(); - $this->_mapType = $this->_charReader->getMapType(); + if (!isset($this->charReader)) { + $this->charReader = $this->charReaderFactory->getReaderFor( + $this->charset); + $this->map = array(); + $this->mapType = $this->charReader->getMapType(); } $ignored = ''; - $this->_datas .= $chars; - $this->_charCount += $this->_charReader->getCharPositions(substr($this->_datas, $this->_datasSize), $this->_datasSize, $this->_map, $ignored); + $this->datas .= $chars; + $this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored); if ($ignored !== false) { - $this->_datasSize = strlen($this->_datas) - strlen($ignored); + $this->datasSize = strlen($this->datas) - strlen($ignored); } else { - $this->_datasSize = strlen($this->_datas); + $this->datasSize = strlen($this->datas); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php b/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php index 4ae5bacfc..a711bac47 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php @@ -16,10 +16,10 @@ abstract class Swift_ConfigurableSpool implements Swift_Spool { /** The maximum number of messages to send per flush */ - private $_message_limit; + private $message_limit; /** The time limit per flush */ - private $_time_limit; + private $time_limit; /** * Sets the maximum number of messages to send per flush. @@ -28,7 +28,7 @@ abstract class Swift_ConfigurableSpool implements Swift_Spool */ public function setMessageLimit($limit) { - $this->_message_limit = (int) $limit; + $this->message_limit = (int) $limit; } /** @@ -38,7 +38,7 @@ public function setMessageLimit($limit) */ public function getMessageLimit() { - return $this->_message_limit; + return $this->message_limit; } /** @@ -48,7 +48,7 @@ public function getMessageLimit() */ public function setTimeLimit($limit) { - $this->_time_limit = (int) $limit; + $this->time_limit = (int) $limit; } /** @@ -58,6 +58,6 @@ public function setTimeLimit($limit) */ public function getTimeLimit() { - return $this->_time_limit; + return $this->time_limit; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php b/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php index befec9ac0..b1bc3306f 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php @@ -11,7 +11,7 @@ /** * Dependency Injection container. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_DependencyContainer { @@ -28,13 +28,13 @@ class Swift_DependencyContainer const TYPE_ALIAS = 0x1000; /** Singleton instance */ - private static $_instance = null; + private static $instance = null; /** The data container */ - private $_store = array(); + private $store = array(); /** The current endpoint in the data container */ - private $_endPoint; + private $endPoint; /** * Constructor should not be used. @@ -52,11 +52,11 @@ public function __construct() */ public static function getInstance() { - if (!isset(self::$_instance)) { - self::$_instance = new self(); + if (!isset(self::$instance)) { + self::$instance = new self(); } - return self::$_instance; + return self::$instance; } /** @@ -66,7 +66,7 @@ public static function getInstance() */ public function listItems() { - return array_keys($this->_store); + return array_keys($this->store); } /** @@ -80,8 +80,8 @@ public function listItems() */ public function has($itemName) { - return array_key_exists($itemName, $this->_store) - && isset($this->_store[$itemName]['lookupType']); + return array_key_exists($itemName, $this->store) + && isset($this->store[$itemName]['lookupType']); } /** @@ -91,9 +91,9 @@ public function has($itemName) * * @param string $itemName * - * @throws Swift_DependencyException If the dependency is not found - * * @return mixed + * + * @throws Swift_DependencyException If the dependency is not found */ public function lookup($itemName) { @@ -103,15 +103,15 @@ public function lookup($itemName) ); } - switch ($this->_store[$itemName]['lookupType']) { + switch ($this->store[$itemName]['lookupType']) { case self::TYPE_ALIAS: - return $this->_createAlias($itemName); + return $this->createAlias($itemName); case self::TYPE_VALUE: - return $this->_getValue($itemName); + return $this->getValue($itemName); case self::TYPE_INSTANCE: - return $this->_createNewInstance($itemName); + return $this->createNewInstance($itemName); case self::TYPE_SHARED: - return $this->_createSharedInstance($itemName); + return $this->createSharedInstance($itemName); } } @@ -125,8 +125,8 @@ public function lookup($itemName) public function createDependenciesFor($itemName) { $args = array(); - if (isset($this->_store[$itemName]['args'])) { - $args = $this->_resolveArgs($this->_store[$itemName]['args']); + if (isset($this->store[$itemName]['args'])) { + $args = $this->resolveArgs($this->store[$itemName]['args']); } return $args; @@ -147,8 +147,8 @@ public function createDependenciesFor($itemName) */ public function register($itemName) { - $this->_store[$itemName] = array(); - $this->_endPoint = &$this->_store[$itemName]; + $this->store[$itemName] = array(); + $this->endPoint = &$this->store[$itemName]; return $this; } @@ -164,7 +164,7 @@ public function register($itemName) */ public function asValue($value) { - $endPoint = &$this->_getEndPoint(); + $endPoint = &$this->getEndPoint(); $endPoint['lookupType'] = self::TYPE_VALUE; $endPoint['value'] = $value; @@ -180,7 +180,7 @@ public function asValue($value) */ public function asAliasOf($lookup) { - $endPoint = &$this->_getEndPoint(); + $endPoint = &$this->getEndPoint(); $endPoint['lookupType'] = self::TYPE_ALIAS; $endPoint['ref'] = $lookup; @@ -202,7 +202,7 @@ public function asAliasOf($lookup) */ public function asNewInstanceOf($className) { - $endPoint = &$this->_getEndPoint(); + $endPoint = &$this->getEndPoint(); $endPoint['lookupType'] = self::TYPE_INSTANCE; $endPoint['className'] = $className; @@ -220,7 +220,7 @@ public function asNewInstanceOf($className) */ public function asSharedInstanceOf($className) { - $endPoint = &$this->_getEndPoint(); + $endPoint = &$this->getEndPoint(); $endPoint['lookupType'] = self::TYPE_SHARED; $endPoint['className'] = $className; @@ -240,7 +240,7 @@ public function asSharedInstanceOf($className) */ public function withDependencies(array $lookups) { - $endPoint = &$this->_getEndPoint(); + $endPoint = &$this->getEndPoint(); $endPoint['args'] = array(); foreach ($lookups as $lookup) { $this->addConstructorLookup($lookup); @@ -261,7 +261,7 @@ public function withDependencies(array $lookups) */ public function addConstructorValue($value) { - $endPoint = &$this->_getEndPoint(); + $endPoint = &$this->getEndPoint(); if (!isset($endPoint['args'])) { $endPoint['args'] = array(); } @@ -282,8 +282,8 @@ public function addConstructorValue($value) */ public function addConstructorLookup($lookup) { - $endPoint = &$this->_getEndPoint(); - if (!isset($this->_endPoint['args'])) { + $endPoint = &$this->getEndPoint(); + if (!isset($this->endPoint['args'])) { $endPoint['args'] = array(); } $endPoint['args'][] = array('type' => 'lookup', 'item' => $lookup); @@ -292,21 +292,21 @@ public function addConstructorLookup($lookup) } /** Get the literal value with $itemName */ - private function _getValue($itemName) + private function getValue($itemName) { - return $this->_store[$itemName]['value']; + return $this->store[$itemName]['value']; } /** Resolve an alias to another item */ - private function _createAlias($itemName) + private function createAlias($itemName) { - return $this->lookup($this->_store[$itemName]['ref']); + return $this->lookup($this->store[$itemName]['ref']); } /** Create a fresh instance of $itemName */ - private function _createNewInstance($itemName) + private function createNewInstance($itemName) { - $reflector = new ReflectionClass($this->_store[$itemName]['className']); + $reflector = new ReflectionClass($this->store[$itemName]['className']); if ($reflector->getConstructor()) { return $reflector->newInstanceArgs( $this->createDependenciesFor($itemName) @@ -317,35 +317,35 @@ private function _createNewInstance($itemName) } /** Create and register a shared instance of $itemName */ - private function _createSharedInstance($itemName) + private function createSharedInstance($itemName) { - if (!isset($this->_store[$itemName]['instance'])) { - $this->_store[$itemName]['instance'] = $this->_createNewInstance($itemName); + if (!isset($this->store[$itemName]['instance'])) { + $this->store[$itemName]['instance'] = $this->createNewInstance($itemName); } - return $this->_store[$itemName]['instance']; + return $this->store[$itemName]['instance']; } /** Get the current endpoint in the store */ - private function &_getEndPoint() + private function &getEndPoint() { - if (!isset($this->_endPoint)) { + if (!isset($this->endPoint)) { throw new BadMethodCallException( 'Component must first be registered by calling register()' ); } - return $this->_endPoint; + return $this->endPoint; } /** Get an argument list with dependencies resolved */ - private function _resolveArgs(array $args) + private function resolveArgs(array $args) { $resolved = array(); foreach ($args as $argDefinition) { switch ($argDefinition['type']) { case 'lookup': - $resolved[] = $this->_lookupRecursive($argDefinition['item']); + $resolved[] = $this->lookupRecursive($argDefinition['item']); break; case 'value': $resolved[] = $argDefinition['item']; @@ -357,12 +357,12 @@ private function _resolveArgs(array $args) } /** Resolve a single dependency with an collections */ - private function _lookupRecursive($item) + private function lookupRecursive($item) { if (is_array($item)) { $collection = array(); foreach ($item as $k => $v) { - $collection[$k] = $this->_lookupRecursive($v); + $collection[$k] = $this->lookupRecursive($v); } return $collection; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php b/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php index d8c72ad4d..9755a88e1 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php @@ -39,20 +39,6 @@ public function __construct($data = null, $filename = null, $contentType = null) } } - /** - * Create a new EmbeddedFile. - * - * @param string|Swift_OutputByteStream $data - * @param string $filename - * @param string $contentType - * - * @return Swift_Mime_EmbeddedFile - */ - public static function newInstance($data = null, $filename = null, $contentType = null) - { - return new self($data, $filename, $contentType); - } - /** * Create a new EmbeddedFile from a filesystem path. * @@ -62,8 +48,6 @@ public static function newInstance($data = null, $filename = null, $contentType */ public static function fromPath($path) { - return self::newInstance()->setFile( - new Swift_ByteStream_FileByteStream($path) - ); + return (new self())->setFile(new Swift_ByteStream_FileByteStream($path)); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php index edec10c51..b23b07702 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php @@ -13,7 +13,7 @@ * * Possibly the most accurate RFC 2045 QP implementation found in PHP. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Encoder_QpEncoder implements Swift_Encoder { @@ -22,21 +22,21 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder * * @var Swift_CharacterStream */ - protected $_charStream; + protected $charStream; /** * A filter used if input should be canonicalized. * * @var Swift_StreamFilter */ - protected $_filter; + protected $filter; /** * Pre-computed QP for HUGE optimization. * * @var string[] */ - protected static $_qpMap = array( + protected static $qpMap = array( 0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', @@ -91,14 +91,14 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder 255 => '=FF', ); - protected static $_safeMapShare = array(); + protected static $safeMapShare = array(); /** * A map of non-encoded ascii characters. * * @var string[] */ - protected $_safeMap = array(); + protected $safeMap = array(); /** * Creates a new QpEncoder for the given CharacterStream. @@ -108,28 +108,28 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder */ public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null) { - $this->_charStream = $charStream; - if (!isset(self::$_safeMapShare[$this->getSafeMapShareId()])) { + $this->charStream = $charStream; + if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { $this->initSafeMap(); - self::$_safeMapShare[$this->getSafeMapShareId()] = $this->_safeMap; + self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; } else { - $this->_safeMap = self::$_safeMapShare[$this->getSafeMapShareId()]; + $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; } - $this->_filter = $filter; + $this->filter = $filter; } public function __sleep() { - return array('_charStream', '_filter'); + return array('charStream', 'filter'); } public function __wakeup() { - if (!isset(self::$_safeMapShare[$this->getSafeMapShareId()])) { + if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { $this->initSafeMap(); - self::$_safeMapShare[$this->getSafeMapShareId()] = $this->_safeMap; + self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; } else { - $this->_safeMap = self::$_safeMapShare[$this->getSafeMapShareId()]; + $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; } } @@ -142,7 +142,7 @@ protected function initSafeMap() { foreach (array_merge( array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) { - $this->_safeMap[$byte] = chr($byte); + $this->safeMap[$byte] = chr($byte); } } @@ -173,19 +173,19 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) $currentLine = &$lines[$lNo++]; $size = $lineLen = 0; - $this->_charStream->flushContents(); - $this->_charStream->importString($string); + $this->charStream->flushContents(); + $this->charStream->importString($string); // Fetching more than 4 chars at one is slower, as is fetching fewer bytes // Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to 6 // bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes - while (false !== $bytes = $this->_nextSequence()) { + while (false !== $bytes = $this->nextSequence()) { // If we're filtering the input - if (isset($this->_filter)) { + if (isset($this->filter)) { // If we can't filter because we need more bytes - while ($this->_filter->shouldBuffer($bytes)) { + while ($this->filter->shouldBuffer($bytes)) { // Then collect bytes into the buffer - if (false === $moreBytes = $this->_nextSequence(1)) { + if (false === $moreBytes = $this->nextSequence(1)) { break; } @@ -194,10 +194,10 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) } } // And filter them - $bytes = $this->_filter->filter($bytes); + $bytes = $this->filter->filter($bytes); } - $enc = $this->_encodeByteSequence($bytes, $size); + $enc = $this->encodeByteSequence($bytes, $size); $i = strpos($enc, '=0D=0A'); $newLineLength = $lineLen + ($i === false ? $size : $i); @@ -219,7 +219,7 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) } } - return $this->_standardize(implode("=\r\n", $lines)); + return $this->standardize(implode("=\r\n", $lines)); } /** @@ -229,7 +229,7 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) */ public function charsetChanged($charset) { - $this->_charStream->setCharacterSet($charset); + $this->charStream->setCharacterSet($charset); } /** @@ -240,16 +240,16 @@ public function charsetChanged($charset) * * @return string */ - protected function _encodeByteSequence(array $bytes, &$size) + protected function encodeByteSequence(array $bytes, &$size) { $ret = ''; $size = 0; foreach ($bytes as $b) { - if (isset($this->_safeMap[$b])) { - $ret .= $this->_safeMap[$b]; + if (isset($this->safeMap[$b])) { + $ret .= $this->safeMap[$b]; ++$size; } else { - $ret .= self::$_qpMap[$b]; + $ret .= self::$qpMap[$b]; $size += 3; } } @@ -264,9 +264,9 @@ protected function _encodeByteSequence(array $bytes, &$size) * * @return int[] */ - protected function _nextSequence($size = 4) + protected function nextSequence($size = 4) { - return $this->_charStream->readBytes($size); + return $this->charStream->readBytes($size); } /** @@ -276,7 +276,7 @@ protected function _nextSequence($size = 4) * * @return string */ - protected function _standardize($string) + protected function standardize($string) { $string = str_replace(array("\t=0D=0A", ' =0D=0A', '=0D=0A'), array("=09\r\n", "=20\r\n", "\r\n"), $string @@ -284,7 +284,7 @@ protected function _standardize($string) switch ($end = ord(substr($string, -1))) { case 0x09: case 0x20: - $string = substr_replace($string, self::$_qpMap[$end], -1); + $string = substr_replace($string, self::$qpMap[$end], -1); } return $string; @@ -295,6 +295,6 @@ protected function _standardize($string) */ public function __clone() { - $this->_charStream = clone $this->_charStream; + $this->charStream = clone $this->charStream; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php index b0215e883..bebb13494 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php @@ -20,7 +20,7 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder * * @var Swift_CharacterStream */ - private $_charStream; + private $charStream; /** * Creates a new Rfc2231Encoder using the given character stream instance. @@ -29,7 +29,7 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder */ public function __construct(Swift_CharacterStream $charStream) { - $this->_charStream = $charStream; + $this->charStream = $charStream; } /** @@ -53,12 +53,12 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) $maxLineLength = 75; } - $this->_charStream->flushContents(); - $this->_charStream->importString($string); + $this->charStream->flushContents(); + $this->charStream->importString($string); $thisLineLength = $maxLineLength - $firstLineOffset; - while (false !== $char = $this->_charStream->read(4)) { + while (false !== $char = $this->charStream->read(4)) { $encodedChar = rawurlencode($char); if (0 != strlen($currentLine) && strlen($currentLine.$encodedChar) > $thisLineLength) { @@ -79,7 +79,7 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) */ public function charsetChanged($charset) { - $this->_charStream->setCharacterSet($charset); + $this->charStream->setCharacterSet($charset); } /** @@ -87,6 +87,6 @@ public function charsetChanged($charset) */ public function __clone() { - $this->_charStream = clone $this->_charStream; + $this->charStream = clone $this->charStream; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php b/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php deleted file mode 100644 index 245878706..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php +++ /dev/null @@ -1,62 +0,0 @@ -lookup($key); - } -} diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php index 674e6b5e4..9834aa958 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php @@ -20,14 +20,14 @@ class Swift_Events_CommandEvent extends Swift_Events_EventObject * * @var string */ - private $_command; + private $command; /** * An array of codes which a successful response will contain. * * @var int[] */ - private $_successCodes = array(); + private $successCodes = array(); /** * Create a new CommandEvent for $source with $command. @@ -39,8 +39,8 @@ class Swift_Events_CommandEvent extends Swift_Events_EventObject public function __construct(Swift_Transport $source, $command, $successCodes = array()) { parent::__construct($source); - $this->_command = $command; - $this->_successCodes = $successCodes; + $this->command = $command; + $this->successCodes = $successCodes; } /** @@ -50,7 +50,7 @@ public function __construct(Swift_Transport $source, $command, $successCodes = a */ public function getCommand() { - return $this->_command; + return $this->command; } /** @@ -60,6 +60,6 @@ public function getCommand() */ public function getSuccessCodes() { - return $this->_successCodes; + return $this->successCodes; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php index aac36aaa7..f602608ee 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php @@ -19,11 +19,11 @@ interface Swift_Events_EventDispatcher * Create a new SendEvent for $source and $message. * * @param Swift_Transport $source - * @param Swift_Mime_Message + * @param Swift_Mime_SimpleMessage * * @return Swift_Events_SendEvent */ - public function createSendEvent(Swift_Transport $source, Swift_Mime_Message $message); + public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message); /** * Create a new CommandEvent for $source and $command. diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php index 90694a9a6..21e7c8127 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php @@ -16,10 +16,10 @@ class Swift_Events_EventObject implements Swift_Events_Event { /** The source of this Event */ - private $_source; + private $source; /** The state of this Event (should it bubble up the stack?) */ - private $_bubbleCancelled = false; + private $bubbleCancelled = false; /** * Create a new EventObject originating at $source. @@ -28,7 +28,7 @@ class Swift_Events_EventObject implements Swift_Events_Event */ public function __construct($source) { - $this->_source = $source; + $this->source = $source; } /** @@ -38,7 +38,7 @@ public function __construct($source) */ public function getSource() { - return $this->_source; + return $this->source; } /** @@ -48,7 +48,7 @@ public function getSource() */ public function cancelBubble($cancel = true) { - $this->_bubbleCancelled = $cancel; + $this->bubbleCancelled = $cancel; } /** @@ -58,6 +58,6 @@ public function cancelBubble($cancel = true) */ public function bubbleCancelled() { - return $this->_bubbleCancelled; + return $this->bubbleCancelled; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php index 2e92ba940..5ae6c04b6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php @@ -20,14 +20,14 @@ class Swift_Events_ResponseEvent extends Swift_Events_EventObject * * @var bool */ - private $_valid; + private $valid; /** * The response received from the server. * * @var string */ - private $_response; + private $response; /** * Create a new ResponseEvent for $source and $response. @@ -39,8 +39,8 @@ class Swift_Events_ResponseEvent extends Swift_Events_EventObject public function __construct(Swift_Transport $source, $response, $valid = false) { parent::__construct($source); - $this->_response = $response; - $this->_valid = $valid; + $this->response = $response; + $this->valid = $valid; } /** @@ -50,7 +50,7 @@ public function __construct(Swift_Transport $source, $response, $valid = false) */ public function getResponse() { - return $this->_response; + return $this->response; } /** @@ -60,6 +60,6 @@ public function getResponse() */ public function isValid() { - return $this->_valid; + return $this->valid; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php index 10da8080f..5dc8efb1f 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php @@ -33,35 +33,35 @@ class Swift_Events_SendEvent extends Swift_Events_EventObject /** * The Message being sent. * - * @var Swift_Mime_Message + * @var Swift_Mime_SimpleMessage */ - private $_message; + private $message; /** * Any recipients which failed after sending. * * @var string[] */ - private $_failedRecipients = array(); + private $failedRecipients = array(); /** * The overall result as a bitmask from the class constants. * * @var int */ - private $_result; + private $result; /** * Create a new SendEvent for $source and $message. * - * @param Swift_Transport $source - * @param Swift_Mime_Message $message + * @param Swift_Transport $source + * @param Swift_Mime_SimpleMessage $message */ - public function __construct(Swift_Transport $source, Swift_Mime_Message $message) + public function __construct(Swift_Transport $source, Swift_Mime_SimpleMessage $message) { parent::__construct($source); - $this->_message = $message; - $this->_result = self::RESULT_PENDING; + $this->message = $message; + $this->result = self::RESULT_PENDING; } /** @@ -77,11 +77,11 @@ public function getTransport() /** * Get the Message being sent. * - * @return Swift_Mime_Message + * @return Swift_Mime_SimpleMessage */ public function getMessage() { - return $this->_message; + return $this->message; } /** @@ -91,7 +91,7 @@ public function getMessage() */ public function setFailedRecipients($recipients) { - $this->_failedRecipients = $recipients; + $this->failedRecipients = $recipients; } /** @@ -101,7 +101,7 @@ public function setFailedRecipients($recipients) */ public function getFailedRecipients() { - return $this->_failedRecipients; + return $this->failedRecipients; } /** @@ -111,7 +111,7 @@ public function getFailedRecipients() */ public function setResult($result) { - $this->_result = $result; + $this->result = $result; } /** @@ -124,6 +124,6 @@ public function setResult($result) */ public function getResult() { - return $this->_result; + return $this->result; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php index e8aca752f..815fa4d92 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php @@ -16,20 +16,20 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher { /** A map of event types to their associated listener types */ - private $_eventMap = array(); + private $eventMap = array(); /** Event listeners bound to this dispatcher */ - private $_listeners = array(); + private $listeners = array(); /** Listeners queued to have an Event bubbled up the stack to them */ - private $_bubbleQueue = array(); + private $bubbleQueue = array(); /** * Create a new EventDispatcher. */ public function __construct() { - $this->_eventMap = array( + $this->eventMap = array( 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener', 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', @@ -42,11 +42,11 @@ public function __construct() * Create a new SendEvent for $source and $message. * * @param Swift_Transport $source - * @param Swift_Mime_Message + * @param Swift_Mime_SimpleMessage * * @return Swift_Events_SendEvent */ - public function createSendEvent(Swift_Transport $source, Swift_Mime_Message $message) + public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message) { return new Swift_Events_SendEvent($source, $message); } @@ -111,13 +111,13 @@ public function createTransportExceptionEvent(Swift_Transport $source, Swift_Tra */ public function bindEventListener(Swift_Events_EventListener $listener) { - foreach ($this->_listeners as $l) { + foreach ($this->listeners as $l) { // Already loaded if ($l === $listener) { return; } } - $this->_listeners[] = $listener; + $this->listeners[] = $listener; } /** @@ -128,29 +128,29 @@ public function bindEventListener(Swift_Events_EventListener $listener) */ public function dispatchEvent(Swift_Events_EventObject $evt, $target) { - $this->_prepareBubbleQueue($evt); - $this->_bubble($evt, $target); + $this->prepareBubbleQueue($evt); + $this->bubble($evt, $target); } /** Queue listeners on a stack ready for $evt to be bubbled up it */ - private function _prepareBubbleQueue(Swift_Events_EventObject $evt) + private function prepareBubbleQueue(Swift_Events_EventObject $evt) { - $this->_bubbleQueue = array(); + $this->bubbleQueue = array(); $evtClass = get_class($evt); - foreach ($this->_listeners as $listener) { - if (array_key_exists($evtClass, $this->_eventMap) - && ($listener instanceof $this->_eventMap[$evtClass])) { - $this->_bubbleQueue[] = $listener; + foreach ($this->listeners as $listener) { + if (array_key_exists($evtClass, $this->eventMap) + && ($listener instanceof $this->eventMap[$evtClass])) { + $this->bubbleQueue[] = $listener; } } } /** Bubble $evt up the stack calling $target() on each listener */ - private function _bubble(Swift_Events_EventObject $evt, $target) + private function bubble(Swift_Events_EventObject $evt, $target) { - if (!$evt->bubbleCancelled() && $listener = array_shift($this->_bubbleQueue)) { + if (!$evt->bubbleCancelled() && $listener = array_shift($this->bubbleQueue)) { $listener->$target($evt); - $this->_bubble($evt, $target); + $this->bubble($evt, $target); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php index f87154fb9..77534e3e0 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php @@ -20,7 +20,7 @@ class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject * * @var Swift_TransportException */ - private $_exception; + private $exception; /** * Create a new TransportExceptionEvent for $transport. @@ -31,7 +31,7 @@ class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject public function __construct(Swift_Transport $transport, Swift_TransportException $ex) { parent::__construct($transport); - $this->_exception = $ex; + $this->exception = $ex; } /** @@ -41,6 +41,6 @@ public function __construct(Swift_Transport $transport, Swift_TransportException */ public function getException() { - return $this->_exception; + return $this->exception; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php index 9951c5977..dc2859f74 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php @@ -30,16 +30,4 @@ public function __construct($transports = array()) $this->setTransports($transports); } - - /** - * Create a new FailoverTransport instance. - * - * @param Swift_Transport[] $transports - * - * @return self - */ - public static function newInstance($transports = array()) - { - return new self($transports); - } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php b/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php index c82c5dbf1..b0b9eb064 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php @@ -17,14 +17,14 @@ class Swift_FileSpool extends Swift_ConfigurableSpool { /** The spool directory */ - private $_path; + private $path; /** * File WriteRetry Limit. * * @var int */ - private $_retryLimit = 10; + private $retryLimit = 10; /** * Create a new FileSpool. @@ -35,11 +35,11 @@ class Swift_FileSpool extends Swift_ConfigurableSpool */ public function __construct($path) { - $this->_path = $path; + $this->path = $path; - if (!file_exists($this->_path)) { - if (!mkdir($this->_path, 0777, true)) { - throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->_path)); + if (!file_exists($this->path)) { + if (!mkdir($this->path, 0777, true)) { + throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->path)); } } } @@ -77,25 +77,25 @@ public function stop() */ public function setRetryLimit($limit) { - $this->_retryLimit = $limit; + $this->retryLimit = $limit; } /** * Queues a message. * - * @param Swift_Mime_Message $message The message to store + * @param Swift_Mime_SimpleMessage $message The message to store * * @throws Swift_IoException * * @return bool */ - public function queueMessage(Swift_Mime_Message $message) + public function queueMessage(Swift_Mime_SimpleMessage $message) { $ser = serialize($message); - $fileName = $this->_path.'/'.$this->getRandomString(10); - for ($i = 0; $i < $this->_retryLimit; ++$i) { + $fileName = $this->path.'/'.$this->getRandomString(10); + for ($i = 0; $i < $this->retryLimit; ++$i) { /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */ - $fp = @fopen($fileName.'.message', 'x'); + $fp = @fopen($fileName.'.message', 'xb'); if (false !== $fp) { if (false === fwrite($fp, $ser)) { return false; @@ -108,7 +108,7 @@ public function queueMessage(Swift_Mime_Message $message) } } - throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->_path)); + throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->path)); } /** @@ -118,7 +118,7 @@ public function queueMessage(Swift_Mime_Message $message) */ public function recover($timeout = 900) { - foreach (new DirectoryIterator($this->_path) as $file) { + foreach (new DirectoryIterator($this->path) as $file) { $file = $file->getRealPath(); if (substr($file, -16) == '.message.sending') { @@ -140,7 +140,7 @@ public function recover($timeout = 900) */ public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) { - $directoryIterator = new DirectoryIterator($this->_path); + $directoryIterator = new DirectoryIterator($this->path); /* Start the transport only if there are queued files to send */ if (!$transport->isStarted()) { @@ -200,7 +200,7 @@ protected function getRandomString($count) $ret = ''; $strlen = strlen($base); for ($i = 0; $i < $count; ++$i) { - $ret .= $base[((int) rand(0, $strlen - 1))]; + $ret .= $base[random_int(0, $strlen - 1)]; } return $ret; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/IdGenerator.php b/swiftmailer/swiftmailer/lib/classes/Swift/IdGenerator.php new file mode 100644 index 000000000..c845d85e3 --- /dev/null +++ b/swiftmailer/swiftmailer/lib/classes/Swift/IdGenerator.php @@ -0,0 +1,22 @@ +setFile(new Swift_ByteStream_FileByteStream($path)); + return (new self())->setFile(new Swift_ByteStream_FileByteStream($path)); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php index b37f07f74..cdd085030 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php @@ -20,14 +20,14 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache * * @var array */ - private $_contents = array(); + private $contents = array(); /** * An InputStream for cloning. * * @var Swift_KeyCache_KeyCacheInputStream */ - private $_stream; + private $stream; /** * Create a new ArrayKeyCache with the given $stream for cloning to make @@ -37,7 +37,7 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache */ public function __construct(Swift_KeyCache_KeyCacheInputStream $stream) { - $this->_stream = $stream; + $this->stream = $stream; } /** @@ -52,16 +52,16 @@ public function __construct(Swift_KeyCache_KeyCacheInputStream $stream) */ public function setString($nsKey, $itemKey, $string, $mode) { - $this->_prepareCache($nsKey); + $this->prepareCache($nsKey); switch ($mode) { case self::MODE_WRITE: - $this->_contents[$nsKey][$itemKey] = $string; + $this->contents[$nsKey][$itemKey] = $string; break; case self::MODE_APPEND: if (!$this->hasKey($nsKey, $itemKey)) { - $this->_contents[$nsKey][$itemKey] = ''; + $this->contents[$nsKey][$itemKey] = ''; } - $this->_contents[$nsKey][$itemKey] .= $string; + $this->contents[$nsKey][$itemKey] .= $string; break; default: throw new Swift_SwiftException( @@ -83,16 +83,16 @@ public function setString($nsKey, $itemKey, $string, $mode) */ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) { - $this->_prepareCache($nsKey); + $this->prepareCache($nsKey); switch ($mode) { case self::MODE_WRITE: $this->clearKey($nsKey, $itemKey); case self::MODE_APPEND: if (!$this->hasKey($nsKey, $itemKey)) { - $this->_contents[$nsKey][$itemKey] = ''; + $this->contents[$nsKey][$itemKey] = ''; } while (false !== $bytes = $os->read(8192)) { - $this->_contents[$nsKey][$itemKey] .= $bytes; + $this->contents[$nsKey][$itemKey] .= $bytes; } break; default: @@ -116,7 +116,7 @@ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $o */ public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) { - $is = clone $this->_stream; + $is = clone $this->stream; $is->setKeyCache($this); $is->setNsKey($nsKey); $is->setItemKey($itemKey); @@ -137,9 +137,9 @@ public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writ */ public function getString($nsKey, $itemKey) { - $this->_prepareCache($nsKey); + $this->prepareCache($nsKey); if ($this->hasKey($nsKey, $itemKey)) { - return $this->_contents[$nsKey][$itemKey]; + return $this->contents[$nsKey][$itemKey]; } } @@ -152,7 +152,7 @@ public function getString($nsKey, $itemKey) */ public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) { - $this->_prepareCache($nsKey); + $this->prepareCache($nsKey); $is->write($this->getString($nsKey, $itemKey)); } @@ -166,9 +166,9 @@ public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) */ public function hasKey($nsKey, $itemKey) { - $this->_prepareCache($nsKey); + $this->prepareCache($nsKey); - return array_key_exists($itemKey, $this->_contents[$nsKey]); + return array_key_exists($itemKey, $this->contents[$nsKey]); } /** @@ -179,7 +179,7 @@ public function hasKey($nsKey, $itemKey) */ public function clearKey($nsKey, $itemKey) { - unset($this->_contents[$nsKey][$itemKey]); + unset($this->contents[$nsKey][$itemKey]); } /** @@ -189,7 +189,7 @@ public function clearKey($nsKey, $itemKey) */ public function clearAll($nsKey) { - unset($this->_contents[$nsKey]); + unset($this->contents[$nsKey]); } /** @@ -197,10 +197,10 @@ public function clearAll($nsKey) * * @param string $nsKey */ - private function _prepareCache($nsKey) + private function prepareCache($nsKey) { - if (!array_key_exists($nsKey, $this->_contents)) { - $this->_contents[$nsKey] = array(); + if (!array_key_exists($nsKey, $this->contents)) { + $this->contents[$nsKey] = array(); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php index 453f50a15..d6a633a15 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php @@ -29,28 +29,21 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache * * @var Swift_KeyCache_KeyCacheInputStream */ - private $_stream; + private $stream; /** * A path to write to. * * @var string */ - private $_path; + private $path; /** * Stored keys. * * @var array */ - private $_keys = array(); - - /** - * Will be true if magic_quotes_runtime is turned on. - * - * @var bool - */ - private $_quotes = false; + private $keys = array(); /** * Create a new DiskKeyCache with the given $stream for cloning to make @@ -61,12 +54,8 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache */ public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path) { - $this->_stream = $stream; - $this->_path = $path; - - if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) { - $this->_quotes = true; - } + $this->stream = $stream; + $this->path = $path; } /** @@ -83,13 +72,13 @@ public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path) */ public function setString($nsKey, $itemKey, $string, $mode) { - $this->_prepareCache($nsKey); + $this->prepareCache($nsKey); switch ($mode) { case self::MODE_WRITE: - $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); break; case self::MODE_APPEND: - $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END); + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); break; default: throw new Swift_SwiftException( @@ -99,7 +88,7 @@ public function setString($nsKey, $itemKey, $string, $mode) break; } fwrite($fp, $string); - $this->_freeHandle($nsKey, $itemKey); + $this->freeHandle($nsKey, $itemKey); } /** @@ -116,13 +105,13 @@ public function setString($nsKey, $itemKey, $string, $mode) */ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) { - $this->_prepareCache($nsKey); + $this->prepareCache($nsKey); switch ($mode) { case self::MODE_WRITE: - $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); break; case self::MODE_APPEND: - $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END); + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); break; default: throw new Swift_SwiftException( @@ -134,7 +123,7 @@ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $o while (false !== $bytes = $os->read(8192)) { fwrite($fp, $bytes); } - $this->_freeHandle($nsKey, $itemKey); + $this->freeHandle($nsKey, $itemKey); } /** @@ -150,7 +139,7 @@ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $o */ public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) { - $is = clone $this->_stream; + $is = clone $this->stream; $is->setKeyCache($this); $is->setNsKey($nsKey); $is->setItemKey($itemKey); @@ -173,20 +162,14 @@ public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writ */ public function getString($nsKey, $itemKey) { - $this->_prepareCache($nsKey); + $this->prepareCache($nsKey); if ($this->hasKey($nsKey, $itemKey)) { - $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); - if ($this->_quotes) { - ini_set('magic_quotes_runtime', 0); - } + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); $str = ''; while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { $str .= $bytes; } - if ($this->_quotes) { - ini_set('magic_quotes_runtime', 1); - } - $this->_freeHandle($nsKey, $itemKey); + $this->freeHandle($nsKey, $itemKey); return $str; } @@ -202,17 +185,11 @@ public function getString($nsKey, $itemKey) public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) { if ($this->hasKey($nsKey, $itemKey)) { - $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); - if ($this->_quotes) { - ini_set('magic_quotes_runtime', 0); - } + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { $is->write($bytes); } - if ($this->_quotes) { - ini_set('magic_quotes_runtime', 1); - } - $this->_freeHandle($nsKey, $itemKey); + $this->freeHandle($nsKey, $itemKey); } } @@ -226,7 +203,7 @@ public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) */ public function hasKey($nsKey, $itemKey) { - return is_file($this->_path.'/'.$nsKey.'/'.$itemKey); + return is_file($this->path.'/'.$nsKey.'/'.$itemKey); } /** @@ -238,8 +215,8 @@ public function hasKey($nsKey, $itemKey) public function clearKey($nsKey, $itemKey) { if ($this->hasKey($nsKey, $itemKey)) { - $this->_freeHandle($nsKey, $itemKey); - unlink($this->_path.'/'.$nsKey.'/'.$itemKey); + $this->freeHandle($nsKey, $itemKey); + unlink($this->path.'/'.$nsKey.'/'.$itemKey); } } @@ -250,14 +227,14 @@ public function clearKey($nsKey, $itemKey) */ public function clearAll($nsKey) { - if (array_key_exists($nsKey, $this->_keys)) { - foreach ($this->_keys[$nsKey] as $itemKey => $null) { + if (array_key_exists($nsKey, $this->keys)) { + foreach ($this->keys[$nsKey] as $itemKey => $null) { $this->clearKey($nsKey, $itemKey); } - if (is_dir($this->_path.'/'.$nsKey)) { - rmdir($this->_path.'/'.$nsKey); + if (is_dir($this->path.'/'.$nsKey)) { + rmdir($this->path.'/'.$nsKey); } - unset($this->_keys[$nsKey]); + unset($this->keys[$nsKey]); } } @@ -266,14 +243,14 @@ public function clearAll($nsKey) * * @param string $nsKey */ - private function _prepareCache($nsKey) + private function prepareCache($nsKey) { - $cacheDir = $this->_path.'/'.$nsKey; + $cacheDir = $this->path.'/'.$nsKey; if (!is_dir($cacheDir)) { if (!mkdir($cacheDir)) { throw new Swift_IoException('Failed to create cache directory '.$cacheDir); } - $this->_keys[$nsKey] = array(); + $this->keys[$nsKey] = array(); } } @@ -286,27 +263,27 @@ private function _prepareCache($nsKey) * * @return resource */ - private function _getHandle($nsKey, $itemKey, $position) + private function getHandle($nsKey, $itemKey, $position) { - if (!isset($this->_keys[$nsKey][$itemKey])) { + if (!isset($this->keys[$nsKey][$itemKey])) { $openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b'; - $fp = fopen($this->_path.'/'.$nsKey.'/'.$itemKey, $openMode); - $this->_keys[$nsKey][$itemKey] = $fp; + $fp = fopen($this->path.'/'.$nsKey.'/'.$itemKey, $openMode); + $this->keys[$nsKey][$itemKey] = $fp; } if (self::POSITION_START == $position) { - fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_SET); + fseek($this->keys[$nsKey][$itemKey], 0, SEEK_SET); } elseif (self::POSITION_END == $position) { - fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_END); + fseek($this->keys[$nsKey][$itemKey], 0, SEEK_END); } - return $this->_keys[$nsKey][$itemKey]; + return $this->keys[$nsKey][$itemKey]; } - private function _freeHandle($nsKey, $itemKey) + private function freeHandle($nsKey, $itemKey) { - $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_CURRENT); + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_CURRENT); fclose($fp); - $this->_keys[$nsKey][$itemKey] = null; + $this->keys[$nsKey][$itemKey] = null; } /** @@ -314,7 +291,7 @@ private function _freeHandle($nsKey, $itemKey) */ public function __destruct() { - foreach ($this->_keys as $nsKey => $null) { + foreach ($this->keys as $nsKey => $null) { $this->clearAll($nsKey); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php index b00d458a6..a74df434c 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php @@ -16,16 +16,16 @@ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCacheInputStream { /** The KeyCache being written to */ - private $_keyCache; + private $keyCache; /** The nsKey of the KeyCache being written to */ - private $_nsKey; + private $nsKey; /** The itemKey of the KeyCache being written to */ - private $_itemKey; + private $itemKey; /** A stream to write through on each write() */ - private $_writeThrough = null; + private $writeThrough = null; /** * Set the KeyCache to wrap. @@ -34,7 +34,7 @@ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCach */ public function setKeyCache(Swift_KeyCache $keyCache) { - $this->_keyCache = $keyCache; + $this->keyCache = $keyCache; } /** @@ -44,7 +44,7 @@ public function setKeyCache(Swift_KeyCache $keyCache) */ public function setWriteThroughStream(Swift_InputByteStream $is) { - $this->_writeThrough = $is; + $this->writeThrough = $is; } /** @@ -55,14 +55,14 @@ public function setWriteThroughStream(Swift_InputByteStream $is) */ public function write($bytes, Swift_InputByteStream $is = null) { - $this->_keyCache->setString( - $this->_nsKey, $this->_itemKey, $bytes, Swift_KeyCache::MODE_APPEND + $this->keyCache->setString( + $this->nsKey, $this->itemKey, $bytes, Swift_KeyCache::MODE_APPEND ); if (isset($is)) { $is->write($bytes); } - if (isset($this->_writeThrough)) { - $this->_writeThrough->write($bytes); + if (isset($this->writeThrough)) { + $this->writeThrough->write($bytes); } } @@ -93,7 +93,7 @@ public function unbind(Swift_InputByteStream $is) */ public function flushBuffers() { - $this->_keyCache->clearKey($this->_nsKey, $this->_itemKey); + $this->keyCache->clearKey($this->nsKey, $this->itemKey); } /** @@ -103,7 +103,7 @@ public function flushBuffers() */ public function setNsKey($nsKey) { - $this->_nsKey = $nsKey; + $this->nsKey = $nsKey; } /** @@ -113,7 +113,7 @@ public function setNsKey($nsKey) */ public function setItemKey($itemKey) { - $this->_itemKey = $itemKey; + $this->itemKey = $itemKey; } /** @@ -122,6 +122,6 @@ public function setItemKey($itemKey) */ public function __clone() { - $this->_writeThrough = null; + $this->writeThrough = null; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php index e151b8a9c..03106e55d 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php @@ -30,16 +30,4 @@ public function __construct($transports = array()) $this->setTransports($transports); } - - /** - * Create a new LoadBalancedTransport instance. - * - * @param array $transports - * - * @return self - */ - public static function newInstance($transports = array()) - { - return new self($transports); - } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php deleted file mode 100644 index 18556989a..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php +++ /dev/null @@ -1,47 +0,0 @@ -createDependenciesFor('transport.mail') - ); - - $this->setExtraParams($extraParams); - } - - /** - * Create a new MailTransport instance. - * - * @param string $extraParams To be passed to mail() - * - * @return self - */ - public static function newInstance($extraParams = '-f%s') - { - return new self($extraParams); - } -} diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php index 8314fe8fc..3561ec6e6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php @@ -16,7 +16,7 @@ class Swift_Mailer { /** The Transport used to send messages */ - private $_transport; + private $transport; /** * Create a new Mailer using $transport for delivery. @@ -25,19 +25,7 @@ class Swift_Mailer */ public function __construct(Swift_Transport $transport) { - $this->_transport = $transport; - } - - /** - * Create a new Mailer instance. - * - * @param Swift_Transport $transport - * - * @return self - */ - public static function newInstance(Swift_Transport $transport) - { - return new self($transport); + $this->transport = $transport; } /** @@ -66,23 +54,23 @@ public function createMessage($service = 'message') * The return value is the number of recipients who were accepted for * delivery. * - * @param Swift_Mime_Message $message - * @param array $failedRecipients An array of failures by-reference + * @param Swift_Mime_SimpleMessage $message + * @param array $failedRecipients An array of failures by-reference * * @return int The number of successful recipients. Can be 0 which indicates failure */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { $failedRecipients = (array) $failedRecipients; - if (!$this->_transport->isStarted()) { - $this->_transport->start(); + if (!$this->transport->isStarted()) { + $this->transport->start(); } $sent = 0; try { - $sent = $this->_transport->send($message, $failedRecipients); + $sent = $this->transport->send($message, $failedRecipients); } catch (Swift_RfcComplianceException $e) { foreach ($message->getTo() as $address => $name) { $failedRecipients[] = $address; @@ -99,7 +87,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) */ public function registerPlugin(Swift_Events_EventListener $plugin) { - $this->_transport->registerPlugin($plugin); + $this->transport->registerPlugin($plugin); } /** @@ -109,6 +97,6 @@ public function registerPlugin(Swift_Events_EventListener $plugin) */ public function getTransport() { - return $this->_transport; + return $this->transport; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php index e3e6cad05..84dacb5f1 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php @@ -20,7 +20,7 @@ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientItera * * @var array */ - private $_recipients = array(); + private $recipients = array(); /** * Create a new ArrayRecipientIterator from $recipients. @@ -29,7 +29,7 @@ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientItera */ public function __construct(array $recipients) { - $this->_recipients = $recipients; + $this->recipients = $recipients; } /** @@ -39,7 +39,7 @@ public function __construct(array $recipients) */ public function hasNext() { - return !empty($this->_recipients); + return !empty($this->recipients); } /** @@ -50,6 +50,6 @@ public function hasNext() */ public function nextRecipient() { - return array_splice($this->_recipients, 0, 1); + return array_splice($this->recipients, 0, 1); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php b/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php index 2cafb6751..9aa62835b 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php @@ -53,11 +53,11 @@ public function setFlushRetries($retries) /** * Stores a message in the queue. * - * @param Swift_Mime_Message $message The message to store + * @param Swift_Mime_SimpleMessage $message The message to store * * @return bool Whether the operation has succeeded */ - public function queueMessage(Swift_Mime_Message $message) + public function queueMessage(Swift_Mime_SimpleMessage $message) { //clone the message to make sure it is not changed while in the queue $this->messages[] = clone $message; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Message.php b/swiftmailer/swiftmailer/lib/classes/Swift/Message.php index 242cbf314..00f6e1600 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Message.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Message.php @@ -60,21 +60,6 @@ public function __construct($subject = null, $body = null, $contentType = null, } } - /** - * Create a new Message. - * - * @param string $subject - * @param string $body - * @param string $contentType - * @param string $charset - * - * @return $this - */ - public static function newInstance($subject = null, $body = null, $contentType = null, $charset = null) - { - return new self($subject, $body, $contentType, $charset); - } - /** * Add a MimePart to this Message. * @@ -86,7 +71,7 @@ public static function newInstance($subject = null, $body = null, $contentType = */ public function addPart($body, $contentType = null, $charset = null) { - return $this->attach(Swift_MimePart::newInstance($body, $contentType, $charset)->setEncoder($this->getEncoder())); + return $this->attach((new Swift_MimePart($body, $contentType, $charset))->setEncoder($this->getEncoder())); } /** @@ -205,7 +190,7 @@ protected function doSign() $signer->setHeaders($this->getHeaders()); $signer->startBody(); - $this->_bodyToByteStream($signer); + $this->bodyToByteStream($signer); $signer->endBody(); $signer->addSignature($this->getHeaders()); @@ -221,7 +206,7 @@ protected function saveMessage() $this->savedMessage['body'] = $this->getBody(); $this->savedMessage['children'] = $this->getChildren(); if (count($this->savedMessage['children']) > 0 && $this->getBody() != '') { - $this->setChildren(array_merge(array($this->_becomeMimePart()), $this->savedMessage['children'])); + $this->setChildren(array_merge(array($this->becomeMimePart()), $this->savedMessage['children'])); $this->setBody(''); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php index d5ba14b91..a36ce7237 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php @@ -16,23 +16,23 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity { /** Recognized MIME types */ - private $_mimeTypes = array(); + private $mimeTypes = array(); /** * Create a new Attachment with $headers, $encoder and $cache. * - * @param Swift_Mime_HeaderSet $headers - * @param Swift_Mime_ContentEncoder $encoder - * @param Swift_KeyCache $cache - * @param Swift_Mime_Grammar $grammar - * @param array $mimeTypes optional + * @param Swift_Mime_SimpleHeaderSet $headers + * @param Swift_Mime_ContentEncoder $encoder + * @param Swift_KeyCache $cache + * @param Swift_IdGenerator $idGenerator + * @param array $mimeTypes */ - public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar, $mimeTypes = array()) + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = array()) { - parent::__construct($headers, $encoder, $cache, $grammar); + parent::__construct($headers, $encoder, $cache, $idGenerator); $this->setDisposition('attachment'); $this->setContentType('application/octet-stream'); - $this->_mimeTypes = $mimeTypes; + $this->mimeTypes = $mimeTypes; } /** @@ -56,7 +56,7 @@ public function getNestingLevel() */ public function getDisposition() { - return $this->_getHeaderFieldModel('Content-Disposition'); + return $this->getHeaderFieldModel('Content-Disposition'); } /** @@ -68,7 +68,7 @@ public function getDisposition() */ public function setDisposition($disposition) { - if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) { + if (!$this->setHeaderFieldModel('Content-Disposition', $disposition)) { $this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition); } @@ -82,7 +82,7 @@ public function setDisposition($disposition) */ public function getFilename() { - return $this->_getHeaderParameter('Content-Disposition', 'filename'); + return $this->getHeaderParameter('Content-Disposition', 'filename'); } /** @@ -94,8 +94,8 @@ public function getFilename() */ public function setFilename($filename) { - $this->_setHeaderParameter('Content-Disposition', 'filename', $filename); - $this->_setHeaderParameter('Content-Type', 'name', $filename); + $this->setHeaderParameter('Content-Disposition', 'filename', $filename); + $this->setHeaderParameter('Content-Type', 'name', $filename); return $this; } @@ -107,7 +107,7 @@ public function setFilename($filename) */ public function getSize() { - return $this->_getHeaderParameter('Content-Disposition', 'size'); + return $this->getHeaderParameter('Content-Disposition', 'size'); } /** @@ -119,7 +119,7 @@ public function getSize() */ public function setSize($size) { - $this->_setHeaderParameter('Content-Disposition', 'size', $size); + $this->setHeaderParameter('Content-Disposition', 'size', $size); return $this; } @@ -139,8 +139,8 @@ public function setFile(Swift_FileStream $file, $contentType = null) if (!isset($contentType)) { $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1)); - if (array_key_exists($extension, $this->_mimeTypes)) { - $this->setContentType($this->_mimeTypes[$extension]); + if (array_key_exists($extension, $this->mimeTypes)) { + $this->setContentType($this->mimeTypes[$extension]); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php index 710b5ac9e..34de4ef39 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php @@ -92,7 +92,7 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); } - return $this->_standardize(quoted_printable_encode($string)); + return $this->standardize(quoted_printable_encode($string)); } /** @@ -102,7 +102,7 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) * * @return string */ - protected function _standardize($string) + protected function standardize($string) { // transform CR or LF to CRLF $string = preg_replace('~=0D(?!=0A)|(?_name = $name; - $this->_canonical = $canonical; + $this->name = $name; + $this->canonical = $canonical; } /** @@ -52,11 +52,11 @@ public function __construct($name, $canonical = false) */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) { - if ($this->_canonical) { - $string = $this->_canonicalize($string); + if ($this->canonical) { + $string = $this->canonicalize($string); } - return $this->_safeWordWrap($string, $maxLineLength, "\r\n"); + return $this->safeWordwrap($string, $maxLineLength, "\r\n"); } /** @@ -72,10 +72,10 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre $leftOver = ''; while (false !== $bytes = $os->read(8192)) { $toencode = $leftOver.$bytes; - if ($this->_canonical) { - $toencode = $this->_canonicalize($toencode); + if ($this->canonical) { + $toencode = $this->canonicalize($toencode); } - $wrapped = $this->_safeWordWrap($toencode, $maxLineLength, "\r\n"); + $wrapped = $this->safeWordwrap($toencode, $maxLineLength, "\r\n"); $lastLinePos = strrpos($wrapped, "\r\n"); $leftOver = substr($wrapped, $lastLinePos); $wrapped = substr($wrapped, 0, $lastLinePos); @@ -94,7 +94,7 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre */ public function getName() { - return $this->_name; + return $this->name; } /** @@ -113,7 +113,7 @@ public function charsetChanged($charset) * * @return string */ - private function _safeWordwrap($string, $length = 75, $le = "\r\n") + private function safeWordwrap($string, $length = 75, $le = "\r\n") { if (0 >= $length) { return $string; @@ -151,7 +151,7 @@ private function _safeWordwrap($string, $length = 75, $le = "\r\n") * * @return string */ - private function _canonicalize($string) + private function canonicalize($string) { return str_replace( array("\r\n", "\r", "\n"), diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php index 5cc907b8e..b3577dbe6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php @@ -11,11 +11,11 @@ /** * Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_ContentEncoder { - protected $_dotEscape; + protected $dotEscape; /** * Creates a new QpContentEncoder for the given CharacterStream. @@ -26,26 +26,26 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder */ public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null, $dotEscape = false) { - $this->_dotEscape = $dotEscape; + $this->dotEscape = $dotEscape; parent::__construct($charStream, $filter); } public function __sleep() { - return array('_charStream', '_filter', '_dotEscape'); + return array('charStream', 'filter', 'dotEscape'); } protected function getSafeMapShareId() { - return get_class($this).($this->_dotEscape ? '.dotEscape' : ''); + return get_class($this).($this->dotEscape ? '.dotEscape' : ''); } protected function initSafeMap() { parent::initSafeMap(); - if ($this->_dotEscape) { + if ($this->dotEscape) { /* Encode . as =2e for buggy remote servers */ - unset($this->_safeMap[0x2e]); + unset($this->safeMap[0x2e]); } } @@ -69,20 +69,20 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre $thisLineLength = $maxLineLength - $firstLineOffset; - $this->_charStream->flushContents(); - $this->_charStream->importByteStream($os); + $this->charStream->flushContents(); + $this->charStream->importByteStream($os); $currentLine = ''; $prepend = ''; $size = $lineLen = 0; - while (false !== $bytes = $this->_nextSequence()) { + while (false !== $bytes = $this->nextSequence()) { // If we're filtering the input - if (isset($this->_filter)) { + if (isset($this->filter)) { // If we can't filter because we need more bytes - while ($this->_filter->shouldBuffer($bytes)) { + while ($this->filter->shouldBuffer($bytes)) { // Then collect bytes into the buffer - if (false === $moreBytes = $this->_nextSequence(1)) { + if (false === $moreBytes = $this->nextSequence(1)) { break; } @@ -91,16 +91,16 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre } } // And filter them - $bytes = $this->_filter->filter($bytes); + $bytes = $this->filter->filter($bytes); } - $enc = $this->_encodeByteSequence($bytes, $size); + $enc = $this->encodeByteSequence($bytes, $size); $i = strpos($enc, '=0D=0A'); $newLineLength = $lineLen + ($i === false ? $size : $i); if ($currentLine && $newLineLength >= $thisLineLength) { - $is->write($prepend.$this->_standardize($currentLine)); + $is->write($prepend.$this->standardize($currentLine)); $currentLine = ''; $prepend = "=\r\n"; $thisLineLength = $maxLineLength; @@ -117,7 +117,7 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre } } if (strlen($currentLine)) { - $is->write($prepend.$this->_standardize($currentLine)); + $is->write($prepend.$this->standardize($currentLine)); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php index 6af757124..7835a4928 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php @@ -18,15 +18,15 @@ class Swift_Mime_EmbeddedFile extends Swift_Mime_Attachment /** * Creates a new Attachment with $headers and $encoder. * - * @param Swift_Mime_HeaderSet $headers - * @param Swift_Mime_ContentEncoder $encoder - * @param Swift_KeyCache $cache - * @param Swift_Mime_Grammar $grammar - * @param array $mimeTypes optional + * @param Swift_Mime_SimpleHeaderSet $headers + * @param Swift_Mime_ContentEncoder $encoder + * @param Swift_KeyCache $cache + * @param Swift_IdGenerator $idGenerator + * @param array $mimeTypes optional */ - public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar, $mimeTypes = array()) + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = array()) { - parent::__construct($headers, $encoder, $cache, $grammar, $mimeTypes); + parent::__construct($headers, $encoder, $cache, $idGenerator, $mimeTypes); $this->setDisposition('inline'); $this->setId($this->getId()); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Grammar.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Grammar.php deleted file mode 100644 index a09f33831..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Grammar.php +++ /dev/null @@ -1,176 +0,0 @@ -init(); - } - - public function __wakeup() - { - $this->init(); - } - - protected function init() - { - if (count(self::$_specials) > 0) { - return; - } - - self::$_specials = array( - '(', ')', '<', '>', '[', ']', - ':', ';', '@', ',', '.', '"', - ); - - /*** Refer to RFC 2822 for ABNF grammar ***/ - - // All basic building blocks - self::$_grammar['NO-WS-CTL'] = '[\x01-\x08\x0B\x0C\x0E-\x19\x7F]'; - self::$_grammar['WSP'] = '[ \t]'; - self::$_grammar['CRLF'] = '(?:\r\n)'; - self::$_grammar['FWS'] = '(?:(?:'.self::$_grammar['WSP'].'*'. - self::$_grammar['CRLF'].')?'.self::$_grammar['WSP'].')'; - self::$_grammar['text'] = '[\x00-\x08\x0B\x0C\x0E-\x7F]'; - self::$_grammar['quoted-pair'] = '(?:\\\\'.self::$_grammar['text'].')'; - self::$_grammar['ctext'] = '(?:'.self::$_grammar['NO-WS-CTL']. - '|[\x21-\x27\x2A-\x5B\x5D-\x7E])'; - // Uses recursive PCRE (?1) -- could be a weak point?? - self::$_grammar['ccontent'] = '(?:'.self::$_grammar['ctext'].'|'. - self::$_grammar['quoted-pair'].'|(?1))'; - self::$_grammar['comment'] = '(\((?:'.self::$_grammar['FWS'].'|'. - self::$_grammar['ccontent'].')*'.self::$_grammar['FWS'].'?\))'; - self::$_grammar['CFWS'] = '(?:(?:'.self::$_grammar['FWS'].'?'. - self::$_grammar['comment'].')*(?:(?:'.self::$_grammar['FWS'].'?'. - self::$_grammar['comment'].')|'.self::$_grammar['FWS'].'))'; - self::$_grammar['qtext'] = '(?:'.self::$_grammar['NO-WS-CTL']. - '|[\x21\x23-\x5B\x5D-\x7E])'; - self::$_grammar['qcontent'] = '(?:'.self::$_grammar['qtext'].'|'. - self::$_grammar['quoted-pair'].')'; - self::$_grammar['quoted-string'] = '(?:'.self::$_grammar['CFWS'].'?"'. - '('.self::$_grammar['FWS'].'?'.self::$_grammar['qcontent'].')*'. - self::$_grammar['FWS'].'?"'.self::$_grammar['CFWS'].'?)'; - self::$_grammar['atext'] = '[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]'; - self::$_grammar['atom'] = '(?:'.self::$_grammar['CFWS'].'?'. - self::$_grammar['atext'].'+'.self::$_grammar['CFWS'].'?)'; - self::$_grammar['dot-atom-text'] = '(?:'.self::$_grammar['atext'].'+'. - '(\.'.self::$_grammar['atext'].'+)*)'; - self::$_grammar['dot-atom'] = '(?:'.self::$_grammar['CFWS'].'?'. - self::$_grammar['dot-atom-text'].'+'.self::$_grammar['CFWS'].'?)'; - self::$_grammar['word'] = '(?:'.self::$_grammar['atom'].'|'. - self::$_grammar['quoted-string'].')'; - self::$_grammar['phrase'] = '(?:'.self::$_grammar['word'].'+?)'; - self::$_grammar['no-fold-quote'] = '(?:"(?:'.self::$_grammar['qtext']. - '|'.self::$_grammar['quoted-pair'].')*")'; - self::$_grammar['dtext'] = '(?:'.self::$_grammar['NO-WS-CTL']. - '|[\x21-\x5A\x5E-\x7E])'; - self::$_grammar['no-fold-literal'] = '(?:\[(?:'.self::$_grammar['dtext']. - '|'.self::$_grammar['quoted-pair'].')*\])'; - - // Message IDs - self::$_grammar['id-left'] = '(?:'.self::$_grammar['dot-atom-text'].'|'. - self::$_grammar['no-fold-quote'].')'; - self::$_grammar['id-right'] = '(?:'.self::$_grammar['dot-atom-text'].'|'. - self::$_grammar['no-fold-literal'].')'; - - // Addresses, mailboxes and paths - self::$_grammar['local-part'] = '(?:'.self::$_grammar['dot-atom'].'|'. - self::$_grammar['quoted-string'].')'; - self::$_grammar['dcontent'] = '(?:'.self::$_grammar['dtext'].'|'. - self::$_grammar['quoted-pair'].')'; - self::$_grammar['domain-literal'] = '(?:'.self::$_grammar['CFWS'].'?\[('. - self::$_grammar['FWS'].'?'.self::$_grammar['dcontent'].')*?'. - self::$_grammar['FWS'].'?\]'.self::$_grammar['CFWS'].'?)'; - self::$_grammar['domain'] = '(?:'.self::$_grammar['dot-atom'].'|'. - self::$_grammar['domain-literal'].')'; - self::$_grammar['addr-spec'] = '(?:'.self::$_grammar['local-part'].'@'. - self::$_grammar['domain'].')'; - } - - /** - * Get the grammar defined for $name token. - * - * @param string $name exactly as written in the RFC - * - * @return string - */ - public function getDefinition($name) - { - if (array_key_exists($name, self::$_grammar)) { - return self::$_grammar[$name]; - } - - throw new Swift_RfcComplianceException( - "No such grammar '".$name."' defined." - ); - } - - /** - * Returns the tokens defined in RFC 2822 (and some related RFCs). - * - * @return array - */ - public function getGrammarDefinitions() - { - return self::$_grammar; - } - - /** - * Returns the current special characters used in the syntax which need to be escaped. - * - * @return array - */ - public function getSpecials() - { - return self::$_specials; - } - - /** - * Escape special characters in a string (convert to quoted-pairs). - * - * @param string $token - * @param string[] $include additional chars to escape - * @param string[] $exclude chars from escaping - * - * @return string - */ - public function escapeSpecials($token, $include = array(), $exclude = array()) - { - foreach (array_merge(array('\\'), array_diff(self::$_specials, $exclude), $include) as $char) { - $token = str_replace($char, '\\'.$char, $token); - } - - return $token; - } -} diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php index 510dd6637..062be7d79 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php @@ -31,7 +31,7 @@ protected function initSafeMap() range(0x61, 0x7A), range(0x41, 0x5A), range(0x30, 0x39), array(0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F) ) as $byte) { - $this->_safeMap[$byte] = chr($byte); + $this->safeMap[$byte] = chr($byte); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php deleted file mode 100644 index c65f26d72..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php +++ /dev/null @@ -1,78 +0,0 @@ -setGrammar($grammar); - } + private $cachedValue = null; /** * Set the character set used in this Header. @@ -81,10 +66,10 @@ public function __construct(Swift_Mime_Grammar $grammar) */ public function setCharset($charset) { - $this->clearCachedValueIf($charset != $this->_charset); - $this->_charset = $charset; - if (isset($this->_encoder)) { - $this->_encoder->charsetChanged($charset); + $this->clearCachedValueIf($charset != $this->charset); + $this->charset = $charset; + if (isset($this->encoder)) { + $this->encoder->charsetChanged($charset); } } @@ -95,7 +80,7 @@ public function setCharset($charset) */ public function getCharset() { - return $this->_charset; + return $this->charset; } /** @@ -108,8 +93,8 @@ public function getCharset() */ public function setLanguage($lang) { - $this->clearCachedValueIf($this->_lang != $lang); - $this->_lang = $lang; + $this->clearCachedValueIf($this->lang != $lang); + $this->lang = $lang; } /** @@ -119,7 +104,7 @@ public function setLanguage($lang) */ public function getLanguage() { - return $this->_lang; + return $this->lang; } /** @@ -129,7 +114,7 @@ public function getLanguage() */ public function setEncoder(Swift_Mime_HeaderEncoder $encoder) { - $this->_encoder = $encoder; + $this->encoder = $encoder; $this->setCachedValue(null); } @@ -140,28 +125,7 @@ public function setEncoder(Swift_Mime_HeaderEncoder $encoder) */ public function getEncoder() { - return $this->_encoder; - } - - /** - * Set the grammar used for the header. - * - * @param Swift_Mime_Grammar $grammar - */ - public function setGrammar(Swift_Mime_Grammar $grammar) - { - $this->_grammar = $grammar; - $this->setCachedValue(null); - } - - /** - * Get the grammar used for this Header. - * - * @return Swift_Mime_Grammar - */ - public function getGrammar() - { - return $this->_grammar; + return $this->encoder; } /** @@ -171,7 +135,7 @@ public function getGrammar() */ public function getFieldName() { - return $this->_name; + return $this->name; } /** @@ -181,8 +145,8 @@ public function getFieldName() */ public function setMaxLineLength($lineLength) { - $this->clearCachedValueIf($this->_lineLength != $lineLength); - $this->_lineLength = $lineLength; + $this->clearCachedValueIf($this->lineLength != $lineLength); + $this->lineLength = $lineLength; } /** @@ -192,19 +156,19 @@ public function setMaxLineLength($lineLength) */ public function getMaxLineLength() { - return $this->_lineLength; + return $this->lineLength; } /** * Get this Header rendered as a RFC 2822 compliant string. * - * @throws Swift_RfcComplianceException - * * @return string + * + * @throws Swift_RfcComplianceException */ public function toString() { - return $this->_tokensToString($this->toTokens()); + return $this->tokensToString($this->toTokens()); } /** @@ -226,7 +190,7 @@ public function __toString() */ protected function setFieldName($name) { - $this->_name = $name; + $this->name = $name; } /** @@ -245,13 +209,12 @@ protected function createPhrase(Swift_Mime_Header $header, $string, $charset, Sw // Treat token as exactly what was given $phraseStr = $string; // If it's not valid - if (!preg_match('/^'.$this->getGrammar()->getDefinition('phrase').'$/D', $phraseStr)) { + + if (!preg_match('/^'.self::PHRASE_PATTERN.'$/D', $phraseStr)) { // .. but it is just ascii text, try escaping some characters // and make it a quoted-string - if (preg_match('/^'.$this->getGrammar()->getDefinition('text').'*$/D', $phraseStr)) { - $phraseStr = $this->getGrammar()->escapeSpecials( - $phraseStr, array('"'), $this->getGrammar()->getSpecials() - ); + if (preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $phraseStr)) { + $phraseStr = $this->escapeSpecials($phraseStr, array('"')); $phraseStr = '"'.$phraseStr.'"'; } else { // ... otherwise it needs encoding @@ -268,6 +231,23 @@ protected function createPhrase(Swift_Mime_Header $header, $string, $charset, Sw return $phraseStr; } + /** + * Escape special characters in a string (convert to quoted-pairs). + * + * @param string $token + * @param string[] $include additional chars to escape + * + * @return string + */ + private function escapeSpecials($token, $include = array()) + { + foreach (array_merge(array('\\'), $include) as $char) { + $token = str_replace($char, '\\'.$char, $token); + } + + return $token; + } + /** * Encode needed word tokens within a string of input. * @@ -363,12 +343,12 @@ protected function getEncodableWordTokens($string) protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) { // Adjust $firstLineOffset to account for space needed for syntax - $charsetDecl = $this->_charset; - if (isset($this->_lang)) { - $charsetDecl .= '*'.$this->_lang; + $charsetDecl = $this->charset; + if (isset($this->lang)) { + $charsetDecl .= '*'.$this->lang; } $encodingWrapperLength = strlen( - '=?'.$charsetDecl.'?'.$this->_encoder->getName().'??=' + '=?'.$charsetDecl.'?'.$this->encoder->getName().'??=' ); if ($firstLineOffset >= 75) { @@ -377,16 +357,16 @@ protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) } $encodedTextLines = explode("\r\n", - $this->_encoder->encodeString( - $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->_charset + $this->encoder->encodeString( + $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->charset ) ); - if (strtolower($this->_charset) !== 'iso-2022-jp') { + if (strtolower($this->charset) !== 'iso-2022-jp') { // special encoding for iso-2022-jp using mb_encode_mimeheader foreach ($encodedTextLines as $lineNum => $line) { $encodedTextLines[$lineNum] = '=?'.$charsetDecl. - '?'.$this->_encoder->getName(). + '?'.$this->encoder->getName(). '?'.$line.'?='; } } @@ -413,7 +393,7 @@ protected function generateTokenLines($token) */ protected function setCachedValue($value) { - $this->_cachedValue = $value; + $this->cachedValue = $value; } /** @@ -423,7 +403,7 @@ protected function setCachedValue($value) */ protected function getCachedValue() { - return $this->_cachedValue; + return $this->cachedValue; } /** @@ -472,18 +452,18 @@ protected function toTokens($string = null) * * @return string */ - private function _tokensToString(array $tokens) + private function tokensToString(array $tokens) { $lineCount = 0; $headerLines = array(); - $headerLines[] = $this->_name.': '; + $headerLines[] = $this->name.': '; $currentLine = &$headerLines[$lineCount++]; // Build all tokens back into compliant header foreach ($tokens as $i => $token) { // Line longer than specified maximum or token was just a new line if (("\r\n" == $token) || - ($i > 0 && strlen($currentLine.$token) > $this->_lineLength) + ($i > 0 && strlen($currentLine.$token) > $this->lineLength) && 0 < strlen($currentLine)) { $headerLines[] = ''; $currentLine = &$headerLines[$lineCount++]; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php index 4075cbfa1..6dcc92bfd 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php @@ -16,29 +16,20 @@ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader { /** - * The UNIX timestamp value of this Header. + * Date-time value of this Header. * - * @var int + * @var DateTimeImmutable */ - private $_timestamp; + private $dateTime; /** - * Creates a new DateHeader with $name and $timestamp. + * Creates a new DateHeader with $name. * - * Example: - * - * - * - * - * @param string $name of Header - * @param Swift_Mime_Grammar $grammar + * @param string $name of Header */ - public function __construct($name, Swift_Mime_Grammar $grammar) + public function __construct($name) { $this->setFieldName($name); - parent::__construct($grammar); } /** @@ -57,49 +48,48 @@ public function getFieldType() /** * Set the model for the field body. * - * This method takes a UNIX timestamp. - * - * @param int $model + * @param DateTimeInterface $model */ public function setFieldBodyModel($model) { - $this->setTimestamp($model); + $this->setDateTime($model); } /** * Get the model for the field body. * - * This method returns a UNIX timestamp. - * - * @return mixed + * @return DateTimeImmutable */ public function getFieldBodyModel() { - return $this->getTimestamp(); + return $this->getDateTime(); } /** - * Get the UNIX timestamp of the Date in this Header. + * Get the date-time representing the Date in this Header. * - * @return int + * @return DateTimeImmutable */ - public function getTimestamp() + public function getDateTime() { - return $this->_timestamp; + return $this->dateTime; } /** - * Set the UNIX timestamp of the Date in this Header. + * Set the date-time of the Date in this Header. + * + * If a DateTime instance is provided, it is converted to DateTimeImmutable. * - * @param int $timestamp + * @param DateTimeInterface $dateTime */ - public function setTimestamp($timestamp) + public function setDateTime(DateTimeInterface $dateTime) { - if (null !== $timestamp) { - $timestamp = (int) $timestamp; + $this->clearCachedValueIf($this->getCachedValue() != $dateTime->format(DateTime::RFC2822)); + if ($dateTime instanceof DateTime) { + $immutable = new DateTimeImmutable('@'.$dateTime->getTimestamp()); + $dateTime = $immutable->setTimezone($dateTime->getTimezone()); } - $this->clearCachedValueIf($this->_timestamp != $timestamp); - $this->_timestamp = $timestamp; + $this->dateTime = $dateTime; } /** @@ -115,8 +105,8 @@ public function setTimestamp($timestamp) public function getFieldBody() { if (!$this->getCachedValue()) { - if (isset($this->_timestamp)) { - $this->setCachedValue(date('r', $this->_timestamp)); + if (isset($this->dateTime)) { + $this->setCachedValue($this->dateTime->format(DateTime::RFC2822)); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php index b114506b4..acf794479 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php @@ -8,6 +8,9 @@ * file that was distributed with this source code. */ +use Egulias\EmailValidator\EmailValidator; +use Egulias\EmailValidator\Validation\RFCValidation; + /** * An ID MIME Header for something like Message-ID or Content-ID. * @@ -22,18 +25,25 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac * * @var string[] */ - private $_ids = array(); + private $ids = array(); + + /** + * The strict EmailValidator. + * + * @var EmailValidator + */ + private $emailValidator; /** * Creates a new IdentificationHeader with the given $name and $id. * - * @param string $name - * @param Swift_Mime_Grammar $grammar + * @param string $name + * @param EmailValidator $emailValidator */ - public function __construct($name, Swift_Mime_Grammar $grammar) + public function __construct($name, EmailValidator $emailValidator) { $this->setFieldName($name); - parent::__construct($grammar); + $this->emailValidator = $emailValidator; } /** @@ -96,8 +106,8 @@ public function setId($id) */ public function getId() { - if (count($this->_ids) > 0) { - return $this->_ids[0]; + if (count($this->ids) > 0) { + return $this->ids[0]; } } @@ -113,12 +123,12 @@ public function setIds(array $ids) $actualIds = array(); foreach ($ids as $id) { - $this->_assertValidId($id); + $this->assertValidId($id); $actualIds[] = $id; } - $this->clearCachedValueIf($this->_ids != $actualIds); - $this->_ids = $actualIds; + $this->clearCachedValueIf($this->ids != $actualIds); + $this->ids = $actualIds; } /** @@ -128,7 +138,7 @@ public function setIds(array $ids) */ public function getIds() { - return $this->_ids; + return $this->ids; } /** @@ -148,7 +158,7 @@ public function getFieldBody() if (!$this->getCachedValue()) { $angleAddrs = array(); - foreach ($this->_ids as $id) { + foreach ($this->ids as $id) { $angleAddrs[] = '<'.$id.'>'; } @@ -165,16 +175,10 @@ public function getFieldBody() * * @throws Swift_RfcComplianceException */ - private function _assertValidId($id) + private function assertValidId($id) { - if (!preg_match( - '/^'.$this->getGrammar()->getDefinition('id-left').'@'. - $this->getGrammar()->getDefinition('id-right').'$/D', - $id - )) { - throw new Swift_RfcComplianceException( - 'Invalid ID given <'.$id.'>' - ); + if (!$this->emailValidator->isValid($id, new RFCValidation())) { + throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>'); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php index e4567fc80..450e0f25b 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php @@ -8,6 +8,9 @@ * file that was distributed with this source code. */ +use Egulias\EmailValidator\EmailValidator; +use Egulias\EmailValidator\Validation\RFCValidation; + /** * A Mailbox Address MIME Header for something like From or Sender. * @@ -20,20 +23,27 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader * * @var string[] */ - private $_mailboxes = array(); + private $mailboxes = array(); + + /** + * The strict EmailValidator. + * + * @var EmailValidator + */ + private $emailValidator; /** * Creates a new MailboxHeader with $name. * - * @param string $name of Header + * @param string $name of Header * @param Swift_Mime_HeaderEncoder $encoder - * @param Swift_Mime_Grammar $grammar + * @param EmailValidator $emailValidator */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Mime_Grammar $grammar) + public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator) { $this->setFieldName($name); $this->setEncoder($encoder); - parent::__construct($grammar); + $this->emailValidator = $emailValidator; } /** @@ -103,7 +113,7 @@ public function getFieldBodyModel() */ public function setNameAddresses($mailboxes) { - $this->_mailboxes = $this->normalizeMailboxes((array) $mailboxes); + $this->mailboxes = $this->normalizeMailboxes((array) $mailboxes); $this->setCachedValue(null); //Clear any cached value } @@ -134,7 +144,7 @@ public function setNameAddresses($mailboxes) */ public function getNameAddressStrings() { - return $this->_createNameAddressStrings($this->getNameAddresses()); + return $this->createNameAddressStrings($this->getNameAddresses()); } /** @@ -163,7 +173,7 @@ public function getNameAddressStrings() */ public function getNameAddresses() { - return $this->_mailboxes; + return $this->mailboxes; } /** @@ -200,7 +210,7 @@ public function setAddresses($addresses) */ public function getAddresses() { - return array_keys($this->_mailboxes); + return array_keys($this->mailboxes); } /** @@ -212,7 +222,7 @@ public function removeAddresses($addresses) { $this->setCachedValue(null); foreach ((array) $addresses as $address) { - unset($this->_mailboxes[$address]); + unset($this->mailboxes[$address]); } } @@ -232,7 +242,7 @@ public function getFieldBody() { // Compute the string value of the header only if needed if (null === $this->getCachedValue()) { - $this->setCachedValue($this->createMailboxListString($this->_mailboxes)); + $this->setCachedValue($this->createMailboxListString($this->mailboxes)); } return $this->getCachedValue(); @@ -258,7 +268,7 @@ protected function normalizeMailboxes(array $mailboxes) $address = $value; $name = null; } - $this->_assertValidAddress($address); + $this->assertValidAddress($address); $actualMailboxes[$address] = $name; } @@ -289,7 +299,7 @@ protected function createDisplayNameString($displayName, $shorten = false) */ protected function createMailboxListString(array $mailboxes) { - return implode(', ', $this->_createNameAddressStrings($mailboxes)); + return implode(', ', $this->createNameAddressStrings($mailboxes)); } /** @@ -315,7 +325,7 @@ protected function tokenNeedsEncoding($token) * * @return string[] */ - private function _createNameAddressStrings(array $mailboxes) + private function createNameAddressStrings(array $mailboxes) { $strings = array(); @@ -338,14 +348,12 @@ private function _createNameAddressStrings(array $mailboxes) * * @throws Swift_RfcComplianceException If invalid. */ - private function _assertValidAddress($address) + private function assertValidAddress($address) { - if (!preg_match('/^'.$this->getGrammar()->getDefinition('addr-spec').'$/D', - $address)) { + if (!$this->emailValidator->isValid($address, new RFCValidation())) { throw new Swift_RfcComplianceException( - 'Address in mailbox given ['.$address. - '] does not comply with RFC 2822, 3.6.2.' - ); + 'Address in mailbox given ['.$address.'] does not comply with RFC 2822, 3.6.2.' + ); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php index d74955007..29277994c 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php @@ -20,21 +20,21 @@ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header * * @var string */ - private $_value; + private $value; /** * The name of this Header. * * @var string */ - private $_fieldName; + private $fieldName; /** * @param string $name */ public function __construct($name) { - $this->_fieldName = $name; + $this->fieldName = $name; } /** @@ -81,7 +81,7 @@ public function getFieldBodyModel() */ public function getValue() { - return $this->_value; + return $this->value; } /** @@ -91,7 +91,7 @@ public function getValue() */ public function setValue($value) { - $this->_value = $value; + $this->value = $value; } /** @@ -101,7 +101,7 @@ public function setValue($value) */ public function getFieldBody() { - return $this->_value; + return $this->value; } /** @@ -111,7 +111,7 @@ public function getFieldBody() */ public function toString() { - return $this->_fieldName.': '.$this->_value; + return $this->fieldName.': '.$this->value; } /** @@ -121,7 +121,7 @@ public function toString() */ public function getFieldName() { - return $this->_fieldName; + return $this->fieldName; } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php index c1777d333..b4a0ddf12 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php @@ -13,7 +13,7 @@ * * @author Chris Corbyn */ -class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_UnstructuredHeader implements Swift_Mime_ParameterizedHeader +class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_UnstructuredHeader { /** * RFC 2231's definition of a token. @@ -27,14 +27,14 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct * * @var Swift_Encoder */ - private $_paramEncoder; + private $paramEncoder; /** * The parameters as an associative array. * * @var string[] */ - private $_params = array(); + private $params = array(); /** * Creates a new ParameterizedHeader with $name. @@ -42,12 +42,11 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct * @param string $name * @param Swift_Mime_HeaderEncoder $encoder * @param Swift_Encoder $paramEncoder, optional - * @param Swift_Mime_Grammar $grammar */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder = null, Swift_Mime_Grammar $grammar) + public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder = null) { - parent::__construct($name, $encoder, $grammar); - $this->_paramEncoder = $paramEncoder; + parent::__construct($name, $encoder); + $this->paramEncoder = $paramEncoder; } /** @@ -71,8 +70,8 @@ public function getFieldType() public function setCharset($charset) { parent::setCharset($charset); - if (isset($this->_paramEncoder)) { - $this->_paramEncoder->charsetChanged($charset); + if (isset($this->paramEncoder)) { + $this->paramEncoder->charsetChanged($charset); } } @@ -98,7 +97,7 @@ public function getParameter($parameter) { $params = $this->getParameters(); - return array_key_exists($parameter, $params) ? $params[$parameter] : null; + return $params[$parameter] ?? null; } /** @@ -108,8 +107,8 @@ public function getParameter($parameter) */ public function setParameters(array $parameters) { - $this->clearCachedValueIf($this->_params != $parameters); - $this->_params = $parameters; + $this->clearCachedValueIf($this->params != $parameters); + $this->params = $parameters; } /** @@ -119,7 +118,7 @@ public function setParameters(array $parameters) */ public function getParameters() { - return $this->_params; + return $this->params; } /** @@ -130,10 +129,10 @@ public function getParameters() public function getFieldBody() //TODO: Check caching here { $body = parent::getFieldBody(); - foreach ($this->_params as $name => $value) { + foreach ($this->params as $name => $value) { if (null !== $value) { // Add the parameter - $body .= '; '.$this->_createParameter($name, $value); + $body .= '; '.$this->createParameter($name, $value); } } @@ -155,12 +154,12 @@ protected function toTokens($string = null) $tokens = parent::toTokens(parent::getFieldBody()); // Try creating any parameters - foreach ($this->_params as $name => $value) { + foreach ($this->params as $name => $value) { if (null !== $value) { // Add the semi-colon separator $tokens[count($tokens) - 1] .= ';'; $tokens = array_merge($tokens, $this->generateTokenLines( - ' '.$this->_createParameter($name, $value) + ' '.$this->createParameter($name, $value) )); } } @@ -176,7 +175,7 @@ protected function toTokens($string = null) * * @return string */ - private function _createParameter($name, $value) + private function createParameter($name, $value) { $origValue = $value; @@ -189,7 +188,7 @@ private function _createParameter($name, $value) if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { // TODO: text, or something else?? // ... and it's not ascii - if (!preg_match('/^'.$this->getGrammar()->getDefinition('text').'*$/D', $value)) { + if (!preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $value)) { $encoded = true; // Allow space for the indices, charset and language $maxValueLength = $this->getMaxLineLength() - strlen($name.'*N*="";') - 1; @@ -201,8 +200,8 @@ private function _createParameter($name, $value) // Encode if we need to if ($encoded || strlen($value) > $maxValueLength) { - if (isset($this->_paramEncoder)) { - $value = $this->_paramEncoder->encodeString( + if (isset($this->paramEncoder)) { + $value = $this->paramEncoder->encodeString( $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() ); } else { @@ -212,19 +211,19 @@ private function _createParameter($name, $value) } } - $valueLines = isset($this->_paramEncoder) ? explode("\r\n", $value) : array($value); + $valueLines = isset($this->paramEncoder) ? explode("\r\n", $value) : array($value); // Need to add indices if (count($valueLines) > 1) { $paramLines = array(); foreach ($valueLines as $i => $line) { $paramLines[] = $name.'*'.$i. - $this->_getEndOfParameterValue($line, true, $i == 0); + $this->getEndOfParameterValue($line, true, $i == 0); } return implode(";\r\n ", $paramLines); } else { - return $name.$this->_getEndOfParameterValue( + return $name.$this->getEndOfParameterValue( $valueLines[0], $encoded, true ); } @@ -239,7 +238,7 @@ private function _createParameter($name, $value) * * @return string */ - private function _getEndOfParameterValue($value, $encoded = false, $firstLine = false) + private function getEndOfParameterValue($value, $encoded = false, $firstLine = false) { if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { $value = '"'.$value.'"'; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php index 4a814b122..f79e19fd8 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php @@ -8,6 +8,9 @@ * file that was distributed with this source code. */ +use Egulias\EmailValidator\EmailValidator; +use Egulias\EmailValidator\Validation\RFCValidation; + /** * A Path Header in Swift Mailer, such a Return-Path. * @@ -20,18 +23,25 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader * * @var string */ - private $_address; + private $address; + + /** + * The strict EmailValidator. + * + * @var EmailValidator + */ + private $emailValidator; /** * Creates a new PathHeader with the given $name. * - * @param string $name - * @param Swift_Mime_Grammar $grammar + * @param string $name + * @param EmailValidator $emailValidator */ - public function __construct($name, Swift_Mime_Grammar $grammar) + public function __construct($name, EmailValidator $emailValidator) { $this->setFieldName($name); - parent::__construct($grammar); + $this->emailValidator = $emailValidator; } /** @@ -81,12 +91,12 @@ public function getFieldBodyModel() public function setAddress($address) { if (null === $address) { - $this->_address = null; + $this->address = null; } elseif ('' == $address) { - $this->_address = ''; + $this->address = ''; } else { - $this->_assertValidAddress($address); - $this->_address = $address; + $this->assertValidAddress($address); + $this->address = $address; } $this->setCachedValue(null); } @@ -100,7 +110,7 @@ public function setAddress($address) */ public function getAddress() { - return $this->_address; + return $this->address; } /** @@ -116,8 +126,8 @@ public function getAddress() public function getFieldBody() { if (!$this->getCachedValue()) { - if (isset($this->_address)) { - $this->setCachedValue('<'.$this->_address.'>'); + if (isset($this->address)) { + $this->setCachedValue('<'.$this->address.'>'); } } @@ -131,13 +141,12 @@ public function getFieldBody() * * @throws Swift_RfcComplianceException If address is invalid */ - private function _assertValidAddress($address) + private function assertValidAddress($address) { - if (!preg_match('/^'.$this->getGrammar()->getDefinition('addr-spec').'$/D', - $address)) { + if (!$this->emailValidator->isValid($address, new RFCValidation())) { throw new Swift_RfcComplianceException( 'Address set in PathHeader does not comply with addr-spec of RFC 2822.' - ); + ); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php index 86177f14a..d9d9f5e25 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php @@ -20,20 +20,18 @@ class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractH * * @var string */ - private $_value; + private $value; /** * Creates a new SimpleHeader with $name. * * @param string $name * @param Swift_Mime_HeaderEncoder $encoder - * @param Swift_Mime_Grammar $grammar */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Mime_Grammar $grammar) + public function __construct($name, Swift_Mime_HeaderEncoder $encoder) { $this->setFieldName($name); $this->setEncoder($encoder); - parent::__construct($grammar); } /** @@ -80,7 +78,7 @@ public function getFieldBodyModel() */ public function getValue() { - return $this->_value; + return $this->value; } /** @@ -90,8 +88,8 @@ public function getValue() */ public function setValue($value) { - $this->clearCachedValueIf($this->_value != $value); - $this->_value = $value; + $this->clearCachedValueIf($this->value != $value); + $this->value = $value; } /** @@ -103,7 +101,7 @@ public function getFieldBody() { if (!$this->getCachedValue()) { $this->setCachedValue( - $this->encodeWords($this, $this->_value) + $this->encodeWords($this, $this->value) ); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php new file mode 100644 index 000000000..6e98ee897 --- /dev/null +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php @@ -0,0 +1,53 @@ +idRight = $idRight; + } + + /** + * Returns the right-hand side of the "@" used in all generated IDs. + * + * @return string + */ + public function getIdRight() + { + return $this->idRight; + } + + /** + * Sets the right-hand side of the "@" to use in all generated IDs. + * + * @param string $idRight + */ + public function setIdRight($idRight) + { + $this->idRight = $idRight; + } + + /** + * @return string + */ + public function generateId() + { + $idLeft = bin2hex(random_bytes(16)); // set 32 hex values + + return $idLeft.'@'.$this->idRight; + } +} diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php deleted file mode 100644 index 9b36d2162..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php +++ /dev/null @@ -1,223 +0,0 @@ - 'Real Name'). - * - * If the second parameter is provided and the first is a string, then $name - * is associated with the address. - * - * @param mixed $address - * @param string $name optional - */ - public function setSender($address, $name = null); - - /** - * Get the sender address for this message. - * - * This has a higher significance than the From address. - * - * @return string - */ - public function getSender(); - - /** - * Set the From address of this message. - * - * It is permissible for multiple From addresses to be set using an array. - * - * If multiple From addresses are used, you SHOULD set the Sender address and - * according to RFC 2822, MUST set the sender address. - * - * An array can be used if display names are to be provided: i.e. - * array('email@address.com' => 'Real Name'). - * - * If the second parameter is provided and the first is a string, then $name - * is associated with the address. - * - * @param mixed $addresses - * @param string $name optional - */ - public function setFrom($addresses, $name = null); - - /** - * Get the From address(es) of this message. - * - * This method always returns an associative array where the keys are the - * addresses. - * - * @return string[] - */ - public function getFrom(); - - /** - * Set the Reply-To address(es). - * - * Any replies from the receiver will be sent to this address. - * - * It is permissible for multiple reply-to addresses to be set using an array. - * - * This method has the same synopsis as {@link setFrom()} and {@link setTo()}. - * - * If the second parameter is provided and the first is a string, then $name - * is associated with the address. - * - * @param mixed $addresses - * @param string $name optional - */ - public function setReplyTo($addresses, $name = null); - - /** - * Get the Reply-To addresses for this message. - * - * This method always returns an associative array where the keys provide the - * email addresses. - * - * @return string[] - */ - public function getReplyTo(); - - /** - * Set the To address(es). - * - * Recipients set in this field will receive a copy of this message. - * - * This method has the same synopsis as {@link setFrom()} and {@link setCc()}. - * - * If the second parameter is provided and the first is a string, then $name - * is associated with the address. - * - * @param mixed $addresses - * @param string $name optional - */ - public function setTo($addresses, $name = null); - - /** - * Get the To addresses for this message. - * - * This method always returns an associative array, whereby the keys provide - * the actual email addresses. - * - * @return string[] - */ - public function getTo(); - - /** - * Set the Cc address(es). - * - * Recipients set in this field will receive a 'carbon-copy' of this message. - * - * This method has the same synopsis as {@link setFrom()} and {@link setTo()}. - * - * @param mixed $addresses - * @param string $name optional - */ - public function setCc($addresses, $name = null); - - /** - * Get the Cc addresses for this message. - * - * This method always returns an associative array, whereby the keys provide - * the actual email addresses. - * - * @return string[] - */ - public function getCc(); - - /** - * Set the Bcc address(es). - * - * Recipients set in this field will receive a 'blind-carbon-copy' of this - * message. - * - * In other words, they will get the message, but any other recipients of the - * message will have no such knowledge of their receipt of it. - * - * This method has the same synopsis as {@link setFrom()} and {@link setTo()}. - * - * @param mixed $addresses - * @param string $name optional - */ - public function setBcc($addresses, $name = null); - - /** - * Get the Bcc addresses for this message. - * - * This method always returns an associative array, whereby the keys provide - * the actual email addresses. - * - * @return string[] - */ - public function getBcc(); -} diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php deleted file mode 100644 index 30f460cdc..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php +++ /dev/null @@ -1,117 +0,0 @@ -setContentType('text/plain'); if (null !== $charset) { $this->setCharset($charset); @@ -60,7 +60,7 @@ public function setBody($body, $contentType = null, $charset = null) if (isset($charset)) { $this->setCharset($charset); } - $body = $this->_convertString($body); + $body = $this->convertString($body); parent::setBody($body, $contentType); @@ -74,7 +74,7 @@ public function setBody($body, $contentType = null, $charset = null) */ public function getCharset() { - return $this->_getHeaderParameter('Content-Type', 'charset'); + return $this->getHeaderParameter('Content-Type', 'charset'); } /** @@ -86,11 +86,11 @@ public function getCharset() */ public function setCharset($charset) { - $this->_setHeaderParameter('Content-Type', 'charset', $charset); - if ($charset !== $this->_userCharset) { - $this->_clearCache(); + $this->setHeaderParameter('Content-Type', 'charset', $charset); + if ($charset !== $this->userCharset) { + $this->clearCache(); } - $this->_userCharset = $charset; + $this->userCharset = $charset; parent::charsetChanged($charset); return $this; @@ -103,7 +103,7 @@ public function setCharset($charset) */ public function getFormat() { - return $this->_getHeaderParameter('Content-Type', 'format'); + return $this->getHeaderParameter('Content-Type', 'format'); } /** @@ -115,8 +115,8 @@ public function getFormat() */ public function setFormat($format) { - $this->_setHeaderParameter('Content-Type', 'format', $format); - $this->_userFormat = $format; + $this->setHeaderParameter('Content-Type', 'format', $format); + $this->userFormat = $format; return $this; } @@ -128,7 +128,7 @@ public function setFormat($format) */ public function getDelSp() { - return 'yes' == $this->_getHeaderParameter('Content-Type', 'delsp') ? true : false; + return 'yes' === $this->getHeaderParameter('Content-Type', 'delsp'); } /** @@ -140,8 +140,8 @@ public function getDelSp() */ public function setDelSp($delsp = true) { - $this->_setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null); - $this->_userDelSp = $delsp; + $this->setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null); + $this->userDelSp = $delsp; return $this; } @@ -155,7 +155,7 @@ public function setDelSp($delsp = true) */ public function getNestingLevel() { - return $this->_nestingLevel; + return $this->nestingLevel; } /** @@ -170,28 +170,28 @@ public function charsetChanged($charset) } /** Fix the content-type and encoding of this entity */ - protected function _fixHeaders() + protected function fixHeaders() { - parent::_fixHeaders(); + parent::fixHeaders(); if (count($this->getChildren())) { - $this->_setHeaderParameter('Content-Type', 'charset', null); - $this->_setHeaderParameter('Content-Type', 'format', null); - $this->_setHeaderParameter('Content-Type', 'delsp', null); + $this->setHeaderParameter('Content-Type', 'charset', null); + $this->setHeaderParameter('Content-Type', 'format', null); + $this->setHeaderParameter('Content-Type', 'delsp', null); } else { - $this->setCharset($this->_userCharset); - $this->setFormat($this->_userFormat); - $this->setDelSp($this->_userDelSp); + $this->setCharset($this->userCharset); + $this->setFormat($this->userFormat); + $this->setDelSp($this->userDelSp); } } /** Set the nesting level of this entity */ - protected function _setNestingLevel($level) + protected function setNestingLevel($level) { - $this->_nestingLevel = $level; + $this->nestingLevel = $level; } /** Encode charset when charset is not utf-8 */ - protected function _convertString($string) + protected function convertString($string) { $charset = strtolower($this->getCharset()); if (!in_array($charset, array('utf-8', 'iso-8859-1', 'iso-8859-15', ''))) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php deleted file mode 100644 index e15c6ef95..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php +++ /dev/null @@ -1,34 +0,0 @@ -_encoder = $encoder; - $this->_paramEncoder = $paramEncoder; - $this->_grammar = $grammar; - $this->_charset = $charset; + $this->encoder = $encoder; + $this->paramEncoder = $paramEncoder; + $this->emailValidator = $emailValidator; + $this->charset = $charset; } /** @@ -53,30 +58,30 @@ public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $pa */ public function createMailboxHeader($name, $addresses = null) { - $header = new Swift_Mime_Headers_MailboxHeader($name, $this->_encoder, $this->_grammar); + $header = new Swift_Mime_Headers_MailboxHeader($name, $this->encoder, $this->emailValidator); if (isset($addresses)) { $header->setFieldBodyModel($addresses); } - $this->_setHeaderCharset($header); + $this->setHeaderCharset($header); return $header; } /** - * Create a new Date header using $timestamp (UNIX time). + * Create a new Date header using $dateTime. * - * @param string $name - * @param int|null $timestamp + * @param string $name + * @param DateTimeInterface|null $dateTime * * @return Swift_Mime_Header */ - public function createDateHeader($name, $timestamp = null) + public function createDateHeader($name, DateTimeInterface $dateTime = null) { - $header = new Swift_Mime_Headers_DateHeader($name, $this->_grammar); - if (isset($timestamp)) { - $header->setFieldBodyModel($timestamp); + $header = new Swift_Mime_Headers_DateHeader($name); + if (isset($dateTime)) { + $header->setFieldBodyModel($dateTime); } - $this->_setHeaderCharset($header); + $this->setHeaderCharset($header); return $header; } @@ -91,11 +96,11 @@ public function createDateHeader($name, $timestamp = null) */ public function createTextHeader($name, $value = null) { - $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->_encoder, $this->_grammar); + $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->encoder); if (isset($value)) { $header->setFieldBodyModel($value); } - $this->_setHeaderCharset($header); + $this->setHeaderCharset($header); return $header; } @@ -107,19 +112,18 @@ public function createTextHeader($name, $value = null) * @param string $value * @param array $params * - * @return Swift_Mime_ParameterizedHeader + * @return Swift_Mime_Headers_ParameterizedHeader */ - public function createParameterizedHeader($name, $value = null, - $params = array()) + public function createParameterizedHeader($name, $value = null, $params = array()) { - $header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->_encoder, strtolower($name) == 'content-disposition' ? $this->_paramEncoder : null, $this->_grammar); + $header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->encoder, (strtolower($name) == 'content-disposition') ? $this->paramEncoder : null); if (isset($value)) { $header->setFieldBodyModel($value); } foreach ($params as $k => $v) { $header->setParameter($k, $v); } - $this->_setHeaderCharset($header); + $this->setHeaderCharset($header); return $header; } @@ -134,11 +138,11 @@ public function createParameterizedHeader($name, $value = null, */ public function createIdHeader($name, $ids = null) { - $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->_grammar); + $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->emailValidator); if (isset($ids)) { $header->setFieldBodyModel($ids); } - $this->_setHeaderCharset($header); + $this->setHeaderCharset($header); return $header; } @@ -153,11 +157,11 @@ public function createIdHeader($name, $ids = null) */ public function createPathHeader($name, $path = null) { - $header = new Swift_Mime_Headers_PathHeader($name, $this->_grammar); + $header = new Swift_Mime_Headers_PathHeader($name, $this->emailValidator); if (isset($path)) { $header->setFieldBodyModel($path); } - $this->_setHeaderCharset($header); + $this->setHeaderCharset($header); return $header; } @@ -169,9 +173,9 @@ public function createPathHeader($name, $path = null) */ public function charsetChanged($charset) { - $this->_charset = $charset; - $this->_encoder->charsetChanged($charset); - $this->_paramEncoder->charsetChanged($charset); + $this->charset = $charset; + $this->encoder->charsetChanged($charset); + $this->paramEncoder->charsetChanged($charset); } /** @@ -179,15 +183,15 @@ public function charsetChanged($charset) */ public function __clone() { - $this->_encoder = clone $this->_encoder; - $this->_paramEncoder = clone $this->_paramEncoder; + $this->encoder = clone $this->encoder; + $this->paramEncoder = clone $this->paramEncoder; } /** Apply the charset to the Header */ - private function _setHeaderCharset(Swift_Mime_Header $header) + private function setHeaderCharset(Swift_Mime_Header $header) { - if (isset($this->_charset)) { - $header->setCharset($this->_charset); + if (isset($this->charset)) { + $header->setCharset($this->charset); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php index a06ce7247..6f71fcac1 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -13,37 +13,42 @@ * * @author Chris Corbyn */ -class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet +class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver { /** HeaderFactory */ - private $_factory; + private $factory; /** Collection of set Headers */ - private $_headers = array(); + private $headers = array(); /** Field ordering details */ - private $_order = array(); + private $order = array(); /** List of fields which are required to be displayed */ - private $_required = array(); + private $required = array(); /** The charset used by Headers */ - private $_charset; + private $charset; /** * Create a new SimpleHeaderSet with the given $factory. * - * @param Swift_Mime_HeaderFactory $factory - * @param string $charset + * @param Swift_Mime_SimpleHeaderFactory $factory + * @param string $charset */ - public function __construct(Swift_Mime_HeaderFactory $factory, $charset = null) + public function __construct(Swift_Mime_SimpleHeaderFactory $factory, $charset = null) { - $this->_factory = $factory; + $this->factory = $factory; if (isset($charset)) { $this->setCharset($charset); } } + public function newInstance() + { + return new self($this->factory); + } + /** * Set the charset used by these headers. * @@ -51,9 +56,9 @@ public function __construct(Swift_Mime_HeaderFactory $factory, $charset = null) */ public function setCharset($charset) { - $this->_charset = $charset; - $this->_factory->charsetChanged($charset); - $this->_notifyHeadersOfCharset($charset); + $this->charset = $charset; + $this->factory->charsetChanged($charset); + $this->notifyHeadersOfCharset($charset); } /** @@ -64,20 +69,20 @@ public function setCharset($charset) */ public function addMailboxHeader($name, $addresses = null) { - $this->_storeHeader($name, - $this->_factory->createMailboxHeader($name, $addresses)); + $this->storeHeader($name, + $this->factory->createMailboxHeader($name, $addresses)); } /** - * Add a new Date header using $timestamp (UNIX time). + * Add a new Date header using $dateTime. * - * @param string $name - * @param int $timestamp + * @param string $name + * @param DateTimeInterface $dateTime */ - public function addDateHeader($name, $timestamp = null) + public function addDateHeader($name, DateTimeInterface $dateTime = null) { - $this->_storeHeader($name, - $this->_factory->createDateHeader($name, $timestamp)); + $this->storeHeader($name, + $this->factory->createDateHeader($name, $dateTime)); } /** @@ -88,8 +93,8 @@ public function addDateHeader($name, $timestamp = null) */ public function addTextHeader($name, $value = null) { - $this->_storeHeader($name, - $this->_factory->createTextHeader($name, $value)); + $this->storeHeader($name, + $this->factory->createTextHeader($name, $value)); } /** @@ -101,7 +106,7 @@ public function addTextHeader($name, $value = null) */ public function addParameterizedHeader($name, $value = null, $params = array()) { - $this->_storeHeader($name, $this->_factory->createParameterizedHeader($name, $value, $params)); + $this->storeHeader($name, $this->factory->createParameterizedHeader($name, $value, $params)); } /** @@ -112,7 +117,7 @@ public function addParameterizedHeader($name, $value = null, $params = array()) */ public function addIdHeader($name, $ids = null) { - $this->_storeHeader($name, $this->_factory->createIdHeader($name, $ids)); + $this->storeHeader($name, $this->factory->createIdHeader($name, $ids)); } /** @@ -123,7 +128,7 @@ public function addIdHeader($name, $ids = null) */ public function addPathHeader($name, $path = null) { - $this->_storeHeader($name, $this->_factory->createPathHeader($name, $path)); + $this->storeHeader($name, $this->factory->createPathHeader($name, $path)); } /** @@ -140,16 +145,16 @@ public function has($name, $index = 0) { $lowerName = strtolower($name); - if (!array_key_exists($lowerName, $this->_headers)) { + if (!array_key_exists($lowerName, $this->headers)) { return false; } if (func_num_args() < 2) { // index was not specified, so we only need to check that there is at least one header value set - return (bool) count($this->_headers[$lowerName]); + return (bool) count($this->headers[$lowerName]); } - return array_key_exists($index, $this->_headers[$lowerName]); + return array_key_exists($index, $this->headers[$lowerName]); } /** @@ -166,7 +171,7 @@ public function has($name, $index = 0) */ public function set(Swift_Mime_Header $header, $index = 0) { - $this->_storeHeader($header->getFieldName(), $header, $index); + $this->storeHeader($header->getFieldName(), $header, $index); } /** @@ -186,13 +191,13 @@ public function get($name, $index = 0) if (func_num_args() < 2) { if ($this->has($name)) { - $values = array_values($this->_headers[$name]); + $values = array_values($this->headers[$name]); return array_shift($values); } } else { if ($this->has($name, $index)) { - return $this->_headers[$name][$index]; + return $this->headers[$name][$index]; } } } @@ -208,7 +213,7 @@ public function getAll($name = null) { if (!isset($name)) { $headers = array(); - foreach ($this->_headers as $collection) { + foreach ($this->headers as $collection) { $headers = array_merge($headers, $collection); } @@ -216,11 +221,11 @@ public function getAll($name = null) } $lowerName = strtolower($name); - if (!array_key_exists($lowerName, $this->_headers)) { + if (!array_key_exists($lowerName, $this->headers)) { return array(); } - return $this->_headers[$lowerName]; + return $this->headers[$lowerName]; } /** @@ -230,9 +235,9 @@ public function getAll($name = null) */ public function listAll() { - $headers = $this->_headers; - if ($this->_canSort()) { - uksort($headers, array($this, '_sortHeaders')); + $headers = $this->headers; + if ($this->canSort()) { + uksort($headers, array($this, 'sortHeaders')); } return array_keys($headers); @@ -249,7 +254,7 @@ public function listAll() public function remove($name, $index = 0) { $lowerName = strtolower($name); - unset($this->_headers[$lowerName][$index]); + unset($this->headers[$lowerName][$index]); } /** @@ -260,17 +265,7 @@ public function remove($name, $index = 0) public function removeAll($name) { $lowerName = strtolower($name); - unset($this->_headers[$lowerName]); - } - - /** - * Create a new instance of this HeaderSet. - * - * @return self - */ - public function newInstance() - { - return new self($this->_factory); + unset($this->headers[$lowerName]); } /** @@ -282,7 +277,7 @@ public function newInstance() */ public function defineOrdering(array $sequence) { - $this->_order = array_flip(array_map('strtolower', $sequence)); + $this->order = array_flip(array_map('strtolower', $sequence)); } /** @@ -294,7 +289,7 @@ public function defineOrdering(array $sequence) */ public function setAlwaysDisplayed(array $names) { - $this->_required = array_flip(array_map('strtolower', $names)); + $this->required = array_flip(array_map('strtolower', $names)); } /** @@ -315,13 +310,13 @@ public function charsetChanged($charset) public function toString() { $string = ''; - $headers = $this->_headers; - if ($this->_canSort()) { - uksort($headers, array($this, '_sortHeaders')); + $headers = $this->headers; + if ($this->canSort()) { + uksort($headers, array($this, 'sortHeaders')); } foreach ($headers as $collection) { foreach ($collection as $header) { - if ($this->_isDisplayed($header) || $header->getFieldBody() != '') { + if ($this->isDisplayed($header) || $header->getFieldBody() != '') { $string .= $header->toString(); } } @@ -343,31 +338,31 @@ public function __toString() } /** Save a Header to the internal collection */ - private function _storeHeader($name, Swift_Mime_Header $header, $offset = null) + private function storeHeader($name, Swift_Mime_Header $header, $offset = null) { - if (!isset($this->_headers[strtolower($name)])) { - $this->_headers[strtolower($name)] = array(); + if (!isset($this->headers[strtolower($name)])) { + $this->headers[strtolower($name)] = array(); } if (!isset($offset)) { - $this->_headers[strtolower($name)][] = $header; + $this->headers[strtolower($name)][] = $header; } else { - $this->_headers[strtolower($name)][$offset] = $header; + $this->headers[strtolower($name)][$offset] = $header; } } /** Test if the headers can be sorted */ - private function _canSort() + private function canSort() { - return count($this->_order) > 0; + return count($this->order) > 0; } /** uksort() algorithm for Header ordering */ - private function _sortHeaders($a, $b) + private function sortHeaders($a, $b) { $lowerA = strtolower($a); $lowerB = strtolower($b); - $aPos = array_key_exists($lowerA, $this->_order) ? $this->_order[$lowerA] : -1; - $bPos = array_key_exists($lowerB, $this->_order) ? $this->_order[$lowerB] : -1; + $aPos = array_key_exists($lowerA, $this->order) ? $this->order[$lowerA] : -1; + $bPos = array_key_exists($lowerB, $this->order) ? $this->order[$lowerB] : -1; if (-1 === $aPos && -1 === $bPos) { // just be sure to be determinist here @@ -384,15 +379,15 @@ private function _sortHeaders($a, $b) } /** Test if the given Header is always displayed */ - private function _isDisplayed(Swift_Mime_Header $header) + private function isDisplayed(Swift_Mime_Header $header) { - return array_key_exists(strtolower($header->getFieldName()), $this->_required); + return array_key_exists(strtolower($header->getFieldName()), $this->required); } /** Notify all Headers of the new charset */ - private function _notifyHeadersOfCharset($charset) + private function notifyHeadersOfCharset($charset) { - foreach ($this->_headers as $headerGroup) { + foreach ($this->headers as $headerGroup) { foreach ($headerGroup as $header) { $header->setCharset($charset); } @@ -404,10 +399,10 @@ private function _notifyHeadersOfCharset($charset) */ public function __clone() { - $this->_factory = clone $this->_factory; - foreach ($this->_headers as $groupKey => $headerGroup) { + $this->factory = clone $this->factory; + foreach ($this->headers as $groupKey => $headerGroup) { foreach ($headerGroup as $key => $header) { - $this->_headers[$groupKey][$key] = clone $header; + $this->headers[$groupKey][$key] = clone $header; } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php index 72d40cee0..768de07f8 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php @@ -13,7 +13,7 @@ * * @author Chris Corbyn */ -class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime_Message +class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart { const PRIORITY_HIGHEST = 1; const PRIORITY_HIGH = 2; @@ -24,15 +24,15 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime /** * Create a new SimpleMessage with $headers, $encoder and $cache. * - * @param Swift_Mime_HeaderSet $headers - * @param Swift_Mime_ContentEncoder $encoder - * @param Swift_KeyCache $cache - * @param Swift_Mime_Grammar $grammar - * @param string $charset + * @param Swift_Mime_SimpleHeaderSet $headers + * @param Swift_Mime_ContentEncoder $encoder + * @param Swift_KeyCache $cache + * @param Swift_IdGenerator $idGenerator + * @param string $charset */ - public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar, $charset = null) + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) { - parent::__construct($headers, $encoder, $cache, $grammar, $charset); + parent::__construct($headers, $encoder, $cache, $idGenerator, $charset); $this->getHeaders()->defineOrdering(array( 'Return-Path', 'Received', @@ -53,7 +53,7 @@ public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEnc )); $this->getHeaders()->setAlwaysDisplayed(array('Date', 'Message-ID', 'From')); $this->getHeaders()->addTextHeader('MIME-Version', '1.0'); - $this->setDate(time()); + $this->setDate(new DateTimeImmutable()); $this->setId($this->getId()); $this->getHeaders()->addMailboxHeader('From'); } @@ -77,7 +77,7 @@ public function getNestingLevel() */ public function setSubject($subject) { - if (!$this->_setHeaderFieldModel('Subject', $subject)) { + if (!$this->setHeaderFieldModel('Subject', $subject)) { $this->getHeaders()->addTextHeader('Subject', $subject); } @@ -91,20 +91,20 @@ public function setSubject($subject) */ public function getSubject() { - return $this->_getHeaderFieldModel('Subject'); + return $this->getHeaderFieldModel('Subject'); } /** * Set the date at which this message was created. * - * @param int $date + * @param DateTimeInterface $dateTime * * @return $this */ - public function setDate($date) + public function setDate(DateTimeInterface $dateTime) { - if (!$this->_setHeaderFieldModel('Date', $date)) { - $this->getHeaders()->addDateHeader('Date', $date); + if (!$this->setHeaderFieldModel('Date', $dateTime)) { + $this->getHeaders()->addDateHeader('Date', $dateTime); } return $this; @@ -113,11 +113,11 @@ public function setDate($date) /** * Get the date at which this message was created. * - * @return int + * @return DateTimeInterface */ public function getDate() { - return $this->_getHeaderFieldModel('Date'); + return $this->getHeaderFieldModel('Date'); } /** @@ -129,7 +129,7 @@ public function getDate() */ public function setReturnPath($address) { - if (!$this->_setHeaderFieldModel('Return-Path', $address)) { + if (!$this->setHeaderFieldModel('Return-Path', $address)) { $this->getHeaders()->addPathHeader('Return-Path', $address); } @@ -143,7 +143,7 @@ public function setReturnPath($address) */ public function getReturnPath() { - return $this->_getHeaderFieldModel('Return-Path'); + return $this->getHeaderFieldModel('Return-Path'); } /** @@ -162,7 +162,7 @@ public function setSender($address, $name = null) $address = array($address => $name); } - if (!$this->_setHeaderFieldModel('Sender', (array) $address)) { + if (!$this->setHeaderFieldModel('Sender', (array) $address)) { $this->getHeaders()->addMailboxHeader('Sender', (array) $address); } @@ -176,7 +176,7 @@ public function setSender($address, $name = null) */ public function getSender() { - return $this->_getHeaderFieldModel('Sender'); + return $this->getHeaderFieldModel('Sender'); } /** @@ -216,7 +216,7 @@ public function setFrom($addresses, $name = null) $addresses = array($addresses => $name); } - if (!$this->_setHeaderFieldModel('From', (array) $addresses)) { + if (!$this->setHeaderFieldModel('From', (array) $addresses)) { $this->getHeaders()->addMailboxHeader('From', (array) $addresses); } @@ -230,7 +230,7 @@ public function setFrom($addresses, $name = null) */ public function getFrom() { - return $this->_getHeaderFieldModel('From'); + return $this->getHeaderFieldModel('From'); } /** @@ -270,7 +270,7 @@ public function setReplyTo($addresses, $name = null) $addresses = array($addresses => $name); } - if (!$this->_setHeaderFieldModel('Reply-To', (array) $addresses)) { + if (!$this->setHeaderFieldModel('Reply-To', (array) $addresses)) { $this->getHeaders()->addMailboxHeader('Reply-To', (array) $addresses); } @@ -284,7 +284,7 @@ public function setReplyTo($addresses, $name = null) */ public function getReplyTo() { - return $this->_getHeaderFieldModel('Reply-To'); + return $this->getHeaderFieldModel('Reply-To'); } /** @@ -325,7 +325,7 @@ public function setTo($addresses, $name = null) $addresses = array($addresses => $name); } - if (!$this->_setHeaderFieldModel('To', (array) $addresses)) { + if (!$this->setHeaderFieldModel('To', (array) $addresses)) { $this->getHeaders()->addMailboxHeader('To', (array) $addresses); } @@ -339,7 +339,7 @@ public function setTo($addresses, $name = null) */ public function getTo() { - return $this->_getHeaderFieldModel('To'); + return $this->getHeaderFieldModel('To'); } /** @@ -377,7 +377,7 @@ public function setCc($addresses, $name = null) $addresses = array($addresses => $name); } - if (!$this->_setHeaderFieldModel('Cc', (array) $addresses)) { + if (!$this->setHeaderFieldModel('Cc', (array) $addresses)) { $this->getHeaders()->addMailboxHeader('Cc', (array) $addresses); } @@ -391,7 +391,7 @@ public function setCc($addresses, $name = null) */ public function getCc() { - return $this->_getHeaderFieldModel('Cc'); + return $this->getHeaderFieldModel('Cc'); } /** @@ -429,7 +429,7 @@ public function setBcc($addresses, $name = null) $addresses = array($addresses => $name); } - if (!$this->_setHeaderFieldModel('Bcc', (array) $addresses)) { + if (!$this->setHeaderFieldModel('Bcc', (array) $addresses)) { $this->getHeaders()->addMailboxHeader('Bcc', (array) $addresses); } @@ -443,7 +443,7 @@ public function setBcc($addresses, $name = null) */ public function getBcc() { - return $this->_getHeaderFieldModel('Bcc'); + return $this->getHeaderFieldModel('Bcc'); } /** @@ -470,7 +470,7 @@ public function setPriority($priority) } elseif ($priority < min($pMapKeys)) { $priority = min($pMapKeys); } - if (!$this->_setHeaderFieldModel('X-Priority', + if (!$this->setHeaderFieldModel('X-Priority', sprintf('%d (%s)', $priority, $priorityMap[$priority]))) { $this->getHeaders()->addTextHeader('X-Priority', sprintf('%d (%s)', $priority, $priorityMap[$priority])); @@ -489,11 +489,11 @@ public function setPriority($priority) */ public function getPriority() { - list($priority) = sscanf($this->_getHeaderFieldModel('X-Priority'), + list($priority) = sscanf($this->getHeaderFieldModel('X-Priority'), '%[1-5]' ); - return isset($priority) ? $priority : 3; + return $priority ?? 3; } /** @@ -505,7 +505,7 @@ public function getPriority() */ public function setReadReceiptTo($addresses) { - if (!$this->_setHeaderFieldModel('Disposition-Notification-To', $addresses)) { + if (!$this->setHeaderFieldModel('Disposition-Notification-To', $addresses)) { $this->getHeaders() ->addMailboxHeader('Disposition-Notification-To', $addresses); } @@ -520,17 +520,17 @@ public function setReadReceiptTo($addresses) */ public function getReadReceiptTo() { - return $this->_getHeaderFieldModel('Disposition-Notification-To'); + return $this->getHeaderFieldModel('Disposition-Notification-To'); } /** - * Attach a {@link Swift_Mime_MimeEntity} such as an Attachment or MimePart. + * Attach a {@link Swift_Mime_SimpleMimeEntity} such as an Attachment or MimePart. * - * @param Swift_Mime_MimeEntity $entity + * @param Swift_Mime_SimpleMimeEntity $entity * * @return $this */ - public function attach(Swift_Mime_MimeEntity $entity) + public function attach(Swift_Mime_SimpleMimeEntity $entity) { $this->setChildren(array_merge($this->getChildren(), array($entity))); @@ -540,11 +540,11 @@ public function attach(Swift_Mime_MimeEntity $entity) /** * Remove an already attached entity. * - * @param Swift_Mime_MimeEntity $entity + * @param Swift_Mime_SimpleMimeEntity $entity * * @return $this */ - public function detach(Swift_Mime_MimeEntity $entity) + public function detach(Swift_Mime_SimpleMimeEntity $entity) { $newChildren = array(); foreach ($this->getChildren() as $child) { @@ -558,14 +558,14 @@ public function detach(Swift_Mime_MimeEntity $entity) } /** - * Attach a {@link Swift_Mime_MimeEntity} and return it's CID source. + * Attach a {@link Swift_Mime_SimpleMimeEntity} and return it's CID source. * This method should be used when embedding images or other data in a message. * - * @param Swift_Mime_MimeEntity $entity + * @param Swift_Mime_SimpleMimeEntity $entity * * @return string */ - public function embed(Swift_Mime_MimeEntity $entity) + public function embed(Swift_Mime_SimpleMimeEntity $entity) { $this->attach($entity); @@ -580,7 +580,7 @@ public function embed(Swift_Mime_MimeEntity $entity) public function toString() { if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') { - $this->setChildren(array_merge(array($this->_becomeMimePart()), $children)); + $this->setChildren(array_merge(array($this->becomeMimePart()), $children)); $string = parent::toString(); $this->setChildren($children); } else { @@ -610,7 +610,7 @@ public function __toString() public function toByteStream(Swift_InputByteStream $is) { if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') { - $this->setChildren(array_merge(array($this->_becomeMimePart()), $children)); + $this->setChildren(array_merge(array($this->becomeMimePart()), $children)); parent::toByteStream($is); $this->setChildren($children); } else { @@ -618,29 +618,29 @@ public function toByteStream(Swift_InputByteStream $is) } } - /** @see Swift_Mime_SimpleMimeEntity::_getIdField() */ - protected function _getIdField() + /** @see Swift_Mime_SimpleMimeEntity::getIdField() */ + protected function getIdField() { return 'Message-ID'; } /** Turn the body of this message into a child of itself if needed */ - protected function _becomeMimePart() + protected function becomeMimePart() { $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(), - $this->_getCache(), $this->_getGrammar(), $this->_userCharset + $this->getCache(), $this->getIdGenerator(), $this->userCharset ); - $part->setContentType($this->_userContentType); + $part->setContentType($this->userContentType); $part->setBody($this->getBody()); - $part->setFormat($this->_userFormat); - $part->setDelSp($this->_userDelSp); - $part->_setNestingLevel($this->_getTopNestingLevel()); + $part->setFormat($this->userFormat); + $part->setDelSp($this->userDelSp); + $part->setNestingLevel($this->getTopNestingLevel()); return $part; } /** Get the highest nesting level nested inside this message */ - private function _getTopNestingLevel() + private function getTopNestingLevel() { $highestLevel = $this->getNestingLevel(); foreach ($this->getChildren() as $child) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php index a13f1b23d..2d1a9b47d 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -13,79 +13,91 @@ * * @author Chris Corbyn */ -class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity +class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver { + /** Main message document; there can only be one of these */ + const LEVEL_TOP = 16; + + /** An entity which nests with the same precedence as an attachment */ + const LEVEL_MIXED = 256; + + /** An entity which nests with the same precedence as a mime part */ + const LEVEL_ALTERNATIVE = 4096; + + /** An entity which nests with the same precedence as embedded content */ + const LEVEL_RELATED = 65536; + /** A collection of Headers for this mime entity */ - private $_headers; + private $headers; /** The body as a string, or a stream */ - private $_body; + private $body; /** The encoder that encodes the body into a streamable format */ - private $_encoder; + private $encoder; - /** The grammar to use for id validation */ - private $_grammar; + /** Message ID generator */ + private $idGenerator; /** A mime boundary, if any is used */ - private $_boundary; + private $boundary; /** Mime types to be used based on the nesting level */ - private $_compositeRanges = array( + private $compositeRanges = array( 'multipart/mixed' => array(self::LEVEL_TOP, self::LEVEL_MIXED), 'multipart/alternative' => array(self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE), 'multipart/related' => array(self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED), ); /** A set of filter rules to define what level an entity should be nested at */ - private $_compoundLevelFilters = array(); + private $compoundLevelFilters = array(); /** The nesting level of this entity */ - private $_nestingLevel = self::LEVEL_ALTERNATIVE; + private $nestingLevel = self::LEVEL_ALTERNATIVE; /** A KeyCache instance used during encoding and streaming */ - private $_cache; + private $cache; /** Direct descendants of this entity */ - private $_immediateChildren = array(); + private $immediateChildren = array(); /** All descendants of this entity */ - private $_children = array(); + private $children = array(); /** The maximum line length of the body of this entity */ - private $_maxLineLength = 78; + private $maxLineLength = 78; /** The order in which alternative mime types should appear */ - private $_alternativePartOrder = array( + private $alternativePartOrder = array( 'text/plain' => 1, 'text/html' => 2, 'multipart/related' => 3, ); /** The CID of this entity */ - private $_id; + private $id; /** The key used for accessing the cache */ - private $_cacheKey; + private $cacheKey; - protected $_userContentType; + protected $userContentType; /** * Create a new SimpleMimeEntity with $headers, $encoder and $cache. * - * @param Swift_Mime_HeaderSet $headers - * @param Swift_Mime_ContentEncoder $encoder - * @param Swift_KeyCache $cache - * @param Swift_Mime_Grammar $grammar + * @param Swift_Mime_SimpleHeaderSet $headers + * @param Swift_Mime_ContentEncoder $encoder + * @param Swift_KeyCache $cache + * @param Swift_IdGenerator $idGenerator */ - public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar) + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator) { - $this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true)); - $this->_cache = $cache; - $this->_headers = $headers; - $this->_grammar = $grammar; + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values + $this->cache = $cache; + $this->headers = $headers; + $this->idGenerator = $idGenerator; $this->setEncoder($encoder); - $this->_headers->defineOrdering(array('Content-Type', 'Content-Transfer-Encoding')); + $this->headers->defineOrdering(array('Content-Type', 'Content-Transfer-Encoding')); // This array specifies that, when the entire MIME document contains // $compoundLevel, then for each child within $level, if its Content-Type @@ -100,7 +112,7 @@ public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEnc // ) // ) - $this->_compoundLevelFilters = array( + $this->compoundLevelFilters = array( (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => array( self::LEVEL_ALTERNATIVE => array( 'text/plain' => self::LEVEL_ALTERNATIVE, @@ -109,7 +121,7 @@ public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEnc ), ); - $this->_id = $this->getRandomId(); + $this->id = $this->idGenerator->generateId(); } /** @@ -119,19 +131,19 @@ public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEnc */ public function generateId() { - $this->setId($this->getRandomId()); + $this->setId($this->idGenerator->generateId()); - return $this->_id; + return $this->id; } /** - * Get the {@link Swift_Mime_HeaderSet} for this entity. + * Get the {@link Swift_Mime_SimpleHeaderSet} for this entity. * - * @return Swift_Mime_HeaderSet + * @return Swift_Mime_SimpleHeaderSet */ public function getHeaders() { - return $this->_headers; + return $this->headers; } /** @@ -143,7 +155,7 @@ public function getHeaders() */ public function getNestingLevel() { - return $this->_nestingLevel; + return $this->nestingLevel; } /** @@ -153,7 +165,7 @@ public function getNestingLevel() */ public function getContentType() { - return $this->_getHeaderFieldModel('Content-Type'); + return $this->getHeaderFieldModel('Content-Type'); } /** @@ -165,10 +177,10 @@ public function getContentType() */ public function setContentType($type) { - $this->_setContentTypeInHeaders($type); + $this->setContentTypeInHeaders($type); // Keep track of the value so that if the content-type changes automatically // due to added child entities, it can be restored if they are later removed - $this->_userContentType = $type; + $this->userContentType = $type; return $this; } @@ -182,9 +194,9 @@ public function setContentType($type) */ public function getId() { - $tmp = (array) $this->_getHeaderFieldModel($this->_getIdField()); + $tmp = (array) $this->getHeaderFieldModel($this->getIdField()); - return $this->_headers->has($this->_getIdField()) ? current($tmp) : $this->_id; + return $this->headers->has($this->getIdField()) ? current($tmp) : $this->id; } /** @@ -196,10 +208,10 @@ public function getId() */ public function setId($id) { - if (!$this->_setHeaderFieldModel($this->_getIdField(), $id)) { - $this->_headers->addIdHeader($this->_getIdField(), $id); + if (!$this->setHeaderFieldModel($this->getIdField(), $id)) { + $this->headers->addIdHeader($this->getIdField(), $id); } - $this->_id = $id; + $this->id = $id; return $this; } @@ -213,7 +225,7 @@ public function setId($id) */ public function getDescription() { - return $this->_getHeaderFieldModel('Content-Description'); + return $this->getHeaderFieldModel('Content-Description'); } /** @@ -227,8 +239,8 @@ public function getDescription() */ public function setDescription($description) { - if (!$this->_setHeaderFieldModel('Content-Description', $description)) { - $this->_headers->addTextHeader('Content-Description', $description); + if (!$this->setHeaderFieldModel('Content-Description', $description)) { + $this->headers->addTextHeader('Content-Description', $description); } return $this; @@ -241,7 +253,7 @@ public function setDescription($description) */ public function getMaxLineLength() { - return $this->_maxLineLength; + return $this->maxLineLength; } /** @@ -255,7 +267,7 @@ public function getMaxLineLength() */ public function setMaxLineLength($length) { - $this->_maxLineLength = $length; + $this->maxLineLength = $length; return $this; } @@ -263,37 +275,36 @@ public function setMaxLineLength($length) /** * Get all children added to this entity. * - * @return Swift_Mime_MimeEntity[] + * @return Swift_Mime_SimpleMimeEntity[] */ public function getChildren() { - return $this->_children; + return $this->children; } /** * Set all children of this entity. * - * @param Swift_Mime_MimeEntity[] $children - * @param int $compoundLevel For internal use only + * @param Swift_Mime_SimpleMimeEntity[] $children + * @param int $compoundLevel For internal use only * * @return $this */ public function setChildren(array $children, $compoundLevel = null) { // TODO: Try to refactor this logic - - $compoundLevel = isset($compoundLevel) ? $compoundLevel : $this->_getCompoundLevel($children); + $compoundLevel = $compoundLevel ?? $this->getCompoundLevel($children); $immediateChildren = array(); $grandchildren = array(); - $newContentType = $this->_userContentType; + $newContentType = $this->userContentType; foreach ($children as $child) { - $level = $this->_getNeededChildLevel($child, $compoundLevel); + $level = $this->getNeededChildLevel($child, $compoundLevel); if (empty($immediateChildren)) { //first iteration $immediateChildren = array($child); } else { - $nextLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel); + $nextLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); if ($nextLevel == $level) { $immediateChildren[] = $child; } elseif ($level < $nextLevel) { @@ -308,11 +319,11 @@ public function setChildren(array $children, $compoundLevel = null) } if ($immediateChildren) { - $lowestLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel); + $lowestLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); // Determine which composite media type is needed to accommodate the // immediate children - foreach ($this->_compositeRanges as $mediaType => $range) { + foreach ($this->compositeRanges as $mediaType => $range) { if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) { $newContentType = $mediaType; @@ -322,18 +333,18 @@ public function setChildren(array $children, $compoundLevel = null) // Put any grandchildren in a subpart if (!empty($grandchildren)) { - $subentity = $this->_createChild(); - $subentity->_setNestingLevel($lowestLevel); + $subentity = $this->createChild(); + $subentity->setNestingLevel($lowestLevel); $subentity->setChildren($grandchildren, $compoundLevel); array_unshift($immediateChildren, $subentity); } } - $this->_immediateChildren = $immediateChildren; - $this->_children = $children; - $this->_setContentTypeInHeaders($newContentType); - $this->_fixHeaders(); - $this->_sortChildren(); + $this->immediateChildren = $immediateChildren; + $this->children = $children; + $this->setContentTypeInHeaders($newContentType); + $this->fixHeaders(); + $this->sortChildren(); return $this; } @@ -345,7 +356,7 @@ public function setChildren(array $children, $compoundLevel = null) */ public function getBody() { - return $this->_body instanceof Swift_OutputByteStream ? $this->_readStream($this->_body) : $this->_body; + return $this->body instanceof Swift_OutputByteStream ? $this->readStream($this->body) : $this->body; } /** @@ -359,11 +370,11 @@ public function getBody() */ public function setBody($body, $contentType = null) { - if ($body !== $this->_body) { - $this->_clearCache(); + if ($body !== $this->body) { + $this->clearCache(); } - $this->_body = $body; + $this->body = $body; if (isset($contentType)) { $this->setContentType($contentType); } @@ -378,7 +389,7 @@ public function setBody($body, $contentType = null) */ public function getEncoder() { - return $this->_encoder; + return $this->encoder; } /** @@ -390,13 +401,13 @@ public function getEncoder() */ public function setEncoder(Swift_Mime_ContentEncoder $encoder) { - if ($encoder !== $this->_encoder) { - $this->_clearCache(); + if ($encoder !== $this->encoder) { + $this->clearCache(); } - $this->_encoder = $encoder; - $this->_setEncoding($encoder->getName()); - $this->_notifyEncoderChanged($encoder); + $this->encoder = $encoder; + $this->setEncoding($encoder->getName()); + $this->notifyEncoderChanged($encoder); return $this; } @@ -408,11 +419,11 @@ public function setEncoder(Swift_Mime_ContentEncoder $encoder) */ public function getBoundary() { - if (!isset($this->_boundary)) { - $this->_boundary = '_=_swift_v4_'.time().'_'.md5(getmypid().mt_rand().uniqid('', true)).'_=_'; + if (!isset($this->boundary)) { + $this->boundary = '_=_swift_'.time().'_'.bin2hex(random_bytes(16)).'_=_'; } - return $this->_boundary; + return $this->boundary; } /** @@ -426,8 +437,8 @@ public function getBoundary() */ public function setBoundary($boundary) { - $this->_assertValidBoundary($boundary); - $this->_boundary = $boundary; + $this->assertValidBoundary($boundary); + $this->boundary = $boundary; return $this; } @@ -440,7 +451,7 @@ public function setBoundary($boundary) */ public function charsetChanged($charset) { - $this->_notifyCharsetChanged($charset); + $this->notifyCharsetChanged($charset); } /** @@ -451,7 +462,7 @@ public function charsetChanged($charset) */ public function encoderChanged(Swift_Mime_ContentEncoder $encoder) { - $this->_notifyEncoderChanged($encoder); + $this->notifyEncoderChanged($encoder); } /** @@ -461,8 +472,8 @@ public function encoderChanged(Swift_Mime_ContentEncoder $encoder) */ public function toString() { - $string = $this->_headers->toString(); - $string .= $this->_bodyToString(); + $string = $this->headers->toString(); + $string .= $this->bodyToString(); return $string; } @@ -472,22 +483,22 @@ public function toString() * * @return string */ - protected function _bodyToString() + protected function bodyToString() { $string = ''; - if (isset($this->_body) && empty($this->_immediateChildren)) { - if ($this->_cache->hasKey($this->_cacheKey, 'body')) { - $body = $this->_cache->getString($this->_cacheKey, 'body'); + if (isset($this->body) && empty($this->immediateChildren)) { + if ($this->cache->hasKey($this->cacheKey, 'body')) { + $body = $this->cache->getString($this->cacheKey, 'body'); } else { - $body = "\r\n".$this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength()); - $this->_cache->setString($this->_cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE); + $body = "\r\n".$this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength()); + $this->cache->setString($this->cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE); } $string .= $body; } - if (!empty($this->_immediateChildren)) { - foreach ($this->_immediateChildren as $child) { + if (!empty($this->immediateChildren)) { + foreach ($this->immediateChildren as $child) { $string .= "\r\n\r\n--".$this->getBoundary()."\r\n"; $string .= $child->toString(); } @@ -516,10 +527,10 @@ public function __toString() */ public function toByteStream(Swift_InputByteStream $is) { - $is->write($this->_headers->toString()); + $is->write($this->headers->toString()); $is->commit(); - $this->_bodyToByteStream($is); + $this->bodyToByteStream($is); } /** @@ -527,26 +538,26 @@ public function toByteStream(Swift_InputByteStream $is) * * @param Swift_InputByteStream */ - protected function _bodyToByteStream(Swift_InputByteStream $is) + protected function bodyToByteStream(Swift_InputByteStream $is) { - if (empty($this->_immediateChildren)) { - if (isset($this->_body)) { - if ($this->_cache->hasKey($this->_cacheKey, 'body')) { - $this->_cache->exportToByteStream($this->_cacheKey, 'body', $is); + if (empty($this->immediateChildren)) { + if (isset($this->body)) { + if ($this->cache->hasKey($this->cacheKey, 'body')) { + $this->cache->exportToByteStream($this->cacheKey, 'body', $is); } else { - $cacheIs = $this->_cache->getInputByteStream($this->_cacheKey, 'body'); + $cacheIs = $this->cache->getInputByteStream($this->cacheKey, 'body'); if ($cacheIs) { $is->bind($cacheIs); } $is->write("\r\n"); - if ($this->_body instanceof Swift_OutputByteStream) { - $this->_body->setReadPointer(0); + if ($this->body instanceof Swift_OutputByteStream) { + $this->body->setReadPointer(0); - $this->_encoder->encodeByteStream($this->_body, $is, 0, $this->getMaxLineLength()); + $this->encoder->encodeByteStream($this->body, $is, 0, $this->getMaxLineLength()); } else { - $is->write($this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); + $is->write($this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); } if ($cacheIs) { @@ -556,8 +567,8 @@ protected function _bodyToByteStream(Swift_InputByteStream $is) } } - if (!empty($this->_immediateChildren)) { - foreach ($this->_immediateChildren as $child) { + if (!empty($this->immediateChildren)) { + foreach ($this->immediateChildren as $child) { $is->write("\r\n\r\n--".$this->getBoundary()."\r\n"); $child->toByteStream($is); } @@ -568,7 +579,7 @@ protected function _bodyToByteStream(Swift_InputByteStream $is) /** * Get the name of the header that provides the ID of this entity. */ - protected function _getIdField() + protected function getIdField() { return 'Content-ID'; } @@ -576,20 +587,20 @@ protected function _getIdField() /** * Get the model data (usually an array or a string) for $field. */ - protected function _getHeaderFieldModel($field) + protected function getHeaderFieldModel($field) { - if ($this->_headers->has($field)) { - return $this->_headers->get($field)->getFieldBodyModel(); + if ($this->headers->has($field)) { + return $this->headers->get($field)->getFieldBodyModel(); } } /** * Set the model data for $field. */ - protected function _setHeaderFieldModel($field, $model) + protected function setHeaderFieldModel($field, $model) { - if ($this->_headers->has($field)) { - $this->_headers->get($field)->setFieldBodyModel($model); + if ($this->headers->has($field)) { + $this->headers->get($field)->setFieldBodyModel($model); return true; } @@ -600,20 +611,20 @@ protected function _setHeaderFieldModel($field, $model) /** * Get the parameter value of $parameter on $field header. */ - protected function _getHeaderParameter($field, $parameter) + protected function getHeaderParameter($field, $parameter) { - if ($this->_headers->has($field)) { - return $this->_headers->get($field)->getParameter($parameter); + if ($this->headers->has($field)) { + return $this->headers->get($field)->getParameter($parameter); } } /** * Set the parameter value of $parameter on $field header. */ - protected function _setHeaderParameter($field, $parameter, $value) + protected function setHeaderParameter($field, $parameter, $value) { - if ($this->_headers->has($field)) { - $this->_headers->get($field)->setParameter($parameter, $value); + if ($this->headers->has($field)) { + $this->headers->get($field)->setParameter($parameter, $value); return true; } @@ -624,16 +635,16 @@ protected function _setHeaderParameter($field, $parameter, $value) /** * Re-evaluate what content type and encoding should be used on this entity. */ - protected function _fixHeaders() + protected function fixHeaders() { - if (count($this->_immediateChildren)) { - $this->_setHeaderParameter('Content-Type', 'boundary', + if (count($this->immediateChildren)) { + $this->setHeaderParameter('Content-Type', 'boundary', $this->getBoundary() ); - $this->_headers->remove('Content-Transfer-Encoding'); + $this->headers->remove('Content-Transfer-Encoding'); } else { - $this->_setHeaderParameter('Content-Type', 'boundary', null); - $this->_setEncoding($this->_encoder->getName()); + $this->setHeaderParameter('Content-Type', 'boundary', null); + $this->setEncoding($this->encoder->getName()); } } @@ -642,50 +653,30 @@ protected function _fixHeaders() * * @return Swift_KeyCache */ - protected function _getCache() + protected function getCache() { - return $this->_cache; + return $this->cache; } /** - * Get the grammar used for validation. + * Get the ID generator. * - * @return Swift_Mime_Grammar + * @return Swift_IdGenerator */ - protected function _getGrammar() + protected function getIdGenerator() { - return $this->_grammar; + return $this->idGenerator; } /** * Empty the KeyCache for this entity. */ - protected function _clearCache() - { - $this->_cache->clearKey($this->_cacheKey, 'body'); - } - - /** - * Returns a random Content-ID or Message-ID. - * - * @return string - */ - protected function getRandomId() + protected function clearCache() { - $idLeft = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)); - $idRight = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated'; - $id = $idLeft.'@'.$idRight; - - try { - $this->_assertValidId($id); - } catch (Swift_RfcComplianceException $e) { - $id = $idLeft.'@swift.generated'; - } - - return $id; + $this->cache->clearKey($this->cacheKey, 'body'); } - private function _readStream(Swift_OutputByteStream $os) + private function readStream(Swift_OutputByteStream $os) { $string = ''; while (false !== $bytes = $os->read(8192)) { @@ -697,33 +688,33 @@ private function _readStream(Swift_OutputByteStream $os) return $string; } - private function _setEncoding($encoding) + private function setEncoding($encoding) { - if (!$this->_setHeaderFieldModel('Content-Transfer-Encoding', $encoding)) { - $this->_headers->addTextHeader('Content-Transfer-Encoding', $encoding); + if (!$this->setHeaderFieldModel('Content-Transfer-Encoding', $encoding)) { + $this->headers->addTextHeader('Content-Transfer-Encoding', $encoding); } } - private function _assertValidBoundary($boundary) + private function assertValidBoundary($boundary) { if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) { throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); } } - private function _setContentTypeInHeaders($type) + private function setContentTypeInHeaders($type) { - if (!$this->_setHeaderFieldModel('Content-Type', $type)) { - $this->_headers->addParameterizedHeader('Content-Type', $type); + if (!$this->setHeaderFieldModel('Content-Type', $type)) { + $this->headers->addParameterizedHeader('Content-Type', $type); } } - private function _setNestingLevel($level) + private function setNestingLevel($level) { - $this->_nestingLevel = $level; + $this->nestingLevel = $level; } - private function _getCompoundLevel($children) + private function getCompoundLevel($children) { $level = 0; foreach ($children as $child) { @@ -733,10 +724,10 @@ private function _getCompoundLevel($children) return $level; } - private function _getNeededChildLevel($child, $compoundLevel) + private function getNeededChildLevel($child, $compoundLevel) { $filter = array(); - foreach ($this->_compoundLevelFilters as $bitmask => $rules) { + foreach ($this->compoundLevelFilters as $bitmask => $rules) { if (($compoundLevel & $bitmask) === $bitmask) { $filter = $rules + $filter; } @@ -752,31 +743,31 @@ private function _getNeededChildLevel($child, $compoundLevel) return $realLevel; } - private function _createChild() + private function createChild() { - return new self($this->_headers->newInstance(), $this->_encoder, $this->_cache, $this->_grammar); + return new self($this->headers->newInstance(), $this->encoder, $this->cache, $this->idGenerator); } - private function _notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) + private function notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) { - foreach ($this->_immediateChildren as $child) { + foreach ($this->immediateChildren as $child) { $child->encoderChanged($encoder); } } - private function _notifyCharsetChanged($charset) + private function notifyCharsetChanged($charset) { - $this->_encoder->charsetChanged($charset); - $this->_headers->charsetChanged($charset); - foreach ($this->_immediateChildren as $child) { + $this->encoder->charsetChanged($charset); + $this->headers->charsetChanged($charset); + foreach ($this->immediateChildren as $child) { $child->charsetChanged($charset); } } - private function _sortChildren() + private function sortChildren() { $shouldSort = false; - foreach ($this->_immediateChildren as $child) { + foreach ($this->immediateChildren as $child) { // NOTE: This include alternative parts moved into a related part if ($child->getNestingLevel() == self::LEVEL_ALTERNATIVE) { $shouldSort = true; @@ -788,9 +779,9 @@ private function _sortChildren() if ($shouldSort) { // Group the messages by order of preference $sorted = array(); - foreach ($this->_immediateChildren as $child) { + foreach ($this->immediateChildren as $child) { $type = $child->getContentType(); - $level = array_key_exists($type, $this->_alternativePartOrder) ? $this->_alternativePartOrder[$type] : max($this->_alternativePartOrder) + 1; + $level = array_key_exists($type, $this->alternativePartOrder) ? $this->alternativePartOrder[$type] : max($this->alternativePartOrder) + 1; if (empty($sorted[$level])) { $sorted[$level] = array(); @@ -801,7 +792,7 @@ private function _sortChildren() ksort($sorted); - $this->_immediateChildren = array_reduce($sorted, 'array_merge', array()); + $this->immediateChildren = array_reduce($sorted, 'array_merge', array()); } } @@ -810,22 +801,8 @@ private function _sortChildren() */ public function __destruct() { - if ($this->_cache instanceof Swift_KeyCache) { - $this->_cache->clearAll($this->_cacheKey); - } - } - - /** - * Throws an Exception if the id passed does not comply with RFC 2822. - * - * @param string $id - * - * @throws Swift_RfcComplianceException - */ - private function _assertValidId($id) - { - if (!preg_match('/^'.$this->_grammar->getDefinition('id-left').'@'.$this->_grammar->getDefinition('id-right').'$/D', $id)) { - throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>'); + if ($this->cache instanceof Swift_KeyCache) { + $this->cache->clearAll($this->cacheKey); } } @@ -834,11 +811,11 @@ private function _assertValidId($id) */ public function __clone() { - $this->_headers = clone $this->_headers; - $this->_encoder = clone $this->_encoder; - $this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true)); + $this->headers = clone $this->headers; + $this->encoder = clone $this->encoder; + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values $children = array(); - foreach ($this->_children as $pos => $child) { + foreach ($this->children as $pos => $child) { $children[$pos] = clone $child; } $this->setChildren($children); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php b/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php index 525b7ec8e..8fa0cbebc 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php @@ -42,18 +42,4 @@ public function __construct($body = null, $contentType = null, $charset = null) $this->setContentType($contentType); } } - - /** - * Create a new MimePart. - * - * @param string $body - * @param string $contentType - * @param string $charset - * - * @return self - */ - public static function newInstance($body = null, $contentType = null, $charset = null) - { - return new self($body, $contentType, $charset); - } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php index ddde335c5..a580dfbef 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php @@ -23,14 +23,4 @@ public function __construct() ->createDependenciesFor('transport.null') ); } - - /** - * Create a new NullTransport instance. - * - * @return self - */ - public static function newInstance() - { - return new self(); - } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php index a2ec2abcd..06b3109e6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php @@ -20,28 +20,28 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_ * * @var int */ - private $_threshold; + private $threshold; /** * The number of seconds to sleep for during a restart. * * @var int */ - private $_sleep; + private $sleep; /** * The internal counter. * * @var int */ - private $_counter = 0; + private $counter = 0; /** * The Sleeper instance for sleeping. * * @var Swift_Plugins_Sleeper */ - private $_sleeper; + private $sleeper; /** * Create a new AntiFloodPlugin with $threshold and $sleep time. @@ -54,7 +54,7 @@ public function __construct($threshold = 99, $sleep = 0, Swift_Plugins_Sleeper $ { $this->setThreshold($threshold); $this->setSleepTime($sleep); - $this->_sleeper = $sleeper; + $this->sleeper = $sleeper; } /** @@ -64,7 +64,7 @@ public function __construct($threshold = 99, $sleep = 0, Swift_Plugins_Sleeper $ */ public function setThreshold($threshold) { - $this->_threshold = $threshold; + $this->threshold = $threshold; } /** @@ -74,7 +74,7 @@ public function setThreshold($threshold) */ public function getThreshold() { - return $this->_threshold; + return $this->threshold; } /** @@ -84,7 +84,7 @@ public function getThreshold() */ public function setSleepTime($sleep) { - $this->_sleep = $sleep; + $this->sleep = $sleep; } /** @@ -94,7 +94,7 @@ public function setSleepTime($sleep) */ public function getSleepTime() { - return $this->_sleep; + return $this->sleep; } /** @@ -113,15 +113,15 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) */ public function sendPerformed(Swift_Events_SendEvent $evt) { - ++$this->_counter; - if ($this->_counter >= $this->_threshold) { + ++$this->counter; + if ($this->counter >= $this->threshold) { $transport = $evt->getTransport(); $transport->stop(); - if ($this->_sleep) { - $this->sleep($this->_sleep); + if ($this->sleep) { + $this->sleep($this->sleep); } $transport->start(); - $this->_counter = 0; + $this->counter = 0; } } @@ -132,8 +132,8 @@ public function sendPerformed(Swift_Events_SendEvent $evt) */ public function sleep($seconds) { - if (isset($this->_sleeper)) { - $this->_sleeper->sleep($seconds); + if (isset($this->sleeper)) { + $this->sleeper->sleep($seconds); } else { sleep($seconds); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php index f7e18d0eb..af060a99c 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php @@ -20,17 +20,17 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, * * @var int */ - private $_out = 0; + private $out = 0; /** * The incoming traffic counter. * * @var int */ - private $_in = 0; + private $in = 0; /** Bound byte streams */ - private $_mirrors = array(); + private $mirrors = array(); /** * Not used. @@ -58,7 +58,7 @@ public function sendPerformed(Swift_Events_SendEvent $evt) public function commandSent(Swift_Events_CommandEvent $evt) { $command = $evt->getCommand(); - $this->_out += strlen($command); + $this->out += strlen($command); } /** @@ -69,7 +69,7 @@ public function commandSent(Swift_Events_CommandEvent $evt) public function responseReceived(Swift_Events_ResponseEvent $evt) { $response = $evt->getResponse(); - $this->_in += strlen($response); + $this->in += strlen($response); } /** @@ -79,8 +79,8 @@ public function responseReceived(Swift_Events_ResponseEvent $evt) */ public function write($bytes) { - $this->_out += strlen($bytes); - foreach ($this->_mirrors as $stream) { + $this->out += strlen($bytes); + foreach ($this->mirrors as $stream) { $stream->write($bytes); } } @@ -102,7 +102,7 @@ public function commit() */ public function bind(Swift_InputByteStream $is) { - $this->_mirrors[] = $is; + $this->mirrors[] = $is; } /** @@ -116,9 +116,9 @@ public function bind(Swift_InputByteStream $is) */ public function unbind(Swift_InputByteStream $is) { - foreach ($this->_mirrors as $k => $stream) { + foreach ($this->mirrors as $k => $stream) { if ($is === $stream) { - unset($this->_mirrors[$k]); + unset($this->mirrors[$k]); } } } @@ -128,7 +128,7 @@ public function unbind(Swift_InputByteStream $is) */ public function flushBuffers() { - foreach ($this->_mirrors as $stream) { + foreach ($this->mirrors as $stream) { $stream->flushBuffers(); } } @@ -140,7 +140,7 @@ public function flushBuffers() */ public function getBytesOut() { - return $this->_out; + return $this->out; } /** @@ -150,7 +150,7 @@ public function getBytesOut() */ public function getBytesIn() { - return $this->_in; + return $this->in; } /** @@ -158,7 +158,7 @@ public function getBytesIn() */ public function reset() { - $this->_out = 0; - $this->_in = 0; + $this->out = 0; + $this->in = 0; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php index 0762b36d2..9d5feefb9 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php @@ -17,19 +17,19 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_Plugins_Decorator_Replacements { /** The replacement map */ - private $_replacements; + private $replacements; /** The body as it was before replacements */ - private $_originalBody; + private $originalBody; /** The original headers of the message, before replacements */ - private $_originalHeaders = array(); + private $originalHeaders = array(); /** Bodies of children before they are replaced */ - private $_originalChildBodies = array(); + private $originalChildBodies = array(); /** The Message that was last replaced */ - private $_lastMessage; + private $lastMessage; /** * Create a new DecoratorPlugin with $replacements. @@ -66,9 +66,9 @@ public function __construct($replacements) public function setReplacements($replacements) { if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) { - $this->_replacements = (array) $replacements; + $this->replacements = (array) $replacements; } else { - $this->_replacements = $replacements; + $this->replacements = $replacements; } } @@ -80,7 +80,7 @@ public function setReplacements($replacements) public function beforeSendPerformed(Swift_Events_SendEvent $evt) { $message = $evt->getMessage(); - $this->_restoreMessage($message); + $this->restoreMessage($message); $to = array_keys($message->getTo()); $address = array_shift($to); if ($replacements = $this->getReplacementsFor($address)) { @@ -91,7 +91,7 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) $search, $replace, $body ); if ($body != $bodyReplaced) { - $this->_originalBody = $body; + $this->originalBody = $body; $message->setBody($bodyReplaced); } @@ -111,12 +111,12 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) $count = 1; } } - } else { + } elseif (is_string($body)) { $bodyReplaced = str_replace($search, $replace, $body, $count); } if ($count) { - $this->_originalHeaders[$header->getFieldName()] = $body; + $this->originalHeaders[$header->getFieldName()] = $body; $header->setFieldBodyModel($bodyReplaced); } } @@ -131,11 +131,11 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) ); if ($body != $bodyReplaced) { $child->setBody($bodyReplaced); - $this->_originalChildBodies[$child->getId()] = $body; + $this->originalChildBodies[$child->getId()] = $body; } } } - $this->_lastMessage = $message; + $this->lastMessage = $message; } } @@ -155,11 +155,11 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) */ public function getReplacementsFor($address) { - if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) { - return $this->_replacements->getReplacementsFor($address); + if ($this->replacements instanceof Swift_Plugins_Decorator_Replacements) { + return $this->replacements->getReplacementsFor($address); } - return isset($this->_replacements[$address]) ? $this->_replacements[$address] : null; + return $this->replacements[$address] ?? null; } /** @@ -169,36 +169,36 @@ public function getReplacementsFor($address) */ public function sendPerformed(Swift_Events_SendEvent $evt) { - $this->_restoreMessage($evt->getMessage()); + $this->restoreMessage($evt->getMessage()); } /** Restore a changed message back to its original state */ - private function _restoreMessage(Swift_Mime_Message $message) + private function restoreMessage(Swift_Mime_SimpleMessage $message) { - if ($this->_lastMessage === $message) { - if (isset($this->_originalBody)) { - $message->setBody($this->_originalBody); - $this->_originalBody = null; + if ($this->lastMessage === $message) { + if (isset($this->originalBody)) { + $message->setBody($this->originalBody); + $this->originalBody = null; } - if (!empty($this->_originalHeaders)) { + if (!empty($this->originalHeaders)) { foreach ($message->getHeaders()->getAll() as $header) { - if (array_key_exists($header->getFieldName(), $this->_originalHeaders)) { - $header->setFieldBodyModel($this->_originalHeaders[$header->getFieldName()]); + if (array_key_exists($header->getFieldName(), $this->originalHeaders)) { + $header->setFieldBodyModel($this->originalHeaders[$header->getFieldName()]); } } - $this->_originalHeaders = array(); + $this->originalHeaders = array(); } - if (!empty($this->_originalChildBodies)) { + if (!empty($this->originalChildBodies)) { $children = (array) $message->getChildren(); foreach ($children as $child) { $id = $child->getId(); - if (array_key_exists($id, $this->_originalChildBodies)) { - $child->setBody($this->_originalChildBodies[$id]); + if (array_key_exists($id, $this->originalChildBodies)) { + $child->setBody($this->originalChildBodies[$id]); } } - $this->_originalChildBodies = array(); + $this->originalChildBodies = array(); } - $this->_lastMessage = null; + $this->lastMessage = null; } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php index 583444053..b975d36b8 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php @@ -20,7 +20,7 @@ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener * * @var string */ - private $_sender; + private $sender; /** * Create a new ImpersonatePlugin to impersonate $sender. @@ -29,7 +29,7 @@ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener */ public function __construct($sender) { - $this->_sender = $sender; + $this->sender = $sender; } /** @@ -46,7 +46,7 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) $headers->addPathHeader('X-Swift-Return-Path', $message->getReturnPath()); // replace them with the one to send to - $message->setReturnPath($this->_sender); + $message->setReturnPath($this->sender); } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php index 64db43846..7ddf1fd16 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php @@ -11,12 +11,12 @@ /** * Does real time logging of Transport level information. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_Events_TransportChangeListener, Swift_Events_TransportExceptionListener, Swift_Plugins_Logger { /** The logger which is delegated to */ - private $_logger; + private $logger; /** * Create a new LoggerPlugin using $logger. @@ -25,7 +25,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ */ public function __construct(Swift_Plugins_Logger $logger) { - $this->_logger = $logger; + $this->logger = $logger; } /** @@ -35,7 +35,7 @@ public function __construct(Swift_Plugins_Logger $logger) */ public function add($entry) { - $this->_logger->add($entry); + $this->logger->add($entry); } /** @@ -43,7 +43,7 @@ public function add($entry) */ public function clear() { - $this->_logger->clear(); + $this->logger->clear(); } /** @@ -53,7 +53,7 @@ public function clear() */ public function dump() { - return $this->_logger->dump(); + return $this->logger->dump(); } /** @@ -64,7 +64,7 @@ public function dump() public function commandSent(Swift_Events_CommandEvent $evt) { $command = $evt->getCommand(); - $this->_logger->add(sprintf('>> %s', $command)); + $this->logger->add(sprintf('>> %s', $command)); } /** @@ -75,7 +75,7 @@ public function commandSent(Swift_Events_CommandEvent $evt) public function responseReceived(Swift_Events_ResponseEvent $evt) { $response = $evt->getResponse(); - $this->_logger->add(sprintf('<< %s', $response)); + $this->logger->add(sprintf('<< %s', $response)); } /** @@ -86,7 +86,7 @@ public function responseReceived(Swift_Events_ResponseEvent $evt) public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) { $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf('++ Starting %s', $transportName)); + $this->logger->add(sprintf('++ Starting %s', $transportName)); } /** @@ -97,7 +97,7 @@ public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) public function transportStarted(Swift_Events_TransportChangeEvent $evt) { $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf('++ %s started', $transportName)); + $this->logger->add(sprintf('++ %s started', $transportName)); } /** @@ -108,7 +108,7 @@ public function transportStarted(Swift_Events_TransportChangeEvent $evt) public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) { $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf('++ Stopping %s', $transportName)); + $this->logger->add(sprintf('++ Stopping %s', $transportName)); } /** @@ -119,7 +119,7 @@ public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) public function transportStopped(Swift_Events_TransportChangeEvent $evt) { $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf('++ %s stopped', $transportName)); + $this->logger->add(sprintf('++ %s stopped', $transportName)); } /** @@ -132,10 +132,10 @@ public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) $e = $evt->getException(); $message = $e->getMessage(); $code = $e->getCode(); - $this->_logger->add(sprintf('!! %s (code: %s)', $message, $code)); + $this->logger->add(sprintf('!! %s (code: %s)', $message, $code)); $message .= PHP_EOL; $message .= 'Log data:'.PHP_EOL; - $message .= $this->_logger->dump(); + $message .= $this->logger->dump(); $evt->cancelBubble(); throw new Swift_TransportException($message, $code, $e->getPrevious()); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php index 865bb0aa3..186b6b41b 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php @@ -20,14 +20,14 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger * * @var array */ - private $_log = array(); + private $log = array(); /** * Max size of the log. * * @var int */ - private $_size = 0; + private $size = 0; /** * Create a new ArrayLogger with a maximum of $size entries. @@ -36,7 +36,7 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger */ public function __construct($size = 50) { - $this->_size = $size; + $this->size = $size; } /** @@ -46,9 +46,9 @@ public function __construct($size = 50) */ public function add($entry) { - $this->_log[] = $entry; - while (count($this->_log) > $this->_size) { - array_shift($this->_log); + $this->log[] = $entry; + while (count($this->log) > $this->size) { + array_shift($this->log); } } @@ -57,7 +57,7 @@ public function add($entry) */ public function clear() { - $this->_log = array(); + $this->log = array(); } /** @@ -67,6 +67,6 @@ public function clear() */ public function dump() { - return implode(PHP_EOL, $this->_log); + return implode(PHP_EOL, $this->log); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php index 3583297ab..40a53d2bb 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php @@ -16,7 +16,7 @@ class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger { /** Whether or not HTML should be output */ - private $_isHtml; + private $isHtml; /** * Create a new EchoLogger. @@ -25,7 +25,7 @@ class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger */ public function __construct($isHtml = true) { - $this->_isHtml = $isHtml; + $this->isHtml = $isHtml; } /** @@ -35,7 +35,7 @@ public function __construct($isHtml = true) */ public function add($entry) { - if ($this->_isHtml) { + if ($this->isHtml) { printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '
', PHP_EOL); } else { printf('%s%s', $entry, PHP_EOL); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php index 31461526c..c19403aec 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php @@ -11,36 +11,36 @@ /** * Makes sure a connection to a POP3 host has been established prior to connecting to SMTP. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeListener, Swift_Plugins_Pop_Pop3Connection { /** A delegate connection to use (mostly a test hook) */ - private $_connection; + private $connection; /** Hostname of the POP3 server */ - private $_host; + private $host; /** Port number to connect on */ - private $_port; + private $port; /** Encryption type to use (if any) */ - private $_crypto; + private $crypto; /** Username to use (if any) */ - private $_username; + private $username; /** Password to use (if any) */ - private $_password; + private $password; /** Established connection via TCP socket */ - private $_socket; + private $socket; /** Connect timeout in seconds */ - private $_timeout = 10; + private $timeout = 10; /** SMTP Transport to bind to */ - private $_transport; + private $transport; /** * Create a new PopBeforeSmtpPlugin for $host and $port. @@ -51,23 +51,9 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL */ public function __construct($host, $port = 110, $crypto = null) { - $this->_host = $host; - $this->_port = $port; - $this->_crypto = $crypto; - } - - /** - * Create a new PopBeforeSmtpPlugin for $host and $port. - * - * @param string $host - * @param int $port - * @param string $crypto as "tls" or "ssl" - * - * @return self - */ - public static function newInstance($host, $port = 110, $crypto = null) - { - return new self($host, $port, $crypto); + $this->host = $host; + $this->port = $port; + $this->crypto = $crypto; } /** @@ -79,7 +65,7 @@ public static function newInstance($host, $port = 110, $crypto = null) */ public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) { - $this->_connection = $connection; + $this->connection = $connection; return $this; } @@ -91,7 +77,7 @@ public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) */ public function bindSmtp(Swift_Transport $smtp) { - $this->_transport = $smtp; + $this->transport = $smtp; } /** @@ -103,7 +89,7 @@ public function bindSmtp(Swift_Transport $smtp) */ public function setTimeout($timeout) { - $this->_timeout = (int) $timeout; + $this->timeout = (int) $timeout; return $this; } @@ -117,7 +103,7 @@ public function setTimeout($timeout) */ public function setUsername($username) { - $this->_username = $username; + $this->username = $username; return $this; } @@ -131,7 +117,7 @@ public function setUsername($username) */ public function setPassword($password) { - $this->_password = $password; + $this->password = $password; return $this; } @@ -143,29 +129,29 @@ public function setPassword($password) */ public function connect() { - if (isset($this->_connection)) { - $this->_connection->connect(); + if (isset($this->connection)) { + $this->connection->connect(); } else { - if (!isset($this->_socket)) { + if (!isset($this->socket)) { if (!$socket = fsockopen( - $this->_getHostString(), $this->_port, $errno, $errstr, $this->_timeout)) { + $this->getHostString(), $this->port, $errno, $errstr, $this->timeout)) { throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('Failed to connect to POP3 host [%s]: %s', $this->_host, $errstr) + sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr) ); } - $this->_socket = $socket; + $this->socket = $socket; - if (false === $greeting = fgets($this->_socket)) { + if (false === $greeting = fgets($this->socket)) { throw new Swift_Plugins_Pop_Pop3Exception( sprintf('Failed to connect to POP3 host [%s]', trim($greeting)) ); } - $this->_assertOk($greeting); + $this->assertOk($greeting); - if ($this->_username) { - $this->_command(sprintf("USER %s\r\n", $this->_username)); - $this->_command(sprintf("PASS %s\r\n", $this->_password)); + if ($this->username) { + $this->command(sprintf("USER %s\r\n", $this->username)); + $this->command(sprintf("PASS %s\r\n", $this->password)); } } } @@ -176,16 +162,16 @@ public function connect() */ public function disconnect() { - if (isset($this->_connection)) { - $this->_connection->disconnect(); + if (isset($this->connection)) { + $this->connection->disconnect(); } else { - $this->_command("QUIT\r\n"); - if (!fclose($this->_socket)) { + $this->command("QUIT\r\n"); + if (!fclose($this->socket)) { throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('POP3 host [%s] connection could not be stopped', $this->_host) + sprintf('POP3 host [%s] connection could not be stopped', $this->host) ); } - $this->_socket = null; + $this->socket = null; } } @@ -196,8 +182,8 @@ public function disconnect() */ public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) { - if (isset($this->_transport)) { - if ($this->_transport !== $evt->getTransport()) { + if (isset($this->transport)) { + if ($this->transport !== $evt->getTransport()) { return; } } @@ -227,26 +213,26 @@ public function transportStopped(Swift_Events_TransportChangeEvent $evt) { } - private function _command($command) + private function command($command) { - if (!fwrite($this->_socket, $command)) { + if (!fwrite($this->socket, $command)) { throw new Swift_Plugins_Pop_Pop3Exception( sprintf('Failed to write command [%s] to POP3 host', trim($command)) ); } - if (false === $response = fgets($this->_socket)) { + if (false === $response = fgets($this->socket)) { throw new Swift_Plugins_Pop_Pop3Exception( sprintf('Failed to read from POP3 host after command [%s]', trim($command)) ); } - $this->_assertOk($response); + $this->assertOk($response); return $response; } - private function _assertOk($response) + private function assertOk($response) { if (substr($response, 0, 3) != '+OK') { throw new Swift_Plugins_Pop_Pop3Exception( @@ -255,10 +241,10 @@ private function _assertOk($response) } } - private function _getHostString() + private function getHostString() { - $host = $this->_host; - switch (strtolower($this->_crypto)) { + $host = $this->host; + switch (strtolower($this->crypto)) { case 'ssl': $host = 'ssl://'.$host; break; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php index c3a1f8685..8d797dd11 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php @@ -11,7 +11,7 @@ /** * Redirects all email to a single recipient. * - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener { @@ -20,14 +20,14 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener * * @var mixed */ - private $_recipient; + private $recipient; /** * List of regular expression for recipient whitelisting. * * @var array */ - private $_whitelist = array(); + private $whitelist = array(); /** * Create a new RedirectingPlugin. @@ -37,8 +37,8 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener */ public function __construct($recipient, array $whitelist = array()) { - $this->_recipient = $recipient; - $this->_whitelist = $whitelist; + $this->recipient = $recipient; + $this->whitelist = $whitelist; } /** @@ -48,7 +48,7 @@ public function __construct($recipient, array $whitelist = array()) */ public function setRecipient($recipient) { - $this->_recipient = $recipient; + $this->recipient = $recipient; } /** @@ -58,7 +58,7 @@ public function setRecipient($recipient) */ public function getRecipient() { - return $this->_recipient; + return $this->recipient; } /** @@ -68,7 +68,7 @@ public function getRecipient() */ public function setWhitelist(array $whitelist) { - $this->_whitelist = $whitelist; + $this->whitelist = $whitelist; } /** @@ -78,7 +78,7 @@ public function setWhitelist(array $whitelist) */ public function getWhitelist() { - return $this->_whitelist; + return $this->whitelist; } /** @@ -106,9 +106,9 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) } // Filter remaining headers against whitelist - $this->_filterHeaderSet($headers, 'To'); - $this->_filterHeaderSet($headers, 'Cc'); - $this->_filterHeaderSet($headers, 'Bcc'); + $this->filterHeaderSet($headers, 'To'); + $this->filterHeaderSet($headers, 'Cc'); + $this->filterHeaderSet($headers, 'Bcc'); // Add each hard coded recipient $to = $message->getTo(); @@ -116,7 +116,7 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) $to = array(); } - foreach ((array) $this->_recipient as $recipient) { + foreach ((array) $this->recipient as $recipient) { if (!array_key_exists($recipient, $to)) { $message->addTo($recipient); } @@ -126,13 +126,13 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) /** * Filter header set against a whitelist of regular expressions. * - * @param Swift_Mime_HeaderSet $headerSet - * @param string $type + * @param Swift_Mime_SimpleHeaderSet $headerSet + * @param string $type */ - private function _filterHeaderSet(Swift_Mime_HeaderSet $headerSet, $type) + private function filterHeaderSet(Swift_Mime_SimpleHeaderSet $headerSet, $type) { foreach ($headerSet->getAll($type) as $headers) { - $headers->setNameAddresses($this->_filterNameAddresses($headers->getNameAddresses())); + $headers->setNameAddresses($this->filterNameAddresses($headers->getNameAddresses())); } } @@ -143,12 +143,12 @@ private function _filterHeaderSet(Swift_Mime_HeaderSet $headerSet, $type) * * @return array */ - private function _filterNameAddresses(array $recipients) + private function filterNameAddresses(array $recipients) { $filtered = array(); foreach ($recipients as $address => $name) { - if ($this->_isWhitelisted($address)) { + if ($this->isWhitelisted($address)) { $filtered[$address] = $name; } } @@ -163,13 +163,13 @@ private function _filterNameAddresses(array $recipients) * * @return bool */ - protected function _isWhitelisted($recipient) + protected function isWhitelisted($recipient) { - if (in_array($recipient, (array) $this->_recipient)) { + if (in_array($recipient, (array) $this->recipient)) { return true; } - foreach ($this->_whitelist as $pattern) { + foreach ($this->whitelist as $pattern) { if (preg_match($pattern, $recipient)) { return true; } @@ -185,10 +185,10 @@ protected function _isWhitelisted($recipient) */ public function sendPerformed(Swift_Events_SendEvent $evt) { - $this->_restoreMessage($evt->getMessage()); + $this->restoreMessage($evt->getMessage()); } - private function _restoreMessage(Swift_Mime_Message $message) + private function restoreMessage(Swift_Mime_SimpleMessage $message) { // restore original headers $headers = $message->getHeaders(); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php index 0f21b7d60..3a2b6657c 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php @@ -24,9 +24,9 @@ interface Swift_Plugins_Reporter /** * Notifies this ReportNotifier that $address failed or succeeded. * - * @param Swift_Mime_Message $message - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} + * @param Swift_Mime_SimpleMessage $message + * @param string $address + * @param int $result from {@link RESULT_PASS, RESULT_FAIL} */ - public function notify(Swift_Mime_Message $message, $address, $result); + public function notify(Swift_Mime_SimpleMessage $message, $address, $result); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php index a37901ff0..5ffca24c6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php @@ -20,7 +20,7 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener * * @var Swift_Plugins_Reporter */ - private $_reporter; + private $reporter; /** * Create a new ReporterPlugin using $reporter. @@ -29,7 +29,7 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener */ public function __construct(Swift_Plugins_Reporter $reporter) { - $this->_reporter = $reporter; + $this->reporter = $reporter; } /** @@ -49,13 +49,13 @@ public function sendPerformed(Swift_Events_SendEvent $evt) $message = $evt->getMessage(); $failures = array_flip($evt->getFailedRecipients()); foreach ((array) $message->getTo() as $address => $null) { - $this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS); + $this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); } foreach ((array) $message->getCc() as $address => $null) { - $this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS); + $this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); } foreach ((array) $message->getBcc() as $address => $null) { - $this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS); + $this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php index cad9d168e..67c117ac7 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php @@ -20,22 +20,22 @@ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter * * @var array */ - private $_failures = array(); + private $failures = array(); - private $_failures_cache = array(); + private $failures_cache = array(); /** * Notifies this ReportNotifier that $address failed or succeeded. * - * @param Swift_Mime_Message $message - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} + * @param Swift_Mime_SimpleMessage $message + * @param string $address + * @param int $result from {@link RESULT_PASS, RESULT_FAIL} */ - public function notify(Swift_Mime_Message $message, $address, $result) + public function notify(Swift_Mime_SimpleMessage $message, $address, $result) { - if (self::RESULT_FAIL == $result && !isset($this->_failures_cache[$address])) { - $this->_failures[] = $address; - $this->_failures_cache[$address] = true; + if (self::RESULT_FAIL == $result && !isset($this->failures_cache[$address])) { + $this->failures[] = $address; + $this->failures_cache[$address] = true; } } @@ -46,7 +46,7 @@ public function notify(Swift_Mime_Message $message, $address, $result) */ public function getFailedRecipients() { - return $this->_failures; + return $this->failures; } /** @@ -54,6 +54,6 @@ public function getFailedRecipients() */ public function clear() { - $this->_failures = $this->_failures_cache = array(); + $this->failures = $this->failures_cache = array(); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php index c62593557..525eef570 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php @@ -18,11 +18,11 @@ class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter /** * Notifies this ReportNotifier that $address failed or succeeded. * - * @param Swift_Mime_Message $message - * @param string $address - * @param int $result from {@see RESULT_PASS, RESULT_FAIL} + * @param Swift_Mime_SimpleMessage $message + * @param string $address + * @param int $result from {@see RESULT_PASS, RESULT_FAIL} */ - public function notify(Swift_Mime_Message $message, $address, $result) + public function notify(Swift_Mime_SimpleMessage $message, $address, $result) { if (self::RESULT_PASS == $result) { echo '
'.PHP_EOL; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php index 2f4b9a75e..77c2e8db6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php @@ -29,28 +29,28 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin * * @var Swift_Plugins_Sleeper */ - private $_sleeper; + private $sleeper; /** * The Timer instance which provides the timestamp. * * @var Swift_Plugins_Timer */ - private $_timer; + private $timer; /** * The time at which the first email was sent. * * @var int */ - private $_start; + private $start; /** * The rate at which messages should be sent. * * @var int */ - private $_rate; + private $rate; /** * The mode for throttling. @@ -59,14 +59,14 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin * * @var int */ - private $_mode; + private $mode; /** * An internal counter of the number of messages sent. * * @var int */ - private $_messages = 0; + private $messages = 0; /** * Create a new ThrottlerPlugin. @@ -78,10 +78,10 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin */ public function __construct($rate, $mode = self::BYTES_PER_MINUTE, Swift_Plugins_Sleeper $sleeper = null, Swift_Plugins_Timer $timer = null) { - $this->_rate = $rate; - $this->_mode = $mode; - $this->_sleeper = $sleeper; - $this->_timer = $timer; + $this->rate = $rate; + $this->mode = $mode; + $this->sleeper = $sleeper; + $this->timer = $timer; } /** @@ -92,20 +92,20 @@ public function __construct($rate, $mode = self::BYTES_PER_MINUTE, Swift_Plugins public function beforeSendPerformed(Swift_Events_SendEvent $evt) { $time = $this->getTimestamp(); - if (!isset($this->_start)) { - $this->_start = $time; + if (!isset($this->start)) { + $this->start = $time; } - $duration = $time - $this->_start; + $duration = $time - $this->start; - switch ($this->_mode) { + switch ($this->mode) { case self::BYTES_PER_MINUTE: - $sleep = $this->_throttleBytesPerMinute($duration); + $sleep = $this->throttleBytesPerMinute($duration); break; case self::MESSAGES_PER_SECOND: - $sleep = $this->_throttleMessagesPerSecond($duration); + $sleep = $this->throttleMessagesPerSecond($duration); break; case self::MESSAGES_PER_MINUTE: - $sleep = $this->_throttleMessagesPerMinute($duration); + $sleep = $this->throttleMessagesPerMinute($duration); break; default: $sleep = 0; @@ -125,7 +125,7 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) public function sendPerformed(Swift_Events_SendEvent $evt) { parent::sendPerformed($evt); - ++$this->_messages; + ++$this->messages; } /** @@ -135,8 +135,8 @@ public function sendPerformed(Swift_Events_SendEvent $evt) */ public function sleep($seconds) { - if (isset($this->_sleeper)) { - $this->_sleeper->sleep($seconds); + if (isset($this->sleeper)) { + $this->sleeper->sleep($seconds); } else { sleep($seconds); } @@ -149,8 +149,8 @@ public function sleep($seconds) */ public function getTimestamp() { - if (isset($this->_timer)) { - return $this->_timer->getTimestamp(); + if (isset($this->timer)) { + return $this->timer->getTimestamp(); } return time(); @@ -163,9 +163,9 @@ public function getTimestamp() * * @return int */ - private function _throttleBytesPerMinute($timePassed) + private function throttleBytesPerMinute($timePassed) { - $expectedDuration = $this->getBytesOut() / ($this->_rate / 60); + $expectedDuration = $this->getBytesOut() / ($this->rate / 60); return (int) ceil($expectedDuration - $timePassed); } @@ -177,9 +177,9 @@ private function _throttleBytesPerMinute($timePassed) * * @return int */ - private function _throttleMessagesPerSecond($timePassed) + private function throttleMessagesPerSecond($timePassed) { - $expectedDuration = $this->_messages / ($this->_rate); + $expectedDuration = $this->messages / $this->rate; return (int) ceil($expectedDuration - $timePassed); } @@ -191,9 +191,9 @@ private function _throttleMessagesPerSecond($timePassed) * * @return int */ - private function _throttleMessagesPerMinute($timePassed) + private function throttleMessagesPerMinute($timePassed) { - $expectedDuration = $this->_messages / ($this->_rate / 60); + $expectedDuration = $this->messages / ($this->rate / 60); return (int) ceil($expectedDuration - $timePassed); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php b/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php index 83cbddcd2..79eafde9a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php @@ -16,7 +16,7 @@ class Swift_Preferences { /** Singleton instance */ - private static $_instance = null; + private static $instance = null; /** Constructor not to be used */ private function __construct() @@ -30,11 +30,11 @@ private function __construct() */ public static function getInstance() { - if (!isset(self::$_instance)) { - self::$_instance = new self(); + if (!isset(self::$instance)) { + self::$instance = new self(); } - return self::$_instance; + return self::$instance; } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php index 47ae7a591..c129281b3 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php @@ -30,16 +30,4 @@ public function __construct($command = '/usr/sbin/sendmail -bs') $this->setCommand($command); } - - /** - * Create a new SendmailTransport instance. - * - * @param string $command - * - * @return self - */ - public static function newInstance($command = '/usr/sbin/sendmail -bs') - { - return new self($command); - } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php b/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php deleted file mode 100644 index 2e7a8726d..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * @deprecated - */ -class Swift_SignedMessage extends Swift_Message -{ -} diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php index 454e84b47..a88daa198 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php @@ -11,7 +11,7 @@ /** * DKIM Signer used to apply DKIM Signature to a message. * - * @author Xavier De Cock + * @author Xavier De Cock */ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner { @@ -20,21 +20,23 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner * * @var string */ - protected $_privateKey; + protected $privateKey; /** * DomainName. * * @var string */ - protected $_domainName; + protected $domainName; /** * Selector. * * @var string */ - protected $_selector; + protected $selector; + + private $passphrase = ''; /** * Hash algorithm used. @@ -43,63 +45,63 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner * * @var string */ - protected $_hashAlgorithm = 'rsa-sha256'; + protected $hashAlgorithm = 'rsa-sha256'; /** * Body canon method. * * @var string */ - protected $_bodyCanon = 'simple'; + protected $bodyCanon = 'simple'; /** * Header canon method. * * @var string */ - protected $_headerCanon = 'simple'; + protected $headerCanon = 'simple'; /** * Headers not being signed. * * @var array */ - protected $_ignoredHeaders = array('return-path' => true); + protected $ignoredHeaders = array('return-path' => true); /** * Signer identity. * * @var string */ - protected $_signerIdentity; + protected $signerIdentity; /** * BodyLength. * * @var int */ - protected $_bodyLen = 0; + protected $bodyLen = 0; /** * Maximum signedLen. * * @var int */ - protected $_maxLen = PHP_INT_MAX; + protected $maxLen = PHP_INT_MAX; /** * Embbed bodyLen in signature. * * @var bool */ - protected $_showLen = false; + protected $showLen = false; /** * When the signature has been applied (true means time()), false means not embedded. * * @var mixed */ - protected $_signatureTimestamp = true; + protected $signatureTimestamp = true; /** * When will the signature expires false means not embedded, if sigTimestamp is auto @@ -107,14 +109,14 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner * * @var int */ - protected $_signatureExpiration = false; + protected $signatureExpiration = false; /** * Must we embed signed headers? * * @var bool */ - protected $_debugHeaders = false; + protected $debugHeaders = false; // work variables /** @@ -122,46 +124,46 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner * * @var array */ - protected $_signedHeaders = array(); + protected $signedHeaders = array(); /** * If debugHeaders is set store debugData here. * * @var string */ - private $_debugHeadersData = ''; + private $debugHeadersData = ''; /** * Stores the bodyHash. * * @var string */ - private $_bodyHash = ''; + private $bodyHash = ''; /** * Stores the signature header. * * @var Swift_Mime_Headers_ParameterizedHeader */ - protected $_dkimHeader; + protected $dkimHeader; - private $_bodyHashHandler; + private $bodyHashHandler; - private $_headerHash; + private $headerHash; - private $_headerCanonData = ''; + private $headerCanonData = ''; - private $_bodyCanonEmptyCounter = 0; + private $bodyCanonEmptyCounter = 0; - private $_bodyCanonIgnoreStart = 2; + private $bodyCanonIgnoreStart = 2; - private $_bodyCanonSpace = false; + private $bodyCanonSpace = false; - private $_bodyCanonLastChar = null; + private $bodyCanonLastChar = null; - private $_bodyCanonLine = ''; + private $bodyCanonLine = ''; - private $_bound = array(); + private $bound = array(); /** * Constructor. @@ -169,32 +171,15 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner * @param string $privateKey * @param string $domainName * @param string $selector + * @param string $passphrase */ - public function __construct($privateKey, $domainName, $selector) - { - $this->_privateKey = $privateKey; - $this->_domainName = $domainName; - $this->_signerIdentity = '@'.$domainName; - $this->_selector = $selector; - - // keep fallback hash algorithm sha1 if php version is lower than 5.4.8 - if (PHP_VERSION_ID < 50408) { - $this->_hashAlgorithm = 'rsa-sha1'; - } - } - - /** - * Instanciate DKIMSigner. - * - * @param string $privateKey - * @param string $domainName - * @param string $selector - * - * @return self - */ - public static function newInstance($privateKey, $domainName, $selector) + public function __construct($privateKey, $domainName, $selector, $passphrase = '') { - return new static($privateKey, $domainName, $selector); + $this->privateKey = $privateKey; + $this->domainName = $domainName; + $this->signerIdentity = '@'.$domainName; + $this->selector = $selector; + $this->passphrase = $passphrase; } /** @@ -204,14 +189,14 @@ public static function newInstance($privateKey, $domainName, $selector) */ public function reset() { - $this->_headerHash = null; - $this->_signedHeaders = array(); - $this->_bodyHash = null; - $this->_bodyHashHandler = null; - $this->_bodyCanonIgnoreStart = 2; - $this->_bodyCanonEmptyCounter = 0; - $this->_bodyCanonLastChar = null; - $this->_bodyCanonSpace = false; + $this->headerHash = null; + $this->signedHeaders = array(); + $this->bodyHash = null; + $this->bodyHashHandler = null; + $this->bodyCanonIgnoreStart = 2; + $this->bodyCanonEmptyCounter = 0; + $this->bodyCanonLastChar = null; + $this->bodyCanonSpace = false; } /** @@ -226,15 +211,15 @@ public function reset() * * @param string $bytes * - * @throws Swift_IoException - * * @return int + * + * @throws Swift_IoException */ // TODO fix return public function write($bytes) { - $this->_canonicalizeBody($bytes); - foreach ($this->_bound as $is) { + $this->canonicalizeBody($bytes); + foreach ($this->bound as $is) { $is->write($bytes); } } @@ -259,7 +244,7 @@ public function commit() public function bind(Swift_InputByteStream $is) { // Don't have to mirror anything - $this->_bound[] = $is; + $this->bound[] = $is; return; } @@ -275,9 +260,9 @@ public function bind(Swift_InputByteStream $is) public function unbind(Swift_InputByteStream $is) { // Don't have to mirror anything - foreach ($this->_bound as $k => $stream) { + foreach ($this->bound as $k => $stream) { if ($stream === $is) { - unset($this->_bound[$k]); + unset($this->bound[$k]); return; } @@ -308,10 +293,10 @@ public function setHashAlgorithm($hash) { switch ($hash) { case 'rsa-sha1': - $this->_hashAlgorithm = 'rsa-sha1'; + $this->hashAlgorithm = 'rsa-sha1'; break; case 'rsa-sha256': - $this->_hashAlgorithm = 'rsa-sha256'; + $this->hashAlgorithm = 'rsa-sha256'; if (!defined('OPENSSL_ALGO_SHA256')) { throw new Swift_SwiftException('Unable to set sha256 as it is not supported by OpenSSL.'); } @@ -333,9 +318,9 @@ public function setHashAlgorithm($hash) public function setBodyCanon($canon) { if ($canon == 'relaxed') { - $this->_bodyCanon = 'relaxed'; + $this->bodyCanon = 'relaxed'; } else { - $this->_bodyCanon = 'simple'; + $this->bodyCanon = 'simple'; } return $this; @@ -351,9 +336,9 @@ public function setBodyCanon($canon) public function setHeaderCanon($canon) { if ($canon == 'relaxed') { - $this->_headerCanon = 'relaxed'; + $this->headerCanon = 'relaxed'; } else { - $this->_headerCanon = 'simple'; + $this->headerCanon = 'simple'; } return $this; @@ -368,7 +353,7 @@ public function setHeaderCanon($canon) */ public function setSignerIdentity($identity) { - $this->_signerIdentity = $identity; + $this->signerIdentity = $identity; return $this; } @@ -383,14 +368,14 @@ public function setSignerIdentity($identity) public function setBodySignedLen($len) { if ($len === true) { - $this->_showLen = true; - $this->_maxLen = PHP_INT_MAX; + $this->showLen = true; + $this->maxLen = PHP_INT_MAX; } elseif ($len === false) { - $this->_showLen = false; - $this->_maxLen = PHP_INT_MAX; + $this->showLen = false; + $this->maxLen = PHP_INT_MAX; } else { - $this->_showLen = true; - $this->_maxLen = (int) $len; + $this->showLen = true; + $this->maxLen = (int) $len; } return $this; @@ -405,7 +390,7 @@ public function setBodySignedLen($len) */ public function setSignatureTimestamp($time) { - $this->_signatureTimestamp = $time; + $this->signatureTimestamp = $time; return $this; } @@ -419,7 +404,7 @@ public function setSignatureTimestamp($time) */ public function setSignatureExpiration($time) { - $this->_signatureExpiration = $time; + $this->signatureExpiration = $time; return $this; } @@ -433,7 +418,7 @@ public function setSignatureExpiration($time) */ public function setDebugHeaders($debug) { - $this->_debugHeaders = (bool) $debug; + $this->debugHeaders = (bool) $debug; return $this; } @@ -444,15 +429,15 @@ public function setDebugHeaders($debug) public function startBody() { // Init - switch ($this->_hashAlgorithm) { + switch ($this->hashAlgorithm) { case 'rsa-sha256': - $this->_bodyHashHandler = hash_init('sha256'); + $this->bodyHashHandler = hash_init('sha256'); break; case 'rsa-sha1': - $this->_bodyHashHandler = hash_init('sha1'); + $this->bodyHashHandler = hash_init('sha1'); break; } - $this->_bodyCanonLine = ''; + $this->bodyCanonLine = ''; } /** @@ -460,7 +445,7 @@ public function startBody() */ public function endBody() { - $this->_endOfBody(); + $this->endOfBody(); } /** @@ -470,7 +455,7 @@ public function endBody() */ public function getAlteredHeaders() { - if ($this->_debugHeaders) { + if ($this->debugHeaders) { return array('DKIM-Signature', 'X-DebugHash'); } else { return array('DKIM-Signature'); @@ -486,7 +471,7 @@ public function getAlteredHeaders() */ public function ignoreHeader($header_name) { - $this->_ignoredHeaders[strtolower($header_name)] = true; + $this->ignoredHeaders[strtolower($header_name)] = true; return $this; } @@ -494,24 +479,24 @@ public function ignoreHeader($header_name) /** * Set the headers to sign. * - * @param Swift_Mime_HeaderSet $headers + * @param Swift_Mime_SimpleHeaderSet $headers * * @return Swift_Signers_DKIMSigner */ - public function setHeaders(Swift_Mime_HeaderSet $headers) + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) { - $this->_headerCanonData = ''; + $this->headerCanonData = ''; // Loop through Headers $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header - if (!isset($this->_ignoredHeaders[strtolower($hName)])) { + if (!isset($this->ignoredHeaders[strtolower($hName)])) { if ($headers->has($hName)) { $tmp = $headers->getAll($hName); foreach ($tmp as $header) { if ($header->getFieldBody() != '') { - $this->_addHeader($header->toString()); - $this->_signedHeaders[] = $header->getFieldName(); + $this->addHeader($header->toString()); + $this->signedHeaders[] = $header->getFieldName(); } } } @@ -524,37 +509,37 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) /** * Add the signature to the given Headers. * - * @param Swift_Mime_HeaderSet $headers + * @param Swift_Mime_SimpleHeaderSet $headers * * @return Swift_Signers_DKIMSigner */ - public function addSignature(Swift_Mime_HeaderSet $headers) + public function addSignature(Swift_Mime_SimpleHeaderSet $headers) { // Prepare the DKIM-Signature - $params = array('v' => '1', 'a' => $this->_hashAlgorithm, 'bh' => base64_encode($this->_bodyHash), 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'i' => $this->_signerIdentity, 's' => $this->_selector); - if ($this->_bodyCanon != 'simple') { - $params['c'] = $this->_headerCanon.'/'.$this->_bodyCanon; - } elseif ($this->_headerCanon != 'simple') { - $params['c'] = $this->_headerCanon; + $params = array('v' => '1', 'a' => $this->hashAlgorithm, 'bh' => base64_encode($this->bodyHash), 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'i' => $this->signerIdentity, 's' => $this->selector); + if ($this->bodyCanon != 'simple') { + $params['c'] = $this->headerCanon.'/'.$this->bodyCanon; + } elseif ($this->headerCanon != 'simple') { + $params['c'] = $this->headerCanon; } - if ($this->_showLen) { - $params['l'] = $this->_bodyLen; + if ($this->showLen) { + $params['l'] = $this->bodyLen; } - if ($this->_signatureTimestamp === true) { + if ($this->signatureTimestamp === true) { $params['t'] = time(); - if ($this->_signatureExpiration !== false) { - $params['x'] = $params['t'] + $this->_signatureExpiration; + if ($this->signatureExpiration !== false) { + $params['x'] = $params['t'] + $this->signatureExpiration; } } else { - if ($this->_signatureTimestamp !== false) { - $params['t'] = $this->_signatureTimestamp; + if ($this->signatureTimestamp !== false) { + $params['t'] = $this->signatureTimestamp; } - if ($this->_signatureExpiration !== false) { - $params['x'] = $this->_signatureExpiration; + if ($this->signatureExpiration !== false) { + $params['x'] = $this->signatureExpiration; } } - if ($this->_debugHeaders) { - $params['z'] = implode('|', $this->_debugHeadersData); + if ($this->debugHeaders) { + $params['z'] = implode('|', $this->debugHeadersData); } $string = ''; foreach ($params as $k => $v) { @@ -564,22 +549,21 @@ public function addSignature(Swift_Mime_HeaderSet $headers) $headers->addTextHeader('DKIM-Signature', $string); // Add the last DKIM-Signature $tmp = $headers->getAll('DKIM-Signature'); - $this->_dkimHeader = end($tmp); - $this->_addHeader(trim($this->_dkimHeader->toString())."\r\n b=", true); - $this->_endOfHeaders(); - if ($this->_debugHeaders) { - $headers->addTextHeader('X-DebugHash', base64_encode($this->_headerHash)); + $this->dkimHeader = end($tmp); + $this->addHeader(trim($this->dkimHeader->toString())."\r\n b=", true); + if ($this->debugHeaders) { + $headers->addTextHeader('X-DebugHash', base64_encode($this->headerHash)); } - $this->_dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->_getEncryptedHash()), 73, ' '))); + $this->dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->getEncryptedHash()), 73, ' '))); return $this; } /* Private helpers */ - protected function _addHeader($header, $is_sig = false) + protected function addHeader($header, $is_sig = false) { - switch ($this->_headerCanon) { + switch ($this->headerCanon) { case 'relaxed': // Prepare Header and cascade $exploded = explode(':', $header, 2); @@ -590,41 +574,32 @@ protected function _addHeader($header, $is_sig = false) case 'simple': // Nothing to do } - $this->_addToHeaderHash($header); + $this->addToHeaderHash($header); } - /** - * @deprecated This method is currently useless in this class but it must be - * kept for BC reasons due to its "protected" scope. This method - * might be overridden by custom client code. - */ - protected function _endOfHeaders() - { - } - - protected function _canonicalizeBody($string) + protected function canonicalizeBody($string) { $len = strlen($string); $canon = ''; - $method = ($this->_bodyCanon == 'relaxed'); + $method = ($this->bodyCanon == 'relaxed'); for ($i = 0; $i < $len; ++$i) { - if ($this->_bodyCanonIgnoreStart > 0) { - --$this->_bodyCanonIgnoreStart; + if ($this->bodyCanonIgnoreStart > 0) { + --$this->bodyCanonIgnoreStart; continue; } switch ($string[$i]) { case "\r": - $this->_bodyCanonLastChar = "\r"; + $this->bodyCanonLastChar = "\r"; break; case "\n": - if ($this->_bodyCanonLastChar == "\r") { + if ($this->bodyCanonLastChar == "\r") { if ($method) { - $this->_bodyCanonSpace = false; + $this->bodyCanonSpace = false; } - if ($this->_bodyCanonLine == '') { - ++$this->_bodyCanonEmptyCounter; + if ($this->bodyCanonLine == '') { + ++$this->bodyCanonEmptyCounter; } else { - $this->_bodyCanonLine = ''; + $this->bodyCanonLine = ''; $canon .= "\r\n"; } } else { @@ -635,52 +610,52 @@ protected function _canonicalizeBody($string) case ' ': case "\t": if ($method) { - $this->_bodyCanonSpace = true; + $this->bodyCanonSpace = true; break; } default: - if ($this->_bodyCanonEmptyCounter > 0) { - $canon .= str_repeat("\r\n", $this->_bodyCanonEmptyCounter); - $this->_bodyCanonEmptyCounter = 0; + if ($this->bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); + $this->bodyCanonEmptyCounter = 0; } - if ($this->_bodyCanonSpace) { - $this->_bodyCanonLine .= ' '; + if ($this->bodyCanonSpace) { + $this->bodyCanonLine .= ' '; $canon .= ' '; - $this->_bodyCanonSpace = false; + $this->bodyCanonSpace = false; } - $this->_bodyCanonLine .= $string[$i]; + $this->bodyCanonLine .= $string[$i]; $canon .= $string[$i]; } } - $this->_addToBodyHash($canon); + $this->addToBodyHash($canon); } - protected function _endOfBody() + protected function endOfBody() { // Add trailing Line return if last line is non empty - if (strlen($this->_bodyCanonLine) > 0) { - $this->_addToBodyHash("\r\n"); + if (strlen($this->bodyCanonLine) > 0) { + $this->addToBodyHash("\r\n"); } - $this->_bodyHash = hash_final($this->_bodyHashHandler, true); + $this->bodyHash = hash_final($this->bodyHashHandler, true); } - private function _addToBodyHash($string) + private function addToBodyHash($string) { $len = strlen($string); - if ($len > ($new_len = ($this->_maxLen - $this->_bodyLen))) { + if ($len > ($new_len = ($this->maxLen - $this->bodyLen))) { $string = substr($string, 0, $new_len); $len = $new_len; } - hash_update($this->_bodyHashHandler, $string); - $this->_bodyLen += $len; + hash_update($this->bodyHashHandler, $string); + $this->bodyLen += $len; } - private function _addToHeaderHash($header) + private function addToHeaderHash($header) { - if ($this->_debugHeaders) { - $this->_debugHeadersData[] = trim($header); + if ($this->debugHeaders) { + $this->debugHeadersData[] = trim($header); } - $this->_headerCanonData .= $header; + $this->headerCanonData .= $header; } /** @@ -688,11 +663,10 @@ private function _addToHeaderHash($header) * * @return string */ - private function _getEncryptedHash() + private function getEncryptedHash() { $signature = ''; - - switch ($this->_hashAlgorithm) { + switch ($this->hashAlgorithm) { case 'rsa-sha1': $algorithm = OPENSSL_ALGO_SHA1; break; @@ -700,11 +674,11 @@ private function _getEncryptedHash() $algorithm = OPENSSL_ALGO_SHA256; break; } - $pkeyId = openssl_get_privatekey($this->_privateKey); + $pkeyId = openssl_get_privatekey($this->privateKey, $this->passphrase); if (!$pkeyId) { throw new Swift_SwiftException('Unable to load DKIM Private Key ['.openssl_error_string().']'); } - if (openssl_sign($this->_headerCanonData, $signature, $pkeyId, $algorithm)) { + if (openssl_sign($this->headerCanonData, $signature, $pkeyId, $algorithm)) { return $signature; } throw new Swift_SwiftException('Unable to sign DKIM Hash ['.openssl_error_string().']'); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php index 0365363c8..40654987f 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php @@ -11,7 +11,7 @@ /** * DomainKey Signer used to apply DomainKeys Signature to a message. * - * @author Xavier De Cock + * @author Xavier De Cock */ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner { @@ -20,56 +20,56 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner * * @var string */ - protected $_privateKey; + protected $privateKey; /** * DomainName. * * @var string */ - protected $_domainName; + protected $domainName; /** * Selector. * * @var string */ - protected $_selector; + protected $selector; /** * Hash algorithm used. * * @var string */ - protected $_hashAlgorithm = 'rsa-sha1'; + protected $hashAlgorithm = 'rsa-sha1'; /** * Canonisation method. * * @var string */ - protected $_canon = 'simple'; + protected $canon = 'simple'; /** * Headers not being signed. * * @var array */ - protected $_ignoredHeaders = array(); + protected $ignoredHeaders = array(); /** * Signer identity. * * @var string */ - protected $_signerIdentity; + protected $signerIdentity; /** * Must we embed signed headers? * * @var bool */ - protected $_debugHeaders = false; + protected $debugHeaders = false; // work variables /** @@ -77,37 +77,37 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner * * @var array */ - private $_signedHeaders = array(); + private $signedHeaders = array(); /** * Stores the signature header. * * @var Swift_Mime_Headers_ParameterizedHeader */ - protected $_domainKeyHeader; + protected $domainKeyHeader; /** * Hash Handler. * * @var resource|null */ - private $_hashHandler; + private $hashHandler; - private $_hash; + private $hash; - private $_canonData = ''; + private $canonData = ''; - private $_bodyCanonEmptyCounter = 0; + private $bodyCanonEmptyCounter = 0; - private $_bodyCanonIgnoreStart = 2; + private $bodyCanonIgnoreStart = 2; - private $_bodyCanonSpace = false; + private $bodyCanonSpace = false; - private $_bodyCanonLastChar = null; + private $bodyCanonLastChar = null; - private $_bodyCanonLine = ''; + private $bodyCanonLine = ''; - private $_bound = array(); + private $bound = array(); /** * Constructor. @@ -118,24 +118,10 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner */ public function __construct($privateKey, $domainName, $selector) { - $this->_privateKey = $privateKey; - $this->_domainName = $domainName; - $this->_signerIdentity = '@'.$domainName; - $this->_selector = $selector; - } - - /** - * Instanciate DomainKeySigner. - * - * @param string $privateKey - * @param string $domainName - * @param string $selector - * - * @return self - */ - public static function newInstance($privateKey, $domainName, $selector) - { - return new static($privateKey, $domainName, $selector); + $this->privateKey = $privateKey; + $this->domainName = $domainName; + $this->signerIdentity = '@'.$domainName; + $this->selector = $selector; } /** @@ -145,12 +131,12 @@ public static function newInstance($privateKey, $domainName, $selector) */ public function reset() { - $this->_hash = null; - $this->_hashHandler = null; - $this->_bodyCanonIgnoreStart = 2; - $this->_bodyCanonEmptyCounter = 0; - $this->_bodyCanonLastChar = null; - $this->_bodyCanonSpace = false; + $this->hash = null; + $this->hashHandler = null; + $this->bodyCanonIgnoreStart = 2; + $this->bodyCanonEmptyCounter = 0; + $this->bodyCanonLastChar = null; + $this->bodyCanonSpace = false; return $this; } @@ -167,14 +153,16 @@ public function reset() * * @param string $bytes * + * @return int + * * @throws Swift_IoException * * @return $this */ public function write($bytes) { - $this->_canonicalizeBody($bytes); - foreach ($this->_bound as $is) { + $this->canonicalizeBody($bytes); + foreach ($this->bound as $is) { $is->write($bytes); } @@ -207,7 +195,7 @@ public function commit() public function bind(Swift_InputByteStream $is) { // Don't have to mirror anything - $this->_bound[] = $is; + $this->bound[] = $is; return $this; } @@ -225,9 +213,9 @@ public function bind(Swift_InputByteStream $is) public function unbind(Swift_InputByteStream $is) { // Don't have to mirror anything - foreach ($this->_bound as $k => $stream) { + foreach ($this->bound as $k => $stream) { if ($stream === $is) { - unset($this->_bound[$k]); + unset($this->bound[$k]); break; } @@ -260,7 +248,7 @@ public function flushBuffers() */ public function setHashAlgorithm($hash) { - $this->_hashAlgorithm = 'rsa-sha1'; + $this->hashAlgorithm = 'rsa-sha1'; return $this; } @@ -275,9 +263,9 @@ public function setHashAlgorithm($hash) public function setCanon($canon) { if ($canon == 'nofws') { - $this->_canon = 'nofws'; + $this->canon = 'nofws'; } else { - $this->_canon = 'simple'; + $this->canon = 'simple'; } return $this; @@ -292,7 +280,7 @@ public function setCanon($canon) */ public function setSignerIdentity($identity) { - $this->_signerIdentity = $identity; + $this->signerIdentity = $identity; return $this; } @@ -306,7 +294,7 @@ public function setSignerIdentity($identity) */ public function setDebugHeaders($debug) { - $this->_debugHeaders = (bool) $debug; + $this->debugHeaders = (bool) $debug; return $this; } @@ -323,7 +311,7 @@ public function startBody() */ public function endBody() { - $this->_endOfBody(); + $this->endOfBody(); } /** @@ -333,7 +321,7 @@ public function endBody() */ public function getAlteredHeaders() { - if ($this->_debugHeaders) { + if ($this->debugHeaders) { return array('DomainKey-Signature', 'X-DebugHash'); } @@ -349,7 +337,7 @@ public function getAlteredHeaders() */ public function ignoreHeader($header_name) { - $this->_ignoredHeaders[strtolower($header_name)] = true; + $this->ignoredHeaders[strtolower($header_name)] = true; return $this; } @@ -357,31 +345,31 @@ public function ignoreHeader($header_name) /** * Set the headers to sign. * - * @param Swift_Mime_HeaderSet $headers + * @param Swift_Mime_SimpleHeaderSet $headers * * @return $this */ - public function setHeaders(Swift_Mime_HeaderSet $headers) + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) { - $this->_startHash(); - $this->_canonData = ''; + $this->startHash(); + $this->canonData = ''; // Loop through Headers $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header - if (!isset($this->_ignoredHeaders[strtolower($hName)])) { + if (!isset($this->ignoredHeaders[strtolower($hName)])) { if ($headers->has($hName)) { $tmp = $headers->getAll($hName); foreach ($tmp as $header) { if ($header->getFieldBody() != '') { - $this->_addHeader($header->toString()); - $this->_signedHeaders[] = $header->getFieldName(); + $this->addHeader($header->toString()); + $this->signedHeaders[] = $header->getFieldName(); } } } } } - $this->_endOfHeaders(); + $this->endOfHeaders(); return $this; } @@ -389,14 +377,14 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) /** * Add the signature to the given Headers. * - * @param Swift_Mime_HeaderSet $headers + * @param Swift_Mime_SimpleHeaderSet $headers * * @return $this */ - public function addSignature(Swift_Mime_HeaderSet $headers) + public function addSignature(Swift_Mime_SimpleHeaderSet $headers) { // Prepare the DomainKey-Signature Header - $params = array('a' => $this->_hashAlgorithm, 'b' => chunk_split(base64_encode($this->_getEncryptedHash()), 73, ' '), 'c' => $this->_canon, 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'q' => 'dns', 's' => $this->_selector); + $params = array('a' => $this->hashAlgorithm, 'b' => chunk_split(base64_encode($this->getEncryptedHash()), 73, ' '), 'c' => $this->canon, 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'q' => 'dns', 's' => $this->selector); $string = ''; foreach ($params as $k => $v) { $string .= $k.'='.$v.'; '; @@ -409,9 +397,9 @@ public function addSignature(Swift_Mime_HeaderSet $headers) /* Private helpers */ - protected function _addHeader($header) + protected function addHeader($header) { - switch ($this->_canon) { + switch ($this->canon) { case 'nofws': // Prepare Header and cascade $exploded = explode(':', $header, 2); @@ -422,37 +410,37 @@ protected function _addHeader($header) case 'simple': // Nothing to do } - $this->_addToHash($header); + $this->addToHash($header); } - protected function _endOfHeaders() + protected function endOfHeaders() { - $this->_bodyCanonEmptyCounter = 1; + $this->bodyCanonEmptyCounter = 1; } - protected function _canonicalizeBody($string) + protected function canonicalizeBody($string) { $len = strlen($string); $canon = ''; - $nofws = ($this->_canon == 'nofws'); + $nofws = ($this->canon == 'nofws'); for ($i = 0; $i < $len; ++$i) { - if ($this->_bodyCanonIgnoreStart > 0) { - --$this->_bodyCanonIgnoreStart; + if ($this->bodyCanonIgnoreStart > 0) { + --$this->bodyCanonIgnoreStart; continue; } switch ($string[$i]) { case "\r": - $this->_bodyCanonLastChar = "\r"; + $this->bodyCanonLastChar = "\r"; break; case "\n": - if ($this->_bodyCanonLastChar == "\r") { + if ($this->bodyCanonLastChar == "\r") { if ($nofws) { - $this->_bodyCanonSpace = false; + $this->bodyCanonSpace = false; } - if ($this->_bodyCanonLine == '') { - ++$this->_bodyCanonEmptyCounter; + if ($this->bodyCanonLine == '') { + ++$this->bodyCanonEmptyCounter; } else { - $this->_bodyCanonLine = ''; + $this->bodyCanonLine = ''; $canon .= "\r\n"; } } else { @@ -464,44 +452,44 @@ protected function _canonicalizeBody($string) case "\t": case "\x09": //HTAB if ($nofws) { - $this->_bodyCanonSpace = true; + $this->bodyCanonSpace = true; break; } default: - if ($this->_bodyCanonEmptyCounter > 0) { - $canon .= str_repeat("\r\n", $this->_bodyCanonEmptyCounter); - $this->_bodyCanonEmptyCounter = 0; + if ($this->bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); + $this->bodyCanonEmptyCounter = 0; } - $this->_bodyCanonLine .= $string[$i]; + $this->bodyCanonLine .= $string[$i]; $canon .= $string[$i]; } } - $this->_addToHash($canon); + $this->addToHash($canon); } - protected function _endOfBody() + protected function endOfBody() { - if (strlen($this->_bodyCanonLine) > 0) { - $this->_addToHash("\r\n"); + if (strlen($this->bodyCanonLine) > 0) { + $this->addToHash("\r\n"); } - $this->_hash = hash_final($this->_hashHandler, true); + $this->hash = hash_final($this->hashHandler, true); } - private function _addToHash($string) + private function addToHash($string) { - $this->_canonData .= $string; - hash_update($this->_hashHandler, $string); + $this->canonData .= $string; + hash_update($this->hashHandler, $string); } - private function _startHash() + private function startHash() { // Init - switch ($this->_hashAlgorithm) { + switch ($this->hashAlgorithm) { case 'rsa-sha1': - $this->_hashHandler = hash_init('sha1'); + $this->hashHandler = hash_init('sha1'); break; } - $this->_bodyCanonLine = ''; + $this->bodyCanonLine = ''; } /** @@ -509,14 +497,14 @@ private function _startHash() * * @return string */ - private function _getEncryptedHash() + private function getEncryptedHash() { $signature = ''; - $pkeyId = openssl_get_privatekey($this->_privateKey); + $pkeyId = openssl_get_privatekey($this->privateKey); if (!$pkeyId) { throw new Swift_SwiftException('Unable to load DomainKey Private Key ['.openssl_error_string().']'); } - if (openssl_sign($this->_canonData, $signature, $pkeyId, OPENSSL_ALGO_SHA1)) { + if (openssl_sign($this->canonData, $signature, $pkeyId, OPENSSL_ALGO_SHA1)) { return $signature; } throw new Swift_SwiftException('Unable to sign DomainKey Hash ['.openssl_error_string().']'); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php index ef8832fdf..6104e34f3 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php @@ -45,16 +45,16 @@ public function endBody(); * * @return self */ - public function setHeaders(Swift_Mime_HeaderSet $headers); + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers); /** * Add the header(s) to the headerSet. * - * @param Swift_Mime_HeaderSet $headers + * @param Swift_Mime_SimpleHeaderSet $headers * * @return self */ - public function addSignature(Swift_Mime_HeaderSet $headers); + public function addSignature(Swift_Mime_SimpleHeaderSet $headers); /** * Return the list of header a signer might tamper. diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php index 8fdbaa43b..deb29f575 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php @@ -12,13 +12,13 @@ * DKIM Signer used to apply DKIM Signature to a message * Takes advantage of pecl extension. * - * @author Xavier De Cock + * @author Xavier De Cock */ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { - private $_peclLoaded = false; + private $peclLoaded = false; - private $_dkimHandler = null; + private $dkimHandler = null; private $dropFirstLF = true; @@ -33,22 +33,17 @@ public function __construct($privateKey, $domainName, $selector) throw new Swift_SwiftException('php-opendkim extension not found'); } - $this->_peclLoaded = true; + $this->peclLoaded = true; parent::__construct($privateKey, $domainName, $selector); } - public static function newInstance($privateKey, $domainName, $selector) - { - return new static($privateKey, $domainName, $selector); - } - - public function addSignature(Swift_Mime_HeaderSet $headers) + public function addSignature(Swift_Mime_SimpleHeaderSet $headers) { $header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature'); - $headerVal = $this->_dkimHandler->getSignatureHeader(); + $headerVal = $this->dkimHandler->getSignatureHeader(); if (!$headerVal) { - throw new Swift_SwiftException('OpenDKIM Error: '.$this->_dkimHandler->getError()); + throw new Swift_SwiftException('OpenDKIM Error: '.$this->dkimHandler->getError()); } $header->setValue($headerVal); $headers->set($header); @@ -56,40 +51,40 @@ public function addSignature(Swift_Mime_HeaderSet $headers) return $this; } - public function setHeaders(Swift_Mime_HeaderSet $headers) + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) { - $bodyLen = $this->_bodyLen; + $bodyLen = $this->bodyLen; if (is_bool($bodyLen)) { $bodyLen = -1; } - $hash = $this->_hashAlgorithm == 'rsa-sha1' ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; - $bodyCanon = $this->_bodyCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; - $headerCanon = $this->_headerCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; - $this->_dkimHandler = new OpenDKIMSign($this->_privateKey, $this->_selector, $this->_domainName, $headerCanon, $bodyCanon, $hash, $bodyLen); + $hash = $this->hashAlgorithm == 'rsa-sha1' ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; + $bodyCanon = $this->bodyCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $headerCanon = $this->headerCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $this->dkimHandler = new OpenDKIMSign($this->privateKey, $this->selector, $this->domainName, $headerCanon, $bodyCanon, $hash, $bodyLen); // Hardcode signature Margin for now - $this->_dkimHandler->setMargin(78); + $this->dkimHandler->setMargin(78); - if (!is_numeric($this->_signatureTimestamp)) { + if (!is_numeric($this->signatureTimestamp)) { OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time()); } else { - if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->_signatureTimestamp)) { + if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->signatureTimestamp)) { throw new Swift_SwiftException('Unable to force signature timestamp ['.openssl_error_string().']'); } } - if (isset($this->_signerIdentity)) { - $this->_dkimHandler->setSigner($this->_signerIdentity); + if (isset($this->signerIdentity)) { + $this->dkimHandler->setSigner($this->signerIdentity); } $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header - if (!isset($this->_ignoredHeaders[strtolower($hName)])) { + if (!isset($this->ignoredHeaders[strtolower($hName)])) { $tmp = $headers->getAll($hName); if ($headers->has($hName)) { foreach ($tmp as $header) { if ($header->getFieldBody() != '') { $htosign = $header->toString(); - $this->_dkimHandler->header($htosign); - $this->_signedHeaders[] = $header->getFieldName(); + $this->dkimHandler->header($htosign); + $this->signedHeaders[] = $header->getFieldName(); } } } @@ -101,28 +96,28 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) public function startBody() { - if (!$this->_peclLoaded) { + if (!$this->peclLoaded) { return parent::startBody(); } $this->dropFirstLF = true; - $this->_dkimHandler->eoh(); + $this->dkimHandler->eoh(); return $this; } public function endBody() { - if (!$this->_peclLoaded) { + if (!$this->peclLoaded) { return parent::endBody(); } - $this->_dkimHandler->eom(); + $this->dkimHandler->eom(); return $this; } public function reset() { - $this->_dkimHandler = null; + $this->dkimHandler = null; parent::reset(); return $this; @@ -137,7 +132,7 @@ public function reset() */ public function setSignatureTimestamp($time) { - $this->_signatureTimestamp = $time; + $this->signatureTimestamp = $time; return $this; } @@ -151,7 +146,7 @@ public function setSignatureTimestamp($time) */ public function setSignatureExpiration($time) { - $this->_signatureExpiration = $time; + $this->signatureExpiration = $time; return $this; } @@ -165,17 +160,17 @@ public function setSignatureExpiration($time) */ public function setDebugHeaders($debug) { - $this->_debugHeaders = (bool) $debug; + $this->debugHeaders = (bool) $debug; return $this; } // Protected - protected function _canonicalizeBody($string) + protected function canonicalizeBody($string) { - if (!$this->_peclLoaded) { - return parent::_canonicalizeBody($string); + if (!$this->peclLoaded) { + return parent::canonicalizeBody($string); } if (false && $this->dropFirstLF === true) { if ($string[0] == "\r" && $string[1] == "\n") { @@ -184,7 +179,7 @@ protected function _canonicalizeBody($string) } $this->dropFirstLF = false; if (strlen($string)) { - $this->_dkimHandler->body($string); + $this->dkimHandler->body($string); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php index d13c02e4c..eea2648c9 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php @@ -34,7 +34,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner protected $replacementFactory; /** - * @var Swift_Mime_HeaderFactory + * @var Swift_Mime_SimpleHeaderFactory */ protected $headerFactory; @@ -59,26 +59,7 @@ public function __construct($signCertificate = null, $signPrivateKey = null, $en ->lookup('transport.replacementfactory'); $this->signOptions = PKCS7_DETACHED; - - // Supported since php5.4 - if (defined('OPENSSL_CIPHER_AES_128_CBC')) { - $this->encryptCipher = OPENSSL_CIPHER_AES_128_CBC; - } else { - $this->encryptCipher = OPENSSL_CIPHER_RC2_128; - } - } - - /** - * Returns an new Swift_Signers_SMimeSigner instance. - * - * @param string $certificate - * @param string $privateKey - * - * @return self - */ - public static function newInstance($certificate = null, $privateKey = null) - { - return new self($certificate, $privateKey); + $this->encryptCipher = OPENSSL_CIPHER_AES_128_CBC; } /** @@ -297,7 +278,7 @@ protected function messageStreamToSignedByteStream(Swift_FileStream $outputStrea $args[] = $this->extraCerts; } - if (!call_user_func_array('openssl_pkcs7_sign', $args)) { + if (!openssl_pkcs7_sign(...$args)) { throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php index b97f01e7c..011c03ab1 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php @@ -11,7 +11,7 @@ /** * Sends Messages over SMTP with ESMTP support. * - * @author Chris Corbyn + * @author Chris Corbyn * * @method Swift_SmtpTransport setUsername(string $username) Set the username to authenticate with. * @method string getUsername() Get the username to authenticate with. @@ -41,18 +41,4 @@ public function __construct($host = 'localhost', $port = 25, $security = null) $this->setPort($port); $this->setEncryption($security); } - - /** - * Create a new SmtpTransport instance. - * - * @param string $host - * @param int $port - * @param string $security - * - * @return self - */ - public static function newInstance($host = 'localhost', $port = 25, $security = null) - { - return new self($host, $port, $security); - } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php b/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php index c16ab4b38..9d0e8fee2 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php @@ -35,11 +35,11 @@ public function isStarted(); /** * Queues a message. * - * @param Swift_Mime_Message $message The message to store + * @param Swift_Mime_SimpleMessage $message The message to store * * @return bool Whether the operation has succeeded */ - public function queueMessage(Swift_Mime_Message $message); + public function queueMessage(Swift_Mime_SimpleMessage $message); /** * Sends messages using the given transport instance. diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php index 79c9b1f03..f92567ba0 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php @@ -32,16 +32,4 @@ public function __construct(Swift_Spool $spool) $arguments ); } - - /** - * Create a new SpoolTransport instance. - * - * @param Swift_Spool $spool - * - * @return self - */ - public static function newInstance(Swift_Spool $spool) - { - return new self($spool); - } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php index 9412b1dc7..ba1f6d323 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php @@ -13,26 +13,26 @@ * * This stream filter deals with Byte arrays rather than simple strings. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilter { /** The needle(s) to search for */ - private $_search; + private $search; /** The replacement(s) to make */ - private $_replace; + private $replace; /** The Index for searching */ - private $_index; + private $index; /** The Search Tree */ - private $_tree = array(); + private $tree = array(); /** Gives the size of the largest search */ - private $_treeMaxLen = 0; + private $treeMaxLen = 0; - private $_repSize; + private $repSize; /** * Create a new ByteArrayReplacementFilter with $search and $replace. @@ -42,11 +42,11 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt */ public function __construct($search, $replace) { - $this->_search = $search; - $this->_index = array(); - $this->_tree = array(); - $this->_replace = array(); - $this->_repSize = array(); + $this->search = $search; + $this->index = array(); + $this->tree = array(); + $this->replace = array(); + $this->repSize = array(); $tree = null; $i = null; @@ -56,10 +56,10 @@ public function __construct($search, $replace) $tree[-1] = min(count($replace) - 1, $i - 1); $tree[-2] = $last_size; } - $tree = &$this->_tree; + $tree = &$this->tree; if (is_array($search_element)) { foreach ($search_element as $k => $char) { - $this->_index[$char] = true; + $this->index[$char] = true; if (!isset($tree[$char])) { $tree[$char] = array(); } @@ -74,23 +74,23 @@ public function __construct($search, $replace) } $tree = &$tree[$search_element]; $size = max($last_size, $size); - $this->_index[$search_element] = true; + $this->index[$search_element] = true; } } if ($i !== null) { $tree[-1] = min(count($replace) - 1, $i); $tree[-2] = $last_size; - $this->_treeMaxLen = $size; + $this->treeMaxLen = $size; } foreach ($replace as $rep) { if (!is_array($rep)) { $rep = array($rep); } - $this->_replace[] = $rep; + $this->replace[] = $rep; } - for ($i = count($this->_replace) - 1; $i >= 0; --$i) { - $this->_replace[$i] = $rep = $this->filter($this->_replace[$i], $i); - $this->_repSize[$i] = count($rep); + for ($i = count($this->replace) - 1; $i >= 0; --$i) { + $this->replace[$i] = $rep = $this->filter($this->replace[$i], $i); + $this->repSize[$i] = count($rep); } } @@ -105,20 +105,20 @@ public function shouldBuffer($buffer) { $endOfBuffer = end($buffer); - return isset($this->_index[$endOfBuffer]); + return isset($this->index[$endOfBuffer]); } /** * Perform the actual replacements on $buffer and return the result. * * @param array $buffer - * @param int $_minReplaces + * @param int $minReplaces * * @return array */ - public function filter($buffer, $_minReplaces = -1) + public function filter($buffer, $minReplaces = -1) { - if ($this->_treeMaxLen == 0) { + if ($this->treeMaxLen == 0) { return $buffer; } @@ -126,16 +126,16 @@ public function filter($buffer, $_minReplaces = -1) $buf_size = count($buffer); $last_size = 0; for ($i = 0; $i < $buf_size; ++$i) { - $search_pos = $this->_tree; + $search_pos = $this->tree; $last_found = PHP_INT_MAX; // We try to find if the next byte is part of a search pattern - for ($j = 0; $j <= $this->_treeMaxLen; ++$j) { + for ($j = 0; $j <= $this->treeMaxLen; ++$j) { // We have a new byte for a search pattern if (isset($buffer[$p = $i + $j]) && isset($search_pos[$buffer[$p]])) { $search_pos = $search_pos[$buffer[$p]]; // We have a complete pattern, save, in case we don't find a better match later if (isset($search_pos[-1]) && $search_pos[-1] < $last_found - && $search_pos[-1] > $_minReplaces) { + && $search_pos[-1] > $minReplaces) { $last_found = $search_pos[-1]; $last_size = $search_pos[-2]; } @@ -143,9 +143,9 @@ public function filter($buffer, $_minReplaces = -1) // We got a complete pattern elseif ($last_found !== PHP_INT_MAX) { // Adding replacement datas to output buffer - $rep_size = $this->_repSize[$last_found]; + $rep_size = $this->repSize[$last_found]; for ($j = 0; $j < $rep_size; ++$j) { - $newBuffer[] = $this->_replace[$last_found][$j]; + $newBuffer[] = $this->replace[$last_found][$j]; } // We Move cursor forward $i += $last_size - 1; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php index f64144af2..50a63f1aa 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php @@ -16,10 +16,10 @@ class Swift_StreamFilters_StringReplacementFilter implements Swift_StreamFilter { /** The needle(s) to search for */ - private $_search; + private $search; /** The replacement(s) to make */ - private $_replace; + private $replace; /** * Create a new StringReplacementFilter with $search and $replace. @@ -29,8 +29,8 @@ class Swift_StreamFilters_StringReplacementFilter implements Swift_StreamFilter */ public function __construct($search, $replace) { - $this->_search = $search; - $this->_replace = $replace; + $this->search = $search; + $this->replace = $replace; } /** @@ -47,7 +47,7 @@ public function shouldBuffer($buffer) } $endOfBuffer = substr($buffer, -1); - foreach ((array) $this->_search as $needle) { + foreach ((array) $this->search as $needle) { if (false !== strpos($needle, $endOfBuffer)) { return true; } @@ -65,6 +65,6 @@ public function shouldBuffer($buffer) */ public function filter($buffer) { - return str_replace($this->_search, $this->_replace, $buffer); + return str_replace($this->search, $this->replace, $buffer); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php index e98240b5b..f60f0cf82 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php @@ -16,7 +16,7 @@ class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_ReplacementFilterFactory { /** Lazy-loaded filters */ - private $_filters = array(); + private $filters = array(); /** * Create a new StreamFilter to replace $search with $replace in a string. @@ -28,18 +28,18 @@ class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_Replac */ public function createFilter($search, $replace) { - if (!isset($this->_filters[$search][$replace])) { - if (!isset($this->_filters[$search])) { - $this->_filters[$search] = array(); + if (!isset($this->filters[$search][$replace])) { + if (!isset($this->filters[$search])) { + $this->filters[$search] = array(); } - if (!isset($this->_filters[$search][$replace])) { - $this->_filters[$search][$replace] = array(); + if (!isset($this->filters[$search][$replace])) { + $this->filters[$search][$replace] = array(); } - $this->_filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace); + $this->filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace); } - return $this->_filters[$search][$replace]; + return $this->filters[$search][$replace]; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php index 6535eadf2..f6214b7bf 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php @@ -32,18 +32,41 @@ public function start(); */ public function stop(); + /** + * Check if this Transport mechanism is alive. + * + * If a Transport mechanism session is no longer functional, the method + * returns FALSE. It is the responsibility of the developer to handle this + * case and restart the Transport mechanism manually. + * + * @example + * + * if (!$transport->ping()) { + * $transport->stop(); + * $transport->start(); + * } + * + * The Transport mechanism will be started, if it is not already. + * + * It is undefined if the Transport mechanism attempts to restart as long as + * the return value reflects whether the mechanism is now functional. + * + * @return bool TRUE if the transport is alive + */ + public function ping(); + /** * Send the given Message. * * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * - * @param Swift_Mime_Message $message + * @param Swift_Mime_SimpleMessage $message * @param string[] $failedRecipients An array of failures by-reference * * @return int */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null); + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null); /** * Register a plugin in the Transport. diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php index 60233f968..34c3323fd 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php @@ -16,34 +16,35 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport { /** Input-Output buffer for sending/receiving SMTP commands and responses */ - protected $_buffer; + protected $buffer; /** Connection status */ - protected $_started = false; + protected $started = false; /** The domain name to use in HELO command */ - protected $_domain = '[127.0.0.1]'; + protected $domain = '[127.0.0.1]'; /** The event dispatching layer */ - protected $_eventDispatcher; + protected $eventDispatcher; /** Source Ip */ - protected $_sourceIp; + protected $sourceIp; /** Return an array of params for the Buffer */ - abstract protected function _getBufferParams(); + abstract protected function getBufferParams(); /** * Creates a new EsmtpTransport using the given I/O buffer. * * @param Swift_Transport_IoBuffer $buf * @param Swift_Events_EventDispatcher $dispatcher + * @param string $localDomain */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher) + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1') { - $this->_eventDispatcher = $dispatcher; - $this->_buffer = $buf; - $this->_lookupHostname(); + $this->eventDispatcher = $dispatcher; + $this->buffer = $buf; + $this->setLocalDomain($localDomain); } /** @@ -52,8 +53,9 @@ public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDis * This should be a fully-qualified domain name and should be truly the domain * you're using. * - * If your server doesn't have a domain name, use the IP in square - * brackets (i.e. [127.0.0.1]). + * If your server does not have a domain name, use the IP address. This will + * automatically be wrapped in square brackets as described in RFC 5321, + * section 4.1.3. * * @param string $domain * @@ -61,7 +63,15 @@ public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDis */ public function setLocalDomain($domain) { - $this->_domain = $domain; + if (substr($domain, 0, 1) !== '[') { + if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + $domain = '['.$domain.']'; + } elseif (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + $domain = '[IPv6:'.$domain.']'; + } + } + + $this->domain = $domain; return $this; } @@ -69,11 +79,14 @@ public function setLocalDomain($domain) /** * Get the name of the domain Swift will identify as. * + * If an IP address was specified, this will be returned wrapped in square + * brackets as described in RFC 5321, section 4.1.3. + * * @return string */ public function getLocalDomain() { - return $this->_domain; + return $this->domain; } /** @@ -83,7 +96,7 @@ public function getLocalDomain() */ public function setSourceIp($source) { - $this->_sourceIp = $source; + $this->sourceIp = $source; } /** @@ -93,7 +106,7 @@ public function setSourceIp($source) */ public function getSourceIp() { - return $this->_sourceIp; + return $this->sourceIp; } /** @@ -101,27 +114,27 @@ public function getSourceIp() */ public function start() { - if (!$this->_started) { - if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this)) { - $this->_eventDispatcher->dispatchEvent($evt, 'beforeTransportStarted'); + if (!$this->started) { + if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStarted'); if ($evt->bubbleCancelled()) { return; } } try { - $this->_buffer->initialize($this->_getBufferParams()); + $this->buffer->initialize($this->getBufferParams()); } catch (Swift_TransportException $e) { - $this->_throwException($e); + $this->throwException($e); } - $this->_readGreeting(); - $this->_doHeloCommand(); + $this->readGreeting(); + $this->doHeloCommand(); if ($evt) { - $this->_eventDispatcher->dispatchEvent($evt, 'transportStarted'); + $this->eventDispatcher->dispatchEvent($evt, 'transportStarted'); } - $this->_started = true; + $this->started = true; } } @@ -132,7 +145,7 @@ public function start() */ public function isStarted() { - return $this->_started; + return $this->started; } /** @@ -141,25 +154,25 @@ public function isStarted() * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * - * @param Swift_Mime_Message $message + * @param Swift_Mime_SimpleMessage $message * @param string[] $failedRecipients An array of failures by-reference * * @return int */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { $sent = 0; $failedRecipients = (array) $failedRecipients; - if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { - $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); if ($evt->bubbleCancelled()) { return 0; } } - if (!$reversePath = $this->_getReversePath($message)) { - $this->_throwException(new Swift_TransportException( + if (!$reversePath = $this->getReversePath($message)) { + $this->throwException(new Swift_TransportException( 'Cannot send message without a sender address' ) ); @@ -173,8 +186,8 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $message->setBcc(array()); try { - $sent += $this->_sendTo($message, $reversePath, $tos, $failedRecipients); - $sent += $this->_sendBcc($message, $reversePath, $bcc, $failedRecipients); + $sent += $this->sendTo($message, $reversePath, $tos, $failedRecipients); + $sent += $this->sendBcc($message, $reversePath, $bcc, $failedRecipients); } catch (Exception $e) { $message->setBcc($bcc); throw $e; @@ -191,7 +204,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); } $evt->setFailedRecipients($failedRecipients); - $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); } $message->generateId(); //Make sure a new Message ID is used @@ -204,9 +217,9 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) */ public function stop() { - if ($this->_started) { - if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this)) { - $this->_eventDispatcher->dispatchEvent($evt, 'beforeTransportStopped'); + if ($this->started) { + if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStopped'); if ($evt->bubbleCancelled()) { return; } @@ -218,16 +231,39 @@ public function stop() } try { - $this->_buffer->terminate(); + $this->buffer->terminate(); if ($evt) { - $this->_eventDispatcher->dispatchEvent($evt, 'transportStopped'); + $this->eventDispatcher->dispatchEvent($evt, 'transportStopped'); } } catch (Swift_TransportException $e) { - $this->_throwException($e); + $this->throwException($e); } } - $this->_started = false; + $this->started = false; + } + + /** + * {@inheritdoc} + */ + public function ping() + { + try { + if (!$this->isStarted()) { + $this->start(); + } + + $this->executeCommand("NOOP\r\n", array(250)); + } catch (Swift_TransportException $e) { + try { + $this->stop(); + } catch (Swift_TransportException $e) { + } + + return false; + } + + return true; } /** @@ -237,7 +273,7 @@ public function stop() */ public function registerPlugin(Swift_Events_EventListener $plugin) { - $this->_eventDispatcher->bindEventListener($plugin); + $this->eventDispatcher->bindEventListener($plugin); } /** @@ -255,7 +291,7 @@ public function reset() */ public function getBuffer() { - return $this->_buffer; + return $this->buffer; } /** @@ -273,32 +309,32 @@ public function getBuffer() public function executeCommand($command, $codes = array(), &$failures = null) { $failures = (array) $failures; - $seq = $this->_buffer->write($command); - $response = $this->_getFullResponse($seq); - if ($evt = $this->_eventDispatcher->createCommandEvent($this, $command, $codes)) { - $this->_eventDispatcher->dispatchEvent($evt, 'commandSent'); + $seq = $this->buffer->write($command); + $response = $this->getFullResponse($seq); + if ($evt = $this->eventDispatcher->createCommandEvent($this, $command, $codes)) { + $this->eventDispatcher->dispatchEvent($evt, 'commandSent'); } - $this->_assertResponseCode($response, $codes); + $this->assertResponseCode($response, $codes); return $response; } /** Read the opening SMTP greeting */ - protected function _readGreeting() + protected function readGreeting() { - $this->_assertResponseCode($this->_getFullResponse(0), array(220)); + $this->assertResponseCode($this->getFullResponse(0), array(220)); } /** Send the HELO welcome */ - protected function _doHeloCommand() + protected function doHeloCommand() { $this->executeCommand( - sprintf("HELO %s\r\n", $this->_domain), array(250) + sprintf("HELO %s\r\n", $this->domain), array(250) ); } /** Send the MAIL FROM command */ - protected function _doMailFromCommand($address) + protected function doMailFromCommand($address) { $this->executeCommand( sprintf("MAIL FROM:<%s>\r\n", $address), array(250) @@ -306,7 +342,7 @@ protected function _doMailFromCommand($address) } /** Send the RCPT TO command */ - protected function _doRcptToCommand($address) + protected function doRcptToCommand($address) { $this->executeCommand( sprintf("RCPT TO:<%s>\r\n", $address), array(250, 251, 252) @@ -314,27 +350,27 @@ protected function _doRcptToCommand($address) } /** Send the DATA command */ - protected function _doDataCommand() + protected function doDataCommand() { $this->executeCommand("DATA\r\n", array(354)); } /** Stream the contents of the message over the buffer */ - protected function _streamMessage(Swift_Mime_Message $message) + protected function streamMessage(Swift_Mime_SimpleMessage $message) { - $this->_buffer->setWriteTranslations(array("\r\n." => "\r\n..")); + $this->buffer->setWriteTranslations(array("\r\n." => "\r\n..")); try { - $message->toByteStream($this->_buffer); - $this->_buffer->flushBuffers(); + $message->toByteStream($this->buffer); + $this->buffer->flushBuffers(); } catch (Swift_TransportException $e) { - $this->_throwException($e); + $this->throwException($e); } - $this->_buffer->setWriteTranslations(array()); + $this->buffer->setWriteTranslations(array()); $this->executeCommand("\r\n.\r\n", array(250)); } /** Determine the best-use reverse path for this message */ - protected function _getReversePath(Swift_Mime_Message $message) + protected function getReversePath(Swift_Mime_SimpleMessage $message) { $return = $message->getReturnPath(); $sender = $message->getSender(); @@ -355,10 +391,10 @@ protected function _getReversePath(Swift_Mime_Message $message) } /** Throw a TransportException, first sending it to any listeners */ - protected function _throwException(Swift_TransportException $e) + protected function throwException(Swift_TransportException $e) { - if ($evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e)) { - $this->_eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); + if ($evt = $this->eventDispatcher->createTransportExceptionEvent($this, $e)) { + $this->eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); if (!$evt->bubbleCancelled()) { throw $e; } @@ -368,18 +404,18 @@ protected function _throwException(Swift_TransportException $e) } /** Throws an Exception if a response code is incorrect */ - protected function _assertResponseCode($response, $wanted) + protected function assertResponseCode($response, $wanted) { list($code) = sscanf($response, '%3d'); $valid = (empty($wanted) || in_array($code, $wanted)); - if ($evt = $this->_eventDispatcher->createResponseEvent($this, $response, + if ($evt = $this->eventDispatcher->createResponseEvent($this, $response, $valid)) { - $this->_eventDispatcher->dispatchEvent($evt, 'responseReceived'); + $this->eventDispatcher->dispatchEvent($evt, 'responseReceived'); } if (!$valid) { - $this->_throwException( + $this->throwException( new Swift_TransportException( 'Expected response code '.implode('/', $wanted).' but got code '. '"'.$code.'", with message "'.$response.'"', @@ -389,18 +425,18 @@ protected function _assertResponseCode($response, $wanted) } /** Get an entire multi-line response using its sequence number */ - protected function _getFullResponse($seq) + protected function getFullResponse($seq) { $response = ''; try { do { - $line = $this->_buffer->readLine($seq); + $line = $this->buffer->readLine($seq); $response .= $line; } while (null !== $line && false !== $line && ' ' != $line[3]); } catch (Swift_TransportException $e) { - $this->_throwException($e); + $this->throwException($e); } catch (Swift_IoException $e) { - $this->_throwException( + $this->throwException( new Swift_TransportException( $e->getMessage()) ); @@ -410,13 +446,13 @@ protected function _getFullResponse($seq) } /** Send an email to the given recipients from the given reverse path */ - private function _doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients) + private function doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients) { $sent = 0; - $this->_doMailFromCommand($reversePath); + $this->doMailFromCommand($reversePath); foreach ($recipients as $forwardPath) { try { - $this->_doRcptToCommand($forwardPath); + $this->doRcptToCommand($forwardPath); ++$sent; } catch (Swift_TransportException $e) { $failedRecipients[] = $forwardPath; @@ -424,8 +460,8 @@ private function _doMailTransaction($message, $reversePath, array $recipients, a } if ($sent != 0) { - $this->_doDataCommand(); - $this->_streamMessage($message); + $this->doDataCommand(); + $this->streamMessage($message); } else { $this->reset(); } @@ -434,23 +470,23 @@ private function _doMailTransaction($message, $reversePath, array $recipients, a } /** Send a message to the given To: recipients */ - private function _sendTo(Swift_Mime_Message $message, $reversePath, array $to, array &$failedRecipients) + private function sendTo(Swift_Mime_SimpleMessage $message, $reversePath, array $to, array &$failedRecipients) { if (empty($to)) { return 0; } - return $this->_doMailTransaction($message, $reversePath, array_keys($to), + return $this->doMailTransaction($message, $reversePath, array_keys($to), $failedRecipients); } /** Send a message to all Bcc: recipients */ - private function _sendBcc(Swift_Mime_Message $message, $reversePath, array $bcc, array &$failedRecipients) + private function sendBcc(Swift_Mime_SimpleMessage $message, $reversePath, array $bcc, array &$failedRecipients) { $sent = 0; foreach ($bcc as $forwardPath => $name) { $message->setBcc(array($forwardPath => $name)); - $sent += $this->_doMailTransaction( + $sent += $this->doMailTransaction( $message, $reversePath, array($forwardPath), $failedRecipients ); } @@ -458,34 +494,6 @@ private function _sendBcc(Swift_Mime_Message $message, $reversePath, array $bcc, return $sent; } - /** Try to determine the hostname of the server this is run on */ - private function _lookupHostname() - { - if (!empty($_SERVER['SERVER_NAME']) && $this->_isFqdn($_SERVER['SERVER_NAME'])) { - $this->_domain = $_SERVER['SERVER_NAME']; - } elseif (!empty($_SERVER['SERVER_ADDR'])) { - // Set the address literal tag (See RFC 5321, section: 4.1.3) - if (false === strpos($_SERVER['SERVER_ADDR'], ':')) { - $prefix = ''; // IPv4 addresses are not tagged. - } else { - $prefix = 'IPv6:'; // Adding prefix in case of IPv6. - } - - $this->_domain = sprintf('[%s%s]', $prefix, $_SERVER['SERVER_ADDR']); - } - } - - /** Determine is the $hostname is a fully-qualified name */ - private function _isFqdn($hostname) - { - // We could do a really thorough check, but there's really no point - if (false !== $dotPos = strpos($hostname, '.')) { - return ($dotPos > 0) && ($dotPos != strlen($hostname) - 1); - } - - return false; - } - /** * Destructor. */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php index 53f721d03..26c2d745a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php @@ -40,7 +40,7 @@ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $passw $challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", array(334)); $challenge = base64_decode(substr($challenge, 4)); $message = base64_encode( - $username.' '.$this->_getResponse($password, $challenge) + $username.' '.$this->getResponse($password, $challenge) ); $agent->executeCommand(sprintf("%s\r\n", $message), array(235)); @@ -60,7 +60,7 @@ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $passw * * @return string */ - private function _getResponse($secret, $challenge) + private function getResponse($secret, $challenge) { if (strlen($secret) > 64) { $secret = pack('H32', md5($secret)); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php index 839265857..fa5d21100 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php @@ -13,7 +13,7 @@ /** * Handles NTLM authentication. * - * @author Ward Peeters + * @author Ward Peeters */ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Esmtp_Authenticator { @@ -38,10 +38,12 @@ public function getAuthKeyword() * @param string $password * * @return bool + * + * @throws \LogicException */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { - if (!function_exists('openssl_random_pseudo_bytes') || !function_exists('openssl_encrypt')) { + if (!function_exists('openssl_encrypt')) { throw new LogicException('The OpenSSL extension must be enabled to use the NTLM authenticator.'); } @@ -56,7 +58,7 @@ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $passw // extra parameters for our unit cases $timestamp = func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000')); - $client = func_num_args() > 4 ? func_get_arg(4) : $this->getRandomBytes(8); + $client = func_num_args() > 4 ? func_get_arg(4) : random_bytes(8); // Message 3 response $this->sendMessage3($response, $username, $password, $timestamp, $client, $agent); @@ -121,10 +123,10 @@ protected function parseMessage2($response) $responseHex = bin2hex($response); $length = floor(hexdec(substr($responseHex, 28, 4)) / 256) * 2; $offset = floor(hexdec(substr($responseHex, 32, 4)) / 256) * 2; - $challenge = $this->hex2bin(substr($responseHex, 48, 16)); - $context = $this->hex2bin(substr($responseHex, 64, 16)); - $targetInfoH = $this->hex2bin(substr($responseHex, 80, 16)); - $targetName = $this->hex2bin(substr($responseHex, $offset, $length)); + $challenge = hex2bin(substr($responseHex, 48, 16)); + $context = hex2bin(substr($responseHex, 64, 16)); + $targetInfoH = hex2bin(substr($responseHex, 80, 16)); + $targetName = hex2bin(substr($responseHex, $offset, $length)); $offset = floor(hexdec(substr($responseHex, 88, 4)) / 256) * 2; $targetInfoBlock = substr($responseHex, $offset); list($domainName, $serverName, $DNSDomainName, $DNSServerName, $terminatorByte) = $this->readSubBlock($targetInfoBlock); @@ -138,7 +140,7 @@ protected function parseMessage2($response) $serverName, $DNSDomainName, $DNSServerName, - $this->hex2bin($targetInfoBlock), + hex2bin($targetInfoBlock), $terminatorByte, ); } @@ -161,7 +163,7 @@ protected function readSubBlock($block) while ($offset < $length) { $blockLength = hexdec(substr(substr($block, $offset, 8), -4)) / 256; $offset += 8; - $data[] = $this->hex2bin(substr($block, $offset, $blockLength * 2)); + $data[] = hex2bin(substr($block, $offset, $blockLength * 2)); $offset += $blockLength * 2; } @@ -458,7 +460,7 @@ protected function createDesKey($key) } } - return $this->hex2bin(implode('', $material)); + return hex2bin(implode('', $material)); } /** HELPER FUNCTIONS */ @@ -538,7 +540,7 @@ protected function uRShift($a, $b) protected function createByte($input, $bytes = 4, $isHex = true) { if ($isHex) { - $byte = $this->hex2bin(str_pad($input, $bytes * 2, '00')); + $byte = hex2bin(str_pad($input, $bytes * 2, '00')); } else { $byte = str_pad($input, $bytes, "\x00"); } @@ -546,24 +548,6 @@ protected function createByte($input, $bytes = 4, $isHex = true) return $byte; } - /** - * Create random bytes. - * - * @param $length - * - * @return string - */ - protected function getRandomBytes($length) - { - $bytes = openssl_random_pseudo_bytes($length, $strong); - - if (false !== $bytes && true === $strong) { - return $bytes; - } - - throw new RuntimeException('OpenSSL did not produce a secure random number.'); - } - /** ENCRYPTION ALGORITHMS */ /** @@ -576,8 +560,7 @@ protected function getRandomBytes($length) */ protected function desEncrypt($value, $key) { - // 1 == OPENSSL_RAW_DATA - but constant is only available as of PHP 5.4. - return substr(openssl_encrypt($value, 'DES-ECB', $key, 1), 0, 8); + return substr(openssl_encrypt($value, 'DES-ECB', $key, \OPENSSL_RAW_DATA), 0, 8); } /** @@ -615,7 +598,7 @@ protected function md4Encrypt($input) { $input = $this->convertTo16bit($input); - return function_exists('hash') ? $this->hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); + return function_exists('hash') ? hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); } /** @@ -630,22 +613,6 @@ protected function convertTo16bit($input) return iconv('UTF-8', 'UTF-16LE', $input); } - /** - * Hex2bin replacement for < PHP 5.4. - * - * @param string $hex - * - * @return string Binary - */ - protected function hex2bin($hex) - { - if (function_exists('hex2bin')) { - return hex2bin($hex); - } else { - return pack('H*', $hex); - } - } - /** * @param string $message */ @@ -670,7 +637,7 @@ protected function debug($message) 'Target Information Terminator', ); - $data = $this->parseMessage2($this->hex2bin($message)); + $data = $this->parseMessage2(hex2bin($message)); foreach ($map as $key => $value) { echo bin2hex($data[$key]).' - '.$data[$key].' ||| '.$value."
\n"; @@ -716,7 +683,7 @@ protected function debug($message) ); foreach ($map as $key => $value) { - echo $data[$key].' - '.$this->hex2bin($data[$key]).' ||| '.$value."
\n"; + echo $data[$key].' - '.hex2bin($data[$key]).' ||| '.$value."
\n"; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php index ca35e7b83..d1a4cc3d7 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php @@ -13,7 +13,7 @@ * * Example: * - * $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'tls') + * $transport = (new Swift_SmtpTransport('smtp.gmail.com', 587, 'tls')) * ->setAuthMode('XOAUTH2') * ->setUsername('YOUR_EMAIL_ADDRESS') * ->setPassword('YOUR_ACCESS_TOKEN'); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php index cb36133c9..94387f01a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php @@ -20,35 +20,35 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler * * @var Swift_Transport_Esmtp_Authenticator[] */ - private $_authenticators = array(); + private $authenticators = array(); /** * The username for authentication. * * @var string */ - private $_username; + private $username; /** * The password for authentication. * * @var string */ - private $_password; + private $password; /** * The auth mode for authentication. * * @var string */ - private $_auth_mode; + private $auth_mode; /** * The ESMTP AUTH parameters available. * * @var string[] */ - private $_esmtpParams = array(); + private $esmtpParams = array(); /** * Create a new AuthHandler with $authenticators for support. @@ -67,7 +67,7 @@ public function __construct(array $authenticators) */ public function setAuthenticators(array $authenticators) { - $this->_authenticators = $authenticators; + $this->authenticators = $authenticators; } /** @@ -77,7 +77,7 @@ public function setAuthenticators(array $authenticators) */ public function getAuthenticators() { - return $this->_authenticators; + return $this->authenticators; } /** @@ -87,7 +87,7 @@ public function getAuthenticators() */ public function setUsername($username) { - $this->_username = $username; + $this->username = $username; } /** @@ -97,7 +97,7 @@ public function setUsername($username) */ public function getUsername() { - return $this->_username; + return $this->username; } /** @@ -107,7 +107,7 @@ public function getUsername() */ public function setPassword($password) { - $this->_password = $password; + $this->password = $password; } /** @@ -117,7 +117,7 @@ public function setPassword($password) */ public function getPassword() { - return $this->_password; + return $this->password; } /** @@ -127,7 +127,7 @@ public function getPassword() */ public function setAuthMode($mode) { - $this->_auth_mode = $mode; + $this->auth_mode = $mode; } /** @@ -137,7 +137,7 @@ public function setAuthMode($mode) */ public function getAuthMode() { - return $this->_auth_mode; + return $this->auth_mode; } /** @@ -157,7 +157,7 @@ public function getHandledKeyword() */ public function setKeywordParams(array $parameters) { - $this->_esmtpParams = $parameters; + $this->esmtpParams = $parameters; } /** @@ -167,20 +167,20 @@ public function setKeywordParams(array $parameters) */ public function afterEhlo(Swift_Transport_SmtpAgent $agent) { - if ($this->_username) { + if ($this->username) { $count = 0; - foreach ($this->_getAuthenticatorsForAgent() as $authenticator) { + foreach ($this->getAuthenticatorsForAgent() as $authenticator) { if (in_array(strtolower($authenticator->getAuthKeyword()), - array_map('strtolower', $this->_esmtpParams))) { + array_map('strtolower', $this->esmtpParams))) { ++$count; - if ($authenticator->authenticate($agent, $this->_username, $this->_password)) { + if ($authenticator->authenticate($agent, $this->username, $this->password)) { return; } } } throw new Swift_TransportException( 'Failed to authenticate on SMTP server with username "'. - $this->_username.'" using '.$count.' possible authenticators' + $this->username.'" using '.$count.' possible authenticators' ); } } @@ -246,13 +246,13 @@ public function resetState() * * @return array */ - protected function _getAuthenticatorsForAgent() + protected function getAuthenticatorsForAgent() { - if (!$mode = strtolower($this->_auth_mode)) { - return $this->_authenticators; + if (!$mode = strtolower($this->auth_mode)) { + return $this->authenticators; } - foreach ($this->_authenticators as $authenticator) { + foreach ($this->authenticators as $authenticator) { if (strtolower($authenticator->getAuthKeyword()) == $mode) { return array($authenticator); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php index 156e2cf5b..7eb7ef330 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php @@ -20,21 +20,21 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo * * @var Swift_Transport_EsmtpHandler[] */ - private $_handlers = array(); + private $handlers = array(); /** * ESMTP capabilities. * * @var string[] */ - private $_capabilities = array(); + private $capabilities = array(); /** * Connection buffer parameters. * * @var array */ - private $_params = array( + private $params = array( 'protocol' => 'tcp', 'host' => 'localhost', 'port' => 25, @@ -51,10 +51,11 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo * @param Swift_Transport_IoBuffer $buf * @param Swift_Transport_EsmtpHandler[] $extensionHandlers * @param Swift_Events_EventDispatcher $dispatcher + * @param string $localDomain */ - public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher) + public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1') { - parent::__construct($buf, $dispatcher); + parent::__construct($buf, $dispatcher, $localDomain); $this->setExtensionHandlers($extensionHandlers); } @@ -67,7 +68,7 @@ public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandl */ public function setHost($host) { - $this->_params['host'] = $host; + $this->params['host'] = $host; return $this; } @@ -79,7 +80,7 @@ public function setHost($host) */ public function getHost() { - return $this->_params['host']; + return $this->params['host']; } /** @@ -91,7 +92,7 @@ public function getHost() */ public function setPort($port) { - $this->_params['port'] = (int) $port; + $this->params['port'] = (int) $port; return $this; } @@ -103,7 +104,7 @@ public function setPort($port) */ public function getPort() { - return $this->_params['port']; + return $this->params['port']; } /** @@ -115,8 +116,8 @@ public function getPort() */ public function setTimeout($timeout) { - $this->_params['timeout'] = (int) $timeout; - $this->_buffer->setParam('timeout', (int) $timeout); + $this->params['timeout'] = (int) $timeout; + $this->buffer->setParam('timeout', (int) $timeout); return $this; } @@ -128,7 +129,7 @@ public function setTimeout($timeout) */ public function getTimeout() { - return $this->_params['timeout']; + return $this->params['timeout']; } /** @@ -142,11 +143,11 @@ public function setEncryption($encryption) { $encryption = strtolower($encryption); if ('tls' == $encryption) { - $this->_params['protocol'] = 'tcp'; - $this->_params['tls'] = true; + $this->params['protocol'] = 'tcp'; + $this->params['tls'] = true; } else { - $this->_params['protocol'] = $encryption; - $this->_params['tls'] = false; + $this->params['protocol'] = $encryption; + $this->params['tls'] = false; } return $this; @@ -159,7 +160,7 @@ public function setEncryption($encryption) */ public function getEncryption() { - return $this->_params['tls'] ? 'tls' : $this->_params['protocol']; + return $this->params['tls'] ? 'tls' : $this->params['protocol']; } /** @@ -171,7 +172,7 @@ public function getEncryption() */ public function setStreamOptions($options) { - $this->_params['stream_context_options'] = $options; + $this->params['stream_context_options'] = $options; return $this; } @@ -183,7 +184,7 @@ public function setStreamOptions($options) */ public function getStreamOptions() { - return $this->_params['stream_context_options']; + return $this->params['stream_context_options']; } /** @@ -195,7 +196,7 @@ public function getStreamOptions() */ public function setSourceIp($source) { - $this->_params['sourceIp'] = $source; + $this->params['sourceIp'] = $source; return $this; } @@ -207,7 +208,7 @@ public function setSourceIp($source) */ public function getSourceIp() { - return isset($this->_params['sourceIp']) ? $this->_params['sourceIp'] : null; + return $this->params['sourceIp'] ?? null; } /** @@ -223,10 +224,11 @@ public function setExtensionHandlers(array $handlers) foreach ($handlers as $handler) { $assoc[$handler->getHandledKeyword()] = $handler; } - - @uasort($assoc, array($this, '_sortHandlers')); - $this->_handlers = $assoc; - $this->_setHandlerParams(); + uasort($assoc, function ($a, $b) { + return $a->getPriorityOver($b->getHandledKeyword()); + }); + $this->handlers = $assoc; + $this->setHandlerParams(); return $this; } @@ -238,7 +240,7 @@ public function setExtensionHandlers(array $handlers) */ public function getExtensionHandlers() { - return array_values($this->_handlers); + return array_values($this->handlers); } /** @@ -258,7 +260,7 @@ public function executeCommand($command, $codes = array(), &$failures = null) $failures = (array) $failures; $stopSignal = false; $response = null; - foreach ($this->_getActiveHandlers() as $handler) { + foreach ($this->getActiveHandlers() as $handler) { $response = $handler->onCommand( $this, $command, $codes, $failures, $stopSignal ); @@ -273,7 +275,7 @@ public function executeCommand($command, $codes = array(), &$failures = null) /** Mixin handling method for ESMTP handlers */ public function __call($method, $args) { - foreach ($this->_handlers as $handler) { + foreach ($this->handlers as $handler) { if (in_array(strtolower($method), array_map('strtolower', (array) $handler->exposeMixinMethods()) )) { @@ -290,53 +292,53 @@ public function __call($method, $args) } /** Get the params to initialize the buffer */ - protected function _getBufferParams() + protected function getBufferParams() { - return $this->_params; + return $this->params; } /** Overridden to perform EHLO instead */ - protected function _doHeloCommand() + protected function doHeloCommand() { try { $response = $this->executeCommand( - sprintf("EHLO %s\r\n", $this->_domain), array(250) + sprintf("EHLO %s\r\n", $this->domain), array(250) ); } catch (Swift_TransportException $e) { - return parent::_doHeloCommand(); + return parent::doHeloCommand(); } - if ($this->_params['tls']) { + if ($this->params['tls']) { try { $this->executeCommand("STARTTLS\r\n", array(220)); - if (!$this->_buffer->startTLS()) { + if (!$this->buffer->startTLS()) { throw new Swift_TransportException('Unable to connect with TLS encryption'); } try { $response = $this->executeCommand( - sprintf("EHLO %s\r\n", $this->_domain), array(250) + sprintf("EHLO %s\r\n", $this->domain), array(250) ); } catch (Swift_TransportException $e) { - return parent::_doHeloCommand(); + return parent::doHeloCommand(); } } catch (Swift_TransportException $e) { - $this->_throwException($e); + $this->throwException($e); } } - $this->_capabilities = $this->_getCapabilities($response); - $this->_setHandlerParams(); - foreach ($this->_getActiveHandlers() as $handler) { + $this->capabilities = $this->getCapabilities($response); + $this->setHandlerParams(); + foreach ($this->getActiveHandlers() as $handler) { $handler->afterEhlo($this); } } /** Overridden to add Extension support */ - protected function _doMailFromCommand($address) + protected function doMailFromCommand($address) { - $handlers = $this->_getActiveHandlers(); + $handlers = $this->getActiveHandlers(); $params = array(); foreach ($handlers as $handler) { $params = array_merge($params, (array) $handler->getMailParams()); @@ -348,9 +350,9 @@ protected function _doMailFromCommand($address) } /** Overridden to add Extension support */ - protected function _doRcptToCommand($address) + protected function doRcptToCommand($address) { - $handlers = $this->_getActiveHandlers(); + $handlers = $this->getActiveHandlers(); $params = array(); foreach ($handlers as $handler) { $params = array_merge($params, (array) $handler->getRcptParams()); @@ -362,7 +364,7 @@ protected function _doRcptToCommand($address) } /** Determine ESMTP capabilities by function group */ - private function _getCapabilities($ehloResponse) + private function getCapabilities($ehloResponse) { $capabilities = array(); $ehloResponse = trim($ehloResponse); @@ -381,31 +383,25 @@ private function _getCapabilities($ehloResponse) } /** Set parameters which are used by each extension handler */ - private function _setHandlerParams() + private function setHandlerParams() { - foreach ($this->_handlers as $keyword => $handler) { - if (array_key_exists($keyword, $this->_capabilities)) { - $handler->setKeywordParams($this->_capabilities[$keyword]); + foreach ($this->handlers as $keyword => $handler) { + if (array_key_exists($keyword, $this->capabilities)) { + $handler->setKeywordParams($this->capabilities[$keyword]); } } } /** Get ESMTP handlers which are currently ok to use */ - private function _getActiveHandlers() + private function getActiveHandlers() { $handlers = array(); - foreach ($this->_handlers as $keyword => $handler) { - if (array_key_exists($keyword, $this->_capabilities)) { + foreach ($this->handlers as $keyword => $handler) { + if (array_key_exists($keyword, $this->capabilities)) { $handlers[] = $handler; } } return $handlers; } - - /** Custom sort for extension handler ordering */ - private function _sortHandlers($a, $b) - { - return $a->getPriorityOver($b->getHandledKeyword()); - } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php index 311a0f2ad..94151f89f 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php @@ -20,7 +20,7 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran * * @var Swift_Transport */ - private $_currentTransport; + private $currentTransport; // needed as __construct is called from elsewhere explicitly public function __construct() @@ -28,41 +28,59 @@ public function __construct() parent::__construct(); } + /** + * {@inheritdoc} + */ + public function ping() + { + $maxTransports = count($this->transports); + for ($i = 0; $i < $maxTransports + && $transport = $this->getNextTransport(); ++$i) { + if ($transport->ping()) { + return true; + } else { + $this->killCurrentTransport(); + } + } + + return count($this->transports) > 0; + } + /** * Send the given Message. * * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * - * @param Swift_Mime_Message $message + * @param Swift_Mime_SimpleMessage $message * @param string[] $failedRecipients An array of failures by-reference * * @return int */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { - $maxTransports = count($this->_transports); + $maxTransports = count($this->transports); $sent = 0; - $this->_lastUsedTransport = null; + $this->lastUsedTransport = null; for ($i = 0; $i < $maxTransports - && $transport = $this->_getNextTransport(); ++$i) { + && $transport = $this->getNextTransport(); ++$i) { try { if (!$transport->isStarted()) { $transport->start(); } if ($sent = $transport->send($message, $failedRecipients)) { - $this->_lastUsedTransport = $transport; + $this->lastUsedTransport = $transport; return $sent; } } catch (Swift_TransportException $e) { - $this->_killCurrentTransport(); + $this->killCurrentTransport(); } } - if (count($this->_transports) == 0) { + if (count($this->transports) == 0) { throw new Swift_TransportException( 'All Transports in FailoverTransport failed, or no Transports available' ); @@ -71,18 +89,18 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) return $sent; } - protected function _getNextTransport() + protected function getNextTransport() { - if (!isset($this->_currentTransport)) { - $this->_currentTransport = parent::_getNextTransport(); + if (!isset($this->currentTransport)) { + $this->currentTransport = parent::getNextTransport(); } - return $this->_currentTransport; + return $this->currentTransport; } - protected function _killCurrentTransport() + protected function killCurrentTransport() { - $this->_currentTransport = null; - parent::_killCurrentTransport(); + $this->currentTransport = null; + parent::killCurrentTransport(); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php index e2adc567e..dc6a2149b 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php @@ -20,21 +20,21 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport * * @var Swift_Transport[] */ - private $_deadTransports = array(); + private $deadTransports = array(); /** * The Transports which are used in rotation. * * @var Swift_Transport[] */ - protected $_transports = array(); + protected $transports = array(); /** * The Transport used in the last successful send operation. * * @var Swift_Transport */ - protected $_lastUsedTransport = null; + protected $lastUsedTransport = null; // needed as __construct is called from elsewhere explicitly public function __construct() @@ -48,8 +48,8 @@ public function __construct() */ public function setTransports(array $transports) { - $this->_transports = $transports; - $this->_deadTransports = array(); + $this->transports = $transports; + $this->deadTransports = array(); } /** @@ -59,7 +59,7 @@ public function setTransports(array $transports) */ public function getTransports() { - return array_merge($this->_transports, $this->_deadTransports); + return array_merge($this->transports, $this->deadTransports); } /** @@ -69,7 +69,7 @@ public function getTransports() */ public function getLastUsedTransport() { - return $this->_lastUsedTransport; + return $this->lastUsedTransport; } /** @@ -79,7 +79,7 @@ public function getLastUsedTransport() */ public function isStarted() { - return count($this->_transports) > 0; + return count($this->transports) > 0; } /** @@ -87,7 +87,7 @@ public function isStarted() */ public function start() { - $this->_transports = array_merge($this->_transports, $this->_deadTransports); + $this->transports = array_merge($this->transports, $this->deadTransports); } /** @@ -95,44 +95,58 @@ public function start() */ public function stop() { - foreach ($this->_transports as $transport) { + foreach ($this->transports as $transport) { $transport->stop(); } } + /** + * {@inheritdoc} + */ + public function ping() + { + foreach ($this->transports as $transport) { + if (!$transport->ping()) { + $this->killCurrentTransport(); + } + } + + return count($this->transports) > 0; + } + /** * Send the given Message. * * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * - * @param Swift_Mime_Message $message + * @param Swift_Mime_SimpleMessage $message * @param string[] $failedRecipients An array of failures by-reference * * @return int */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { - $maxTransports = count($this->_transports); + $maxTransports = count($this->transports); $sent = 0; - $this->_lastUsedTransport = null; + $this->lastUsedTransport = null; for ($i = 0; $i < $maxTransports - && $transport = $this->_getNextTransport(); ++$i) { + && $transport = $this->getNextTransport(); ++$i) { try { if (!$transport->isStarted()) { $transport->start(); } if ($sent = $transport->send($message, $failedRecipients)) { - $this->_lastUsedTransport = $transport; + $this->lastUsedTransport = $transport; break; } } catch (Swift_TransportException $e) { - $this->_killCurrentTransport(); + $this->killCurrentTransport(); } } - if (count($this->_transports) == 0) { + if (count($this->transports) == 0) { throw new Swift_TransportException( 'All Transports in LoadBalancedTransport failed, or no Transports available' ); @@ -148,7 +162,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) */ public function registerPlugin(Swift_Events_EventListener $plugin) { - foreach ($this->_transports as $transport) { + foreach ($this->transports as $transport) { $transport->registerPlugin($plugin); } } @@ -158,10 +172,10 @@ public function registerPlugin(Swift_Events_EventListener $plugin) * * @return Swift_Transport */ - protected function _getNextTransport() + protected function getNextTransport() { - if ($next = array_shift($this->_transports)) { - $this->_transports[] = $next; + if ($next = array_shift($this->transports)) { + $this->transports[] = $next; } return $next; @@ -170,14 +184,14 @@ protected function _getNextTransport() /** * Tag the currently used (top of stack) transport as dead/useless. */ - protected function _killCurrentTransport() + protected function killCurrentTransport() { - if ($transport = array_pop($this->_transports)) { + if ($transport = array_pop($this->transports)) { try { $transport->stop(); } catch (Exception $e) { } - $this->_deadTransports[] = $transport; + $this->deadTransports[] = $transport; } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php deleted file mode 100644 index 77489cedc..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php +++ /dev/null @@ -1,32 +0,0 @@ -_invoker = $invoker; - $this->_eventDispatcher = $eventDispatcher; - } - - /** - * Not used. - */ - public function isStarted() - { - return false; - } - - /** - * Not used. - */ - public function start() - { - } - - /** - * Not used. - */ - public function stop() - { - } - - /** - * Set the additional parameters used on the mail() function. - * - * This string is formatted for sprintf() where %s is the sender address. - * - * @param string $params - * - * @return $this - */ - public function setExtraParams($params) - { - $this->_extraParams = $params; - - return $this; - } - - /** - * Get the additional parameters used on the mail() function. - * - * This string is formatted for sprintf() where %s is the sender address. - * - * @return string - */ - public function getExtraParams() - { - return $this->_extraParams; - } - - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * The return value is the number of recipients who were accepted for delivery. - * - * @param Swift_Mime_Message $message - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) - { - $failedRecipients = (array) $failedRecipients; - - if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { - $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); - if ($evt->bubbleCancelled()) { - return 0; - } - } - - $count = ( - count((array) $message->getTo()) - + count((array) $message->getCc()) - + count((array) $message->getBcc()) - ); - - $toHeader = $message->getHeaders()->get('To'); - $subjectHeader = $message->getHeaders()->get('Subject'); - - if (0 === $count) { - $this->_throwException(new Swift_TransportException('Cannot send message without a recipient')); - } - $to = $toHeader ? $toHeader->getFieldBody() : ''; - $subject = $subjectHeader ? $subjectHeader->getFieldBody() : ''; - - $reversePath = $this->_getReversePath($message); - - // Remove headers that would otherwise be duplicated - $message->getHeaders()->remove('To'); - $message->getHeaders()->remove('Subject'); - - $messageStr = $message->toString(); - - if ($toHeader) { - $message->getHeaders()->set($toHeader); - } - $message->getHeaders()->set($subjectHeader); - - // Separate headers from body - if (false !== $endHeaders = strpos($messageStr, "\r\n\r\n")) { - $headers = substr($messageStr, 0, $endHeaders)."\r\n"; //Keep last EOL - $body = substr($messageStr, $endHeaders + 4); - } else { - $headers = $messageStr."\r\n"; - $body = ''; - } - - unset($messageStr); - - if ("\r\n" != PHP_EOL) { - // Non-windows (not using SMTP) - $headers = str_replace("\r\n", PHP_EOL, $headers); - $subject = str_replace("\r\n", PHP_EOL, $subject); - $body = str_replace("\r\n", PHP_EOL, $body); - $to = str_replace("\r\n", PHP_EOL, $to); - } else { - // Windows, using SMTP - $headers = str_replace("\r\n.", "\r\n..", $headers); - $subject = str_replace("\r\n.", "\r\n..", $subject); - $body = str_replace("\r\n.", "\r\n..", $body); - $to = str_replace("\r\n.", "\r\n..", $to); - } - - if ($this->_invoker->mail($to, $subject, $body, $headers, $this->_formatExtraParams($this->_extraParams, $reversePath))) { - if ($evt) { - $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); - $evt->setFailedRecipients($failedRecipients); - $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } - } else { - $failedRecipients = array_merge( - $failedRecipients, - array_keys((array) $message->getTo()), - array_keys((array) $message->getCc()), - array_keys((array) $message->getBcc()) - ); - - if ($evt) { - $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); - $evt->setFailedRecipients($failedRecipients); - $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } - - $message->generateId(); - - $count = 0; - } - - return $count; - } - - /** - * Register a plugin. - * - * @param Swift_Events_EventListener $plugin - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - $this->_eventDispatcher->bindEventListener($plugin); - } - - /** Throw a TransportException, first sending it to any listeners */ - protected function _throwException(Swift_TransportException $e) - { - if ($evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e)) { - $this->_eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); - if (!$evt->bubbleCancelled()) { - throw $e; - } - } else { - throw $e; - } - } - - /** Determine the best-use reverse path for this message */ - private function _getReversePath(Swift_Mime_Message $message) - { - $return = $message->getReturnPath(); - $sender = $message->getSender(); - $from = $message->getFrom(); - $path = null; - if (!empty($return)) { - $path = $return; - } elseif (!empty($sender)) { - $keys = array_keys($sender); - $path = array_shift($keys); - } elseif (!empty($from)) { - $keys = array_keys($from); - $path = array_shift($keys); - } - - return $path; - } - - /** - * Fix CVE-2016-10074 by disallowing potentially unsafe shell characters. - * - * Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows. - * - * @param string $string The string to be validated - * - * @return bool - */ - private function _isShellSafe($string) - { - // Future-proof - if (escapeshellcmd($string) !== $string || !in_array(escapeshellarg($string), array("'$string'", "\"$string\""))) { - return false; - } - - $length = strlen($string); - for ($i = 0; $i < $length; ++$i) { - $c = $string[$i]; - // All other characters have a special meaning in at least one common shell, including = and +. - // Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here. - // Note that this does permit non-Latin alphanumeric characters based on the current locale. - if (!ctype_alnum($c) && strpos('@_-.', $c) === false) { - return false; - } - } - - return true; - } - - /** - * Return php mail extra params to use for invoker->mail. - * - * @param $extraParams - * @param $reversePath - * - * @return string|null - */ - private function _formatExtraParams($extraParams, $reversePath) - { - if (false !== strpos($extraParams, '-f%s')) { - if (empty($reversePath) || false === $this->_isShellSafe($reversePath)) { - $extraParams = str_replace('-f%s', '', $extraParams); - } else { - $extraParams = sprintf($extraParams, $reversePath); - } - } - - return !empty($extraParams) ? $extraParams : null; - } -} diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php index ad20e0e53..dc38078c3 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php @@ -16,14 +16,14 @@ class Swift_Transport_NullTransport implements Swift_Transport { /** The event dispatcher from the plugin API */ - private $_eventDispatcher; + private $eventDispatcher; /** * Constructor. */ public function __construct(Swift_Events_EventDispatcher $eventDispatcher) { - $this->_eventDispatcher = $eventDispatcher; + $this->eventDispatcher = $eventDispatcher; } /** @@ -50,18 +50,26 @@ public function stop() { } + /** + * {@inheritdoc} + */ + public function ping() + { + return true; + } + /** * Sends the given message. * - * @param Swift_Mime_Message $message + * @param Swift_Mime_SimpleMessage $message * @param string[] $failedRecipients An array of failures by-reference * * @return int The number of sent emails */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { - if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { - $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); if ($evt->bubbleCancelled()) { return 0; } @@ -69,7 +77,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) if ($evt) { $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); - $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); } $count = ( @@ -88,6 +96,6 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) */ public function registerPlugin(Swift_Events_EventListener $plugin) { - $this->_eventDispatcher->bindEventListener($plugin); + $this->eventDispatcher->bindEventListener($plugin); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php index 6430d5f6b..807538505 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php @@ -24,7 +24,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran * * @var array */ - private $_params = array( + private $params = array( 'timeout' => 30, 'blocking' => 1, 'command' => '/usr/sbin/sendmail -bs', @@ -36,10 +36,11 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran * * @param Swift_Transport_IoBuffer $buf * @param Swift_Events_EventDispatcher $dispatcher + * @param string $localDomain */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher) + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1') { - parent::__construct($buf, $dispatcher); + parent::__construct($buf, $dispatcher, $localDomain); } /** @@ -68,7 +69,7 @@ public function start() */ public function setCommand($command) { - $this->_params['command'] = $command; + $this->params['command'] = $command; return $this; } @@ -80,7 +81,7 @@ public function setCommand($command) */ public function getCommand() { - return $this->_params['command']; + return $this->params['command']; } /** @@ -92,12 +93,12 @@ public function getCommand() * NOTE: If using 'sendmail -t' you will not be aware of any failures until * they bounce (i.e. send() will always return 100% success). * - * @param Swift_Mime_Message $message + * @param Swift_Mime_SimpleMessage $message * @param string[] $failedRecipients An array of failures by-reference * * @return int */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { $failedRecipients = (array) $failedRecipients; $command = $this->getCommand(); @@ -105,18 +106,18 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $count = 0; if (false !== strpos($command, ' -t')) { - if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { - $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); if ($evt->bubbleCancelled()) { return 0; } } if (false === strpos($command, ' -f')) { - $command .= ' -f'.escapeshellarg($this->_getReversePath($message)); + $command .= ' -f'.escapeshellarg($this->getReversePath($message)); } - $buffer->initialize(array_merge($this->_params, array('command' => $command))); + $buffer->initialize(array_merge($this->params, array('command' => $command))); if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) { $buffer->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n..")); @@ -136,14 +137,14 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) if ($evt) { $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); $evt->setFailedRecipients($failedRecipients); - $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); } $message->generateId(); } elseif (false !== strpos($command, ' -bs')) { $count = parent::send($message, $failedRecipients); } else { - $this->_throwException(new Swift_TransportException( + $this->throwException(new Swift_TransportException( 'Unsupported sendmail command flags ['.$command.']. '. 'Must be one of "-bs" or "-t" but can include additional flags.' )); @@ -153,8 +154,8 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) } /** Get the params to initialize the buffer */ - protected function _getBufferParams() + protected function getBufferParams() { - return $this->_params; + return $this->params; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php deleted file mode 100644 index 4cab66bd6..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php +++ /dev/null @@ -1,39 +0,0 @@ -_eventDispatcher = $eventDispatcher; - $this->_spool = $spool; + $this->eventDispatcher = $eventDispatcher; + $this->spool = $spool; } /** @@ -39,7 +39,7 @@ public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift */ public function setSpool(Swift_Spool $spool) { - $this->_spool = $spool; + $this->spool = $spool; return $this; } @@ -51,7 +51,7 @@ public function setSpool(Swift_Spool $spool) */ public function getSpool() { - return $this->_spool; + return $this->spool; } /** @@ -78,28 +78,36 @@ public function stop() { } + /** + * {@inheritdoc} + */ + public function ping() + { + return true; + } + /** * Sends the given message. * - * @param Swift_Mime_Message $message + * @param Swift_Mime_SimpleMessage $message * @param string[] $failedRecipients An array of failures by-reference * * @return int The number of sent e-mail's */ - public function send(Swift_Mime_Message $message, &$failedRecipients = null) + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { - if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { - $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); if ($evt->bubbleCancelled()) { return 0; } } - $success = $this->_spool->queueMessage($message); + $success = $this->spool->queueMessage($message); if ($evt) { $evt->setResult($success ? Swift_Events_SendEvent::RESULT_SPOOLED : Swift_Events_SendEvent::RESULT_FAILED); - $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); } return 1; @@ -112,6 +120,6 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) */ public function registerPlugin(Swift_Events_EventListener $plugin) { - $this->_eventDispatcher->bindEventListener($plugin); + $this->eventDispatcher->bindEventListener($plugin); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php index 9f2fff4bf..bc6ed5a34 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php @@ -11,27 +11,27 @@ /** * A generic IoBuffer implementation supporting remote sockets and local processes. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_Transport_IoBuffer { /** A primary socket */ - private $_stream; + private $stream; /** The input stream */ - private $_in; + private $in; /** The output stream */ - private $_out; + private $out; /** Buffer initialization parameters */ - private $_params = array(); + private $params = array(); /** The ReplacementFilterFactory */ - private $_replacementFactory; + private $replacementFactory; /** Translations performed on data being streamed into the buffer */ - private $_translations = array(); + private $translations = array(); /** * Create a new StreamBuffer using $replacementFactory for transformations. @@ -40,7 +40,7 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn */ public function __construct(Swift_ReplacementFilterFactory $replacementFactory) { - $this->_replacementFactory = $replacementFactory; + $this->replacementFactory = $replacementFactory; } /** @@ -52,14 +52,14 @@ public function __construct(Swift_ReplacementFilterFactory $replacementFactory) */ public function initialize(array $params) { - $this->_params = $params; + $this->params = $params; switch ($params['type']) { case self::TYPE_PROCESS: - $this->_establishProcessConnection(); + $this->establishProcessConnection(); break; case self::TYPE_SOCKET: default: - $this->_establishSocketConnection(); + $this->establishSocketConnection(); break; } } @@ -72,26 +72,26 @@ public function initialize(array $params) */ public function setParam($param, $value) { - if (isset($this->_stream)) { + if (isset($this->stream)) { switch ($param) { case 'timeout': - if ($this->_stream) { - stream_set_timeout($this->_stream, $value); + if ($this->stream) { + stream_set_timeout($this->stream, $value); } break; case 'blocking': - if ($this->_stream) { - stream_set_blocking($this->_stream, 1); + if ($this->stream) { + stream_set_blocking($this->stream, 1); } } } - $this->_params[$param] = $value; + $this->params[$param] = $value; } public function startTLS() { - return stream_socket_enable_crypto($this->_stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); + return stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); } /** @@ -99,22 +99,22 @@ public function startTLS() */ public function terminate() { - if (isset($this->_stream)) { - switch ($this->_params['type']) { + if (isset($this->stream)) { + switch ($this->params['type']) { case self::TYPE_PROCESS: - fclose($this->_in); - fclose($this->_out); - proc_close($this->_stream); + fclose($this->in); + fclose($this->out); + proc_close($this->stream); break; case self::TYPE_SOCKET: default: - fclose($this->_stream); + fclose($this->stream); break; } } - $this->_stream = null; - $this->_out = null; - $this->_in = null; + $this->stream = null; + $this->out = null; + $this->in = null; } /** @@ -127,19 +127,19 @@ public function terminate() */ public function setWriteTranslations(array $replacements) { - foreach ($this->_translations as $search => $replace) { + foreach ($this->translations as $search => $replace) { if (!isset($replacements[$search])) { $this->removeFilter($search); - unset($this->_translations[$search]); + unset($this->translations[$search]); } } foreach ($replacements as $search => $replace) { - if (!isset($this->_translations[$search])) { + if (!isset($this->translations[$search])) { $this->addFilter( - $this->_replacementFactory->createFilter($search, $replace), $search + $this->replacementFactory->createFilter($search, $replace), $search ); - $this->_translations[$search] = true; + $this->translations[$search] = true; } } } @@ -152,20 +152,20 @@ public function setWriteTranslations(array $replacements) * * @param int $sequence of last write to scan from * - * @throws Swift_IoException - * * @return string + * + * @throws Swift_IoException */ public function readLine($sequence) { - if (isset($this->_out) && !feof($this->_out)) { - $line = fgets($this->_out); + if (isset($this->out) && !feof($this->out)) { + $line = fgets($this->out); if (strlen($line) == 0) { - $metas = stream_get_meta_data($this->_out); + $metas = stream_get_meta_data($this->out); if ($metas['timed_out']) { throw new Swift_IoException( 'Connection to '. - $this->_getReadConnectionDescription(). + $this->getReadConnectionDescription(). ' Timed Out' ); } @@ -184,20 +184,20 @@ public function readLine($sequence) * * @param int $length * - * @throws Swift_IoException - * * @return string|bool + * + * @throws Swift_IoException */ public function read($length) { - if (isset($this->_out) && !feof($this->_out)) { - $ret = fread($this->_out, $length); + if (isset($this->out) && !feof($this->out)) { + $ret = fread($this->out, $length); if (strlen($ret) == 0) { - $metas = stream_get_meta_data($this->_out); + $metas = stream_get_meta_data($this->out); if ($metas['timed_out']) { throw new Swift_IoException( 'Connection to '. - $this->_getReadConnectionDescription(). + $this->getReadConnectionDescription(). ' Timed Out' ); } @@ -213,22 +213,22 @@ public function setReadPointer($byteOffset) } /** Flush the stream contents */ - protected function _flush() + protected function flush() { - if (isset($this->_in)) { - fflush($this->_in); + if (isset($this->in)) { + fflush($this->in); } } /** Write this bytes to the stream */ - protected function _commit($bytes) + protected function doCommit($bytes) { - if (isset($this->_in)) { + if (isset($this->in)) { $bytesToWrite = strlen($bytes); $totalBytesWritten = 0; while ($totalBytesWritten < $bytesToWrite) { - $bytesWritten = fwrite($this->_in, substr($bytes, $totalBytesWritten)); + $bytesWritten = fwrite($this->in, substr($bytes, $totalBytesWritten)); if (false === $bytesWritten || 0 === $bytesWritten) { break; } @@ -237,7 +237,7 @@ protected function _commit($bytes) } if ($totalBytesWritten > 0) { - return ++$this->_sequence; + return ++$this->sequence; } } } @@ -245,78 +245,79 @@ protected function _commit($bytes) /** * Establishes a connection to a remote server. */ - private function _establishSocketConnection() + private function establishSocketConnection() { - $host = $this->_params['host']; - if (!empty($this->_params['protocol'])) { - $host = $this->_params['protocol'].'://'.$host; + $host = $this->params['host']; + if (!empty($this->params['protocol'])) { + $host = $this->params['protocol'].'://'.$host; } $timeout = 15; - if (!empty($this->_params['timeout'])) { - $timeout = $this->_params['timeout']; + if (!empty($this->params['timeout'])) { + $timeout = $this->params['timeout']; } $options = array(); - if (!empty($this->_params['sourceIp'])) { - $options['socket']['bindto'] = $this->_params['sourceIp'].':0'; + if (!empty($this->params['sourceIp'])) { + $options['socket']['bindto'] = $this->params['sourceIp'].':0'; } - if (isset($this->_params['stream_context_options'])) { - $options = array_merge($options, $this->_params['stream_context_options']); + + if (isset($this->params['stream_context_options'])) { + $options = array_merge($options, $this->params['stream_context_options']); } $streamContext = stream_context_create($options); - $this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); - if (false === $this->_stream) { + $this->stream = @stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); + if (false === $this->stream) { throw new Swift_TransportException( - 'Connection could not be established with host '.$this->_params['host']. + 'Connection could not be established with host '.$this->params['host']. ' ['.$errstr.' #'.$errno.']' ); } - if (!empty($this->_params['blocking'])) { - stream_set_blocking($this->_stream, 1); + if (!empty($this->params['blocking'])) { + stream_set_blocking($this->stream, 1); } else { - stream_set_blocking($this->_stream, 0); + stream_set_blocking($this->stream, 0); } - stream_set_timeout($this->_stream, $timeout); - $this->_in = &$this->_stream; - $this->_out = &$this->_stream; + stream_set_timeout($this->stream, $timeout); + $this->in = &$this->stream; + $this->out = &$this->stream; } /** * Opens a process for input/output. */ - private function _establishProcessConnection() + private function establishProcessConnection() { - $command = $this->_params['command']; + $command = $this->params['command']; $descriptorSpec = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'), ); $pipes = array(); - $this->_stream = proc_open($command, $descriptorSpec, $pipes); + $this->stream = proc_open($command, $descriptorSpec, $pipes); stream_set_blocking($pipes[2], 0); if ($err = stream_get_contents($pipes[2])) { throw new Swift_TransportException( 'Process could not be started ['.$err.']' ); } - $this->_in = &$pipes[0]; - $this->_out = &$pipes[1]; + $this->in = &$pipes[0]; + $this->out = &$pipes[1]; } - private function _getReadConnectionDescription() + private function getReadConnectionDescription() { - switch ($this->_params['type']) { + switch ($this->params['type']) { case self::TYPE_PROCESS: - return 'Process '.$this->_params['command']; + return 'Process '.$this->params['command']; break; case self::TYPE_SOCKET: default: - $host = $this->_params['host']; - if (!empty($this->_params['protocol'])) { - $host = $this->_params['protocol'].'://'.$host; + $host = $this->params['host']; + if (!empty($this->params['protocol'])) { + $host = $this->params['protocol'].'://'.$host; } - $host .= ':'.$this->_params['port']; + $host .= ':'.$this->params['port']; return $host; break; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Validate.php b/swiftmailer/swiftmailer/lib/classes/Swift/Validate.php deleted file mode 100644 index e16c212c4..000000000 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Validate.php +++ /dev/null @@ -1,43 +0,0 @@ - - */ -class Swift_Validate -{ - /** - * Grammar Object. - * - * @var Swift_Mime_Grammar - */ - private static $grammar = null; - - /** - * Checks if an e-mail address matches the current grammars. - * - * @param string $email - * - * @return bool - */ - public static function email($email) - { - if (self::$grammar === null) { - self::$grammar = Swift_DependencyContainer::getInstance() - ->lookup('mime.grammar'); - } - - return (bool) preg_match( - '/^'.self::$grammar->getDefinition('addr-spec').'$/D', - $email - ); - } -} diff --git a/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php b/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php index d575e4f2d..4ce9c7cbb 100644 --- a/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php +++ b/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php @@ -6,8 +6,20 @@ ->register('properties.charset') ->asValue('utf-8') - ->register('mime.grammar') - ->asSharedInstanceOf('Swift_Mime_Grammar') + ->register('email.validator') + ->asSharedInstanceOf('Egulias\EmailValidator\EmailValidator') + + ->register('mime.idgenerator.idright') + // As SERVER_NAME can come from the user in certain configurations, check that + // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use + // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. + ->asValue(!empty($_SERVER['SERVER_NAME']) && preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) === '' ? $_SERVER['SERVER_NAME'] : 'swift.generated') + + ->register('mime.idgenerator') + ->asSharedInstanceOf('Swift_Mime_IdGenerator') + ->withDependencies(array( + 'mime.idgenerator.idright', + )) ->register('mime.message') ->asNewInstanceOf('Swift_Mime_SimpleMessage') @@ -15,7 +27,7 @@ 'mime.headerset', 'mime.qpcontentencoder', 'cache', - 'mime.grammar', + 'mime.idgenerator', 'properties.charset', )) @@ -25,7 +37,7 @@ 'mime.headerset', 'mime.qpcontentencoder', 'cache', - 'mime.grammar', + 'mime.idgenerator', 'properties.charset', )) @@ -35,7 +47,7 @@ 'mime.headerset', 'mime.base64contentencoder', 'cache', - 'mime.grammar', + 'mime.idgenerator', )) ->addConstructorValue($swift_mime_types) @@ -45,7 +57,7 @@ 'mime.headerset', 'mime.base64contentencoder', 'cache', - 'mime.grammar', + 'mime.idgenerator', )) ->addConstructorValue($swift_mime_types) @@ -54,7 +66,7 @@ ->withDependencies(array( 'mime.qpheaderencoder', 'mime.rfc2231encoder', - 'mime.grammar', + 'email.validator', 'properties.charset', )) @@ -93,7 +105,7 @@ ->withDependencies(array('properties.charset')) ->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder') - ->register('mime.qpcontentencoderproxy') + ->register('mime.qpcontentencoder') ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy') ->withDependencies(array('mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset')) @@ -113,11 +125,6 @@ ->register('mime.rfc2231encoder') ->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder') ->withDependencies(array('mime.charstream')) - - // As of PHP 5.4.7, the quoted_printable_encode() function behaves correctly. - // see https://github.com/php/php-src/commit/18bb426587d62f93c54c40bf8535eb8416603629 - ->register('mime.qpcontentencoder') - ->asAliasOf(PHP_VERSION_ID >= 50407 ? 'mime.qpcontentencoderproxy' : 'mime.safeqpcontentencoder') ; unset($swift_mime_types); diff --git a/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php b/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php index 77e432cfa..15772abb2 100644 --- a/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php +++ b/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php @@ -1,12 +1,19 @@ register('transport.localdomain') + // As SERVER_NAME can come from the user in certain configurations, check that + // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use + // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. + ->asValue(!empty($_SERVER['SERVER_NAME']) && preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) === '' ? trim($_SERVER['SERVER_NAME'], '[]') : '127.0.0.1') + ->register('transport.smtp') ->asNewInstanceOf('Swift_Transport_EsmtpTransport') ->withDependencies(array( 'transport.buffer', array('transport.authhandler'), 'transport.eventdispatcher', + 'transport.localdomain', )) ->register('transport.sendmail') @@ -14,12 +21,9 @@ ->withDependencies(array( 'transport.buffer', 'transport.eventdispatcher', + 'transport.localdomain', )) - ->register('transport.mail') - ->asNewInstanceOf('Swift_Transport_MailTransport') - ->withDependencies(array('transport.mailinvoker', 'transport.eventdispatcher')) - ->register('transport.loadbalanced') ->asNewInstanceOf('Swift_Transport_LoadBalancedTransport') @@ -34,9 +38,6 @@ ->asNewInstanceOf('Swift_Transport_NullTransport') ->withDependencies(array('transport.eventdispatcher')) - ->register('transport.mailinvoker') - ->asSharedInstanceOf('Swift_Transport_SimpleMailInvoker') - ->register('transport.buffer') ->asNewInstanceOf('Swift_Transport_StreamBuffer') ->withDependencies(array('transport.replacementfactory')) diff --git a/swiftmailer/swiftmailer/lib/mime_types.php b/swiftmailer/swiftmailer/lib/mime_types.php index 2d7b98dc1..b42c1cc1a 100644 --- a/swiftmailer/swiftmailer/lib/mime_types.php +++ b/swiftmailer/swiftmailer/lib/mime_types.php @@ -7,7 +7,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * - * autogenerated using http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types + * autogenerated using https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types * and https://raw.github.com/minad/mimemagic/master/script/freedesktop.org.xml */ diff --git a/swiftmailer/swiftmailer/lib/preferences.php b/swiftmailer/swiftmailer/lib/preferences.php index 0b430e67d..27b7065db 100644 --- a/swiftmailer/swiftmailer/lib/preferences.php +++ b/swiftmailer/swiftmailer/lib/preferences.php @@ -17,9 +17,3 @@ if (@is_writable($tmpDir = sys_get_temp_dir())) { $preferences->setTempDir($tmpDir)->setCacheType('disk'); } - -// this should only be done when Swiftmailer won't use the native QP content encoder -// see mime_deps.php -if (PHP_VERSION_ID < 50407) { - $preferences->setQPDotEscape(false); -} diff --git a/swiftmailer/swiftmailer/lib/swift_init.php b/swiftmailer/swiftmailer/lib/swift_init.php deleted file mode 100644 index ff7196344..000000000 --- a/swiftmailer/swiftmailer/lib/swift_init.php +++ /dev/null @@ -1,28 +0,0 @@ - 'audio/wav', 'wma' => 'audio/x-ms-wma', 'wmv' => 'audio/x-ms-wmv', - 'xls' => 'application/excel', + 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xml' => 'application/xml', );