PythonistaGuild / TwitchIO

An Async Bot/API wrapper for Twitch made in Python.
https://twitchio.dev
MIT License
791 stars 163 forks source link

User input is not properly tokenized #319

Closed Vgr255 closed 1 year ago

Vgr255 commented 2 years ago

The ext.commands.stringparser.StringParser.process_string method doesn't properly tokenize input if there is no space before a ". This is due to setting the start of the word after the ", dropping everything before it. As such, something like foo"bar" will be tokenized as ["bar"] -- it should be tokenized as ["foo", "bar"].

I believe the following code will fix this, though I haven't been able to test it yet:

            elif loc == '"':
                if not self.ignore:
                    if self.start != self.count:
                        self.words[self.index] = msg[self.start : self.count]
                        self.index += 1
                    self.start = self.count + 1
                    self.ignore = True

If I get some time this week, I'll attempt to PR this.

Thank you!

github-actions[bot] commented 2 years ago

Hello! Thanks for the issue. If this is a general help question, for a faster response consider joining the official Discord Server

Else if you have an issue with the library please wait for someone to help you here.