8000 [Notifier] [Discord] Fix value limits · symfony/symfony@02e27fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 02e27fb

Browse files
committed
[Notifier] [Discord] Fix value limits
1 parent 368bfb7 commit 02e27fb

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

src/Symfony/Component/Notifier/Bridge/Discord/Embeds/DiscordAuthorEmbedObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class DiscordAuthorEmbedObject extends AbstractDiscordEmbedObject
2525
*/
2626
public function name(string $name): static
2727
{
28-
if (\strlen($name) > self::NAME_LIMIT) {
28+
if (mb_strlen($name, 'UTF-8') > self::NAME_LIMIT) {
2929
throw new LengthException(sprintf('Maximum length for the name is %d characters.', self::NAME_LIMIT));
3030
}
3131

src/Symfony/Component/Notifier/Bridge/Discord/Embeds/DiscordEmbed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class DiscordEmbed extends AbstractDiscordEmbed
2727
*/
2828
public function title(string $title): static
2929
{
30-
if (\strlen($title) > self::TITLE_LIMIT) {
30+
if (mb_strlen($title, 'UTF-8') > self::TITLE_LIMIT) {
3131
throw new LengthException(sprintf('Maximum length for the title is %d characters.', self::TITLE_LIMIT));
3232
}
3333

@@ -41,7 +41,7 @@ public function title(string $title): static
4141
*/
4242
public function description(string $description): static
4343
{
44-
if (\strlen($description) > self::DESCRIPTION_LIMIT) {
44+
if (mb_strlen($description, 'UTF-8') > self::DESCRIPTION_LIMIT) {
4545
throw new LengthException(sprintf('Maximum length for the description is %d characters.', self::DESCRIPTION_LIMIT));
4646
}
4747

src/Symfony/Component/Notifier/Bridge/Discord/Embeds/DiscordFieldEmbedObject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class DiscordFieldEmbedObject extends AbstractDiscordEmbedObject
2626
*/
2727
public function name(string $name): static
2828
{
29-
if (\strlen($name) > self::NAME_LIMIT) {
29+
if (mb_strlen($name, 'UTF-8') > self::NAME_LIMIT) {
3030
throw new LengthException(sprintf('Maximum length for the name is %d characters.', self::NAME_LIMIT));
3131
}
3232

@@ -40,7 +40,7 @@ public function name(string $name): static
4040
*/
4141
public function value(string $value): static
4242
{
43-
if (\strlen($value) > self::VALUE_LIMIT) {
43+
if (mb_strlen($value, 'UTF-8') > self::VALUE_LIMIT) {
4444
throw new LengthException(sprintf('Maximum length for the value is %d characters.', self::VALUE_LIMIT));
4545
}
4646

src/Symfony/Component/Notifier/Bridge/Discord/Embeds/DiscordFooterEmbedObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class DiscordFooterEmbedObject extends AbstractDiscordEmbedObject
2525
*/
2626
public function text(string $text): static
2727
{
28-
if (\strlen($text) > self::TEXT_LIMIT) {
28+
if (mb_strlen($text, 'UTF-8') > self::TEXT_LIMIT) {
2929
throw new LengthException(sprintf('Maximum length for the text is %d characters.', self::TEXT_LIMIT));
3030
}
3131

src/Symfony/Component/Notifier/Bridge/Discord/Tests/Embeds/DiscordAuthorEmbedObjectTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public function testThrowsWhenNameExceedsCharacterLimit()
3838
$this->expectException(LengthException::class);
3939
$this->expectExceptionMessage('Maximum length for the name is 256 characters.');
4040

41-
(new DiscordAuthorEmbedObject())->name(str_repeat('h', 257));
41+
(new DiscordAuthorEmbedObject())->name(str_repeat('š', 257));
4242
}
4343
}

src/Symfony/Component/Notifier/Bridge/Discord/Tests/Embeds/DiscordEmbedTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public function testThrowsWhenTitleExceedsCharacterLimit()
4545
$this->expectException(LengthException::class);
4646
$this->expectExceptionMessage('Maximum length for the title is 256 characters.');
4747

48-
(new DiscordEmbed())->title(str_repeat('h', 257));
48+
(new DiscordEmbed())->title(str_repeat('š', 257));
4949
}
5050

5151
public function testThrowsWhenDescriptionExceedsCharacterLimit()
5252
{
5353
$this->expectException(LengthException::class);
5454
$this->expectExceptionMessage('Maximum length for the description is 4096 characters.');
5555

56-
(new DiscordEmbed())->description(str_repeat('h', 4097));
56+
(new DiscordEmbed())->description(str_repeat('š', 4097));
5757
}
5858

5959
public function testThrowsWhenFieldsLimitReached()

src/Symfony/Component/Notifier/Bridge/Discord/Tests/Embeds/DiscordFieldEmbedObjectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ public function testThrowsWhenNameExceedsCharacterLimit()
3636
$this->expectException(LengthException::class);
3737
$this->expectExceptionMessage('Maximum length for the name is 256 characters.');
38 A3E2 38

39-
(new DiscordFieldEmbedObject())->name(str_repeat('h', 257));
39+
(new DiscordFieldEmbedObject())->name(str_repeat('š', 257));
4040
}
4141

4242
public function testThrowsWhenValueExceedsCharacterLimit()
4343
{
4444
$this->expectException(LengthException::class);
4545
$this->expectExceptionMessage('Maximum length for the value is 1024 characters.');
4646

47-
(new DiscordFieldEmbedObject())->value(str_repeat('h', 1025));
47+
(new DiscordFieldEmbedObject())->value(str_repeat('š', 1025));
4848
}
4949
}

src/Symfony/Component/Notifier/Bridge/Discord/Tests/Embeds/DiscordFooterEmbedObjectTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public function testThrowsWhenTextExceedsCharacterLimit()
3636
$this->expectException(LengthException::class);
3737
$this->expectExceptionMessage('Maximum length for the text is 2048 characters.');
3838

39-
(new DiscordFooterEmbedObject())->text(str_repeat('h', 2049));
39+
(new DiscordFooterEmbedObject())->text(str_repeat('š', 2049));
4040
}
4141
}

0 commit comments

Comments
 (0)
0