Sitelet https://web.archive.org/web/20220204174734/https://github.com/DV8FromTheWorld/JDA/issues/1298
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

Add option to escape all markdown characters to MarkdownSanitizer #1298

Closed
3 tasks done
Andre601 opened this issue May 14, 2020 · 3 comments
Closed
3 tasks done

Add option to escape all markdown characters to MarkdownSanitizer #1298

Andre601 opened this issue May 14, 2020 · 3 comments

Comments

@Andre601
Copy link
Contributor

@Andre601 Andre601 commented May 14, 2020

General Troubleshooting

  • I have checked for similar issues.
  • I have updated to the latest JDA version.
  • I have checked the branches or the maintainers' PRs for upcoming features.

Feature Request

When you use MarkdownSanitized.escape(String) on a text that only contains a single icon used in markdown does MarkdownSanitizer not escape it, causing weird Markdown formatting to happen.

For example:
Assume we have a user with the name _ User
When I would have the message Andre_601 is giving _ User _1 Reputation Point_ and want the MarkdownSanitizer to escape the username, will it not do that as it doesn't find two _ to escape.

This causes the above message to be displayed like this:
image

When in actuality it should be displayed like this:
image

Having an option to escape every character used for markdown, even when it's a single one, would be a useful thing as you may want to escape those characters in usernames or similar, while still having markdown formatting used.
My idea would be a boolean option that when set to true, would escape every _, *, ~, >, etc.

Example Use-Case

Use-case has explained above.

@DV8FromTheWorld
Copy link
Owner

@DV8FromTheWorld DV8FromTheWorld commented May 21, 2020

String someString = "Andre_601"
String fullyEscaped = someString.replaceAll("([_`~*>])", "\\\\$1")

@DV8FromTheWorld
Copy link
Owner

@DV8FromTheWorld DV8FromTheWorld commented May 21, 2020

That being said, this issue seems like an easy issue for a simple PR.

@RicardormDev
Copy link

@RicardormDev RicardormDev commented Nov 10, 2020

I wrote this at a server and it seems that the problem is persisting, this might be an error from discord.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants