Skip to content

[Notifier] [Discord] Use private const and mb_strlen() #39492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2020

Conversation

OskarStark
Copy link
Contributor

Q A
Branch? 5.2
Bug fix? no
New feature? no
Deprecations? no
Tickets ---
License MIT
Doc PR ---

like proposed by @nicolas-grekas in https://github.com/symfony/symfony/pull/39444/files#r542288432

@nicolas-grekas
Copy link
Member

Can you please check how Discord behaves as I wondered in my comment ?

@OskarStark
Copy link
Contributor Author

Can you please check how Discord behaves as I wondered in my comment ?

Unfortunately I do not have Discord account I can test with.

@connorhu @mpiot maybe you can help us out here?

@@ -29,6 +29,8 @@ final class DiscordTransport extends AbstractTransport
{
protected const HOST = 'discord.com';

private const MAX_SUBJECT_LENGTH = 2000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's called TEXT_LIMIT in the Slack bridge 5.2
maybe SUBJECT_LIMIT here? or another name in the Slack bridge?

@@ -65,7 +67,7 @@ protected function doSend(MessageInterface $message): SentMessage

$content = $message->getSubject();

if (\strlen($content) > 2000) {
if (mb_strlen($content) > self::MAX_SUBJECT_LENGTH) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling mb_* without an explicit charset is something that should be banned in all situations.
It's a bit like gambling with charsets :)
UTF-8 must be specified here (and only utf8 is supported, since we use json along the path to Discord)

@connorhu
Copy link
Contributor

It seems ok. Should I run some tests with discord api?

@fabpot
Copy link
Member

fabpot commented Dec 17, 2020

Thank you @OskarStark.

@fabpot fabpot merged commit 6ead4a2 into symfony:5.2 Dec 17, 2020
@OskarStark OskarStark deleted the private-const-5.2 branch December 17, 2020 16:58
@fabpot fabpot mentioned this pull request Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants