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

really weird issue - adding asterisk * to a tweet text breaks the api #63

Closed
faisalsayed10 opened this issue Aug 27, 2021 · 3 comments · Fixed by #64
Closed

really weird issue - adding asterisk * to a tweet text breaks the api #63

faisalsayed10 opened this issue Aug 27, 2021 · 3 comments · Fixed by #64

Comments

@faisalsayed10
Copy link

okay so i found this weird issue while working with this api that whenever I add * to my tweet message, it literally breaks the api. Here's what's happening with me:

tweet = await twitterApi.v1.tweet("this is a *tweet*", { tweet_mode: "extended" });

^ this won't work, while if i tweet literally anything else which doesn't include asterisk, it will succeed. I have no idea how this happens, even tried using direct post methods, still breaks.

After this, I tested twitter-api-client and that doesn't break at all.

@alkihis
Copy link
Collaborator

alkihis commented Aug 27, 2021

Hi, thanks for your submission.
It seems to break OAuth signature and -consequently- breaks the subsequent request.
I'll check for a possible fix asap :)

alkihis added a commit that referenced this issue Aug 27, 2021
@alkihis
Copy link
Collaborator

alkihis commented Aug 27, 2021

Ok, for some reason, URLSearchParams object doesn't encode * when you transform it to a query string.
When Twitter expects a query string (GET/DELETE) or a url encoded body (every POST endpoint of v1.1), with a * into values, error was thrown. :)

return new URLSearchParams(body)
  .toString()
  .replace(/\*/g, '%2A'); // URLSearchParams doesnt encode '*', but Twitter wants it encoded.

Will be merged soon with other fixes and improvements.

@faisalsayed10
Copy link
Author

wow thanks for the quick response and also fixing it really quick!

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 a pull request may close this issue.

2 participants