Skip to content
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

fix: Remove deprecation warning on Message#cleanContent #7143

Merged
merged 3 commits into from Dec 26, 2021

Conversation

Jiralite
Copy link
Member

Please describe the changes this PR makes and why it should be merged:
Resolves #7142.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@iCrawl iCrawl added this to the Version 13.5 milestone Dec 24, 2021
@Seblor
Copy link

Seblor commented Dec 24, 2021

I'm not familiar with the inner workings of DJS, but from an outsider's point of view, this looks like a stopgap solution.

The Util.removeMentions method is being deprecated because of the introduction of allowedMentions (#6530). So maybe the code from Util.removeMentions should be moved to the Message.cleanContent getter, or the Util.removeMentions should not be deprecated.

@Jiralite
Copy link
Member Author

Message#cleanContent calls Util.cleanContent() which calls Util.removeMentions() which sanitises input to prevent mentionability by a simple str.replaceAll('@', '@\u200b'). Once Util.removeMentions() is removed, this replacement will no longer exist. Message#cleanContent will still call Util.cleanContent() and will still act as it always has - the only difference being that mentions are not sanitised.

The reason for this is in case people send clean content as a new message which may cause @everyone or @here injections. Since allowedMentions exist, that should be the preferred method to prevent mentions in your message.

@Seblor
Copy link

Seblor commented Dec 24, 2021

That makes sense, thank you for the clarification.

@ImRodry
Copy link
Contributor

ImRodry commented Dec 24, 2021

Shouldn't cleanContent still return @Rodry#4020 instead of <@240875059953139714>? Maybe it shouldn't only remove mentions but also make them readable outside of Discord

@vladfrangu
Copy link
Member

The only thing this PR does is prevent the deprecation warning from showing in .cleanContent, not remove the replace to username behavior

@ImRodry
Copy link
Contributor

ImRodry commented Dec 24, 2021

Once Util.removeMentions() is removed, this replacement will no longer exist. Message#cleanContent will still call Util.cleanContent() and will still act as it always has - the only difference being that mentions are not sanitised.

I was commenting on this

@vladfrangu
Copy link
Member

It means that if you cleanContent a member mention, whose display name is everyone, you will get an @everyone in your chat instead of @\u200beveryone.

src/util/Util.js Outdated Show resolved Hide resolved
@iCrawl iCrawl merged commit 7e5f16b into discordjs:main Dec 26, 2021
@Jiralite Jiralite deleted the content branch December 26, 2021 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Message.cleanContent sends a deprecation warning
6 participants