anonymous-archiver / pastebin-dl

Command line tool for downloading pastes from pastebin.
3 stars 0 forks source link

Preserving Special Characters in Filename #1

Closed Tumultuous-RGR-SiM closed 4 years ago

Tumultuous-RGR-SiM commented 4 years ago

Hi. I'm noticing that the special characters like square brackets, curved brackets, slashes, and semicolons aren't being preserved. The square brackets and semicolon just aren't included at all, and the other characters are replaced with an underscore.

I tested it out on Notonefuck's bin.

anonymous-archiver commented 4 years ago

There is a reason for taking out those special characters as filenames and filesystems will interpret those slashes and whatnot as something else. For example, if the paste you're saving has something like a date "1/13/2016 something", the filesystem will interpret that as needing to navigate to the directory "1" and then "13" before getting to what it thinks is the file "2016 something". That's why some characters are being stripped out and replaced.

MS has a good guide on file naming as certain characters are reserved characters.

https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file

Tumultuous-RGR-SiM commented 4 years ago

That filenaming guide doesn't seem to mention square brackets as being a problem, so how about putting a substitution rule, where "(" gets changed to "["?

Similarly, I think dashes (-) are free from any special restrictions. slashes could be replaced, so that 1/13/2016 turns into 1-13-2016, which is still perfectly readable. Colons could be replaced with a space followed by a dash.

"Robot Fight: Revengence" to "Robot Fight - Revengence"

Those seem to be the most common usages of these special characters. Does this sound like a workable solution to you?

anonymous-archiver commented 4 years ago

Yeah, I can do something like that. May take a bit but it's doable. In the meantime, I hope the program is at least usable for you.

anonymous-archiver commented 4 years ago

Alright, changed so that the parens are changed to '[]' and slashes/* are changed to '-'. Gonna mark this as closed for now.