Open TheDarkLordSano opened 7 years ago
Hrmmm... This is extreamly weird. From what I can remember of the code paths, the bot blindly reads the name to subscribe to from the subscribe message, I can't think of any way it should superimpose a different subscription.
The first two pictures are my original message as requested, the last two are my further experiments, "/u/_te_" and "/u/_te_" respectively. Which resulted in me getting subscribed to "/u/_"
It seems to me that the bot just looks to where the hyperlink ends, it might not explain the first bug but it could explain the behavior I'm the last two screenshots
Hrmmm.... Ok - Thanks for the information. Ill poke at this when I get home tonight and see if i can't nail down the issue.
(Also i think its time to introduce a test suite...)
Not sure how that could happen. Well, to clarify, there's one way I know it could happen, but it would be somewhat ridiculous in context. Assuming the bot caches users available to subscribe to (aka makes a lookup list of users whose posts this bot is on and refers to it at some point), this could happen if using a greedy regex match. It's the only thing that comes to mind for me at the moment.
Notably, I searched the repository just to see if that might be some kind of edge case cover programmed in by the original author of the bot, since that username is honestly too perfect for a random mistake.
I can in fact confirm that this is an issue and that the subscription to /u/ThisHasNotGoneWell is, hilariously, completely accidental. I'll poke at the regex tomorrow to see if I can figure out what the issue actually is, but I tried subbing to the same user in the same post, only to get a message stating I subscribed to /u/cloudninerains.
Sano, I've been poking around a bit more, and I'd like confirmation of something, if possible. When attempting to subscribe to /u/__te__ or /u/__-___----_, I am informed that I've subscribed to an apparently random user (I have yet to determine where the username actually comes from). However, despite not attempting to unsubscribe from those users, my subscription list doesn't have any of them listed in it. I was hoping you could confirm an error in the logs? I believe the exact message would be "Subscription does not exist".
I noted that I still get the subscription message, but that's easy to explain: the message gets sent no matter what happens, even if the subscription fails.
Also, I just sent a test message to the bot, containing the following:
subscribe /u/\-\-t1\-\- subscribe /u/\_\_t2\_\_ subscribe /u/--t3-- subscribe /u/__t4__
That message shows in a post as:
subscribe /u/--t1-- subscribe /u/__t2__ subscribe /u/--t3-- subscribe /u/t4
And resulted in a confirmation message showing active subscriptions to /u/--t3-- and /u/__t4__, but not /u/--t1-- or /u/__t2__. This means that, despite them not rendering for the end user, the bot can see the backslashes somehow. (Notably, the same message partially parses formatting if sent directly to the bot as a message rather than as a comment, such that the first two and second two look identical text-wise, but the second two are auto-linked to the user while the first two are just plain text.)
My personal recommendation is to modify lines 31 and 48 of inbox.py to the following:
users = extract_users(message.body.replace("\\", ""))
That will automatically filter out backslashes, and prevent formatting attempts from breaking the process. If you want to deal with end user confusion regarding username formatting, I would modify line 18 of config.py so that it looks like this:
Don't want to admit your like or dislike to the community? [click here](http://www.reddit.com/message/compose/?to=HFYsubs&subject=subscribe&message=subscribe%20/u/{actualusername}) and send the same message.
And follow up with modifying line 56 of submissions.py to read like so:
post = config.POST_CONTENT.format(
username=submission.author.replace("_", "\\\\\\_").replace("-", "\\\\\\-"),
actualusername=submission.author.replace("_", "\_").replace("-", "\-")
)
This way sending direct messages to the bot will work as expected and link the username, while replying in comments will both display in an understandable and expected format, and be correctly handled by the bot due to the filters mentioned above. If all of this works as expected, it should resolve both this issue as well as #22.
It seems user "Gatling_Tech" attempted to subscribe to /u/te and instead got subscribed to /u/ThisHasNotGoneWell
Context