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

Util.escapeInlineCode fails to properly escape inline code in some cases #7373

Closed
dshepsis opened this issue Jan 31, 2022 · 0 comments · Fixed by #7587
Closed

Util.escapeInlineCode fails to properly escape inline code in some cases #7373

dshepsis opened this issue Jan 31, 2022 · 0 comments · Fixed by #7587

Comments

@dshepsis
Copy link

Which package is this bug report for?

discord.js

Issue description

Have the bot send a message with the content:

Util.escapeInlineCode("``a`")

The function will return ``a\`, indicating only the last backtick was escaped by prepending a backslash. The bot's message will appear as shown below:

image

As you can see, it's rendered as inline code with the content `a\, indicating the first and last backtick were interpreted as marking inline code, even though the last backtick is supposed to be escaped.

In order to correctly escape this string, Util.escapeInlineCode should've returned \`\`a` or \`\`a\`.

Note that the a can be replaced with any string without backticks, as far as I can tell, without affecting the issue. Perhaps there are other kinds of strings you could craft that would cause similar failures, but I couldn't find any.

I'm not sure the exact best way to fix this method, as it may be dependent on exactly how Discord's own markdown parser is built.

Code sample

Util.escapeInlineCode("``a`")

Package version

discord.js@13.5.1

Node.js version

v16.13.1

Operating system

Windows

Priority this issue should have

Low (slightly annoying)

Which partials do you have configured?

Not applicable (subpackage bug)

Which gateway intents are you subscribing to?

Not applicable (subpackage bug)

I have tested this issue on a development release

No response

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants