This repository was archived by the owner on Aug 14, 2023. It is now read-only.
Remove file extensions from locked URLs for hastebin#121
Merged
Conversation
Contributor
Author
|
PR tested, and is currently live on https://paste.pythondiscord.com. Works as intended now. |
jb3
approved these changes
Feb 17, 2022
Member
jb3
left a comment
There was a problem hiding this comment.
Lemon, excellent work my friend. Great stuff! ![]()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recently, Discord has implemented a suspicious file scanning feature which marks any URL with a
.pyin it as a suspicious URL.This means, users who use our paste.pythondiscord.com service will be met with this lovely screen:
This hideous monster of a monkey patch will comment out the line of code that adds the file extension to the URL, thereby ensuring that you will just get a flat URL when you save. E.g., instead of
paste.pythondiscord.com/omaimadnaoida.py, you'll just getpaste.pythondiscord.com/omaimadnaoidawhen you hit save.I've made this monkeypatch fail hard if it fails, so if the code changes and this approach is no longer viable, it should break the entire build, thereby alerting us that we need to change (or remove) the monkey patch to build this service. That seems better than silently failing to remove the .py and reintroducing the bug.
How does this work?
It just comments out a single line in haste-server, which is responsible for adding this extension to the URL before it gets pushed to your history. The specific line and the context can be found here:
https://github.com/toptal/haste-server/blob/master/static/application.js#L249
Why a monkey patch?
Because forking haste-server means maintaining the fork. This will theoretically keep working until this particular line is changed, and honestly it would be weird if that ever happened, this line is very simple and I can't imagine why they would change it at all.
It's likely that this will work for the foreseeable future, and without forcing us to maintain a fork, and without missing out on future updates. We can keep using the latest version of this tool, and if it breaks, we'll just adjust the monkeypatch or get rid of it. It's not a big deal, it'll just fail to deploy. Users won't even notice.