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 false positives in animated for PartialEmoji.from_str #9457

Merged
merged 2 commits into from Jun 21, 2023

Conversation

AbstractUmbra
Copy link
Contributor

Summary

Fixes #9456
Test cases can be found here: https://regex101.com/r/d8WD6t/1

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@Rapptz
Copy link
Owner

Rapptz commented Jun 21, 2023

I'm unsure why a positive lookahead is used, you can just put it as part of the animated group, e.g. <?(?P<animated>a:)?:?(?P<name>[A-Za-z0-9\_]+):(?P<id>[0-9]{13,20})>?. Alternatively you could do a conditional but that makes it confusing to read.

@Rapptz
Copy link
Owner

Rapptz commented Jun 21, 2023

Actually a better regex might be <?(?:(?P<animated>a)?:)?(?P<name>[A-Za-z0-9\_]+):(?P<id>[0-9]{13,20})>? since this one avoids the lookahead, embeds the conditional, and makes it so ::foo:1283908120938 is not a valid input

@AbstractUmbra
Copy link
Contributor Author

Good call! Updated that now.

@Rapptz Rapptz merged commit a7f2c67 into Rapptz:master Jun 21, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PartialEmoji.from_str incorrectly assumes emojis starting with a but not including : are animated
2 participants