When someone downloads a video from ramrom.io , the file they save needs a name, and the obvious choice is the video's own title. It sounds trivial until the first title arrives with emoji, Arabic script, a colon, and 200 characters of hashtags. A filename that works on my server has to work on the visitor's phone too, and those two machines do not agree on what a safe name looks like.
The first rule I learned is that the title is user input, no matter where it came from. It may have been typed by the uploader, pasted from a translation tool, or pulled from a provider's API, and in every case I treat it as untrusted. A title can contain slashes, which on Linux mean directories; it can contain .. , which means parent directories; and on Windows it can contain characters like : and ? that are simply illegal in a filename. My sanitiser strips or replaces the lot: slashes and backslashes become dashes, control characters are dropped, and a ..…