-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug/missing square bracket escape gsm7 (#367)
* Fix regex * Fixed regex by using character encoding * Composer didn't like php-http discovery
- Loading branch information
Showing
4 changed files
with
10 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
|
||
class SMS extends OutboundMessage | ||
{ | ||
public const GSM_7_PATTERN = '/\A[\n\f\r !\"\#$%&\'()*+,-.\/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\\^_abcdefghijklmnopqrstuvwxyz{\|}~ ¡£¤¥§¿ÄÅÆÇÉÑÖØÜßàäåæèéìñòöøùüΓΔΘΛΞΠΣΦΨΩ€]*\z/m'; | ||
public const GSM_7_CHARSET = "\n\f\r !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~ ¡£¤¥§¿ÄÅÆÇÉÑÖØÜßàäåæèéìñòöøùüΓΔΘΛΞΠΣΦΨΩ€"; | ||
|
||
protected ?string $contentId; | ||
|
||
|
@@ -32,7 +32,8 @@ public function __construct(string $to, string $from, protected string $message, | |
|
||
public static function isGsm7(string $message): bool | ||
{ | ||
return (bool)preg_match(self::GSM_7_PATTERN, $message); | ||
$fullPattern = "/\A[" . preg_quote(self::GSM_7_CHARSET, '/') . "]*\z/"; | ||
return (bool)preg_match($fullPattern, $message); | ||
} | ||
|
||
public function getContentId(): string | ||
|
@@ -68,7 +69,7 @@ public function getErrorMessage(): ?string | |
|
||
if ($this->getType() === 'text' && ! self::isGsm7($this->getMessage())) { | ||
$this->setErrorMessage("You are sending a message as `text` when contains unicode only | ||
characters. This could result in encoding problems with the target device or increased billing - See | ||
characters. This could result in encoding problems with the target device - See | ||
https://developer.vonage.com/messaging/sms for details, or email [email protected] if you have any | ||
questions."); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,7 +413,7 @@ public function testThrowsWarningWhenSendingUnicodeAsText(): void | |
|
||
$this->expectWarning(); | ||
$this->expectErrorMessage("You are sending a message as `text` when contains unicode only | ||
characters. This could result in encoding problems with the target device or increased billing - See | ||
characters. This could result in encoding problems with the target device - See | ||
https://developer.vonage.com/messaging/sms for details, or email [email protected] if you have any | ||
questions."); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters