Skip to content

Conversation

henrytndrly
Copy link

iOS doesn’t like having colons in filenames, and Twitter uses colons to identify the size of an image after the filename, e.g. ‘https://pbs.twimg.com/media/foo.jpg:large’, and this library was using the colon in the extension which resulted in images not displaying. The solution was to replace the colons in the extension. (Issue came to light due to using OpenGraph lookups to get appropriate images for embedded tweets)

iOS doesn’t like having colons in filenames, and Twitter uses colons to identify the size of an image after the filename, e.g. ‘https://pbs.twimg.com/media/foo.jpg:large’, and this library was using the colon in the extension which resulted in images not displaying. The solution was to replace the colons in the extension. (Issue came to light due to using OpenGraph lookups to get appropriate images for embedded tweets)
@wcandillon
Copy link
Owner

Thank for doing this!

What do you mean by iOS doesn't like colons in filenames? Is there a specification of the supported filenames? It would be good then to support all of them in this PR.

@henrytndrly
Copy link
Author

TL;DR: It's only colons that need to be processed...

--

The initial guidance I saw was this SO post: https://stackoverflow.com/questions/4924898/how-to-preserve-colon-character-in-filename-when-using-nsdata-method-writetofil so I just tried to replace the colon character, and the image started showing.

A bit more googling suggests that it is 'just' colons that are not liked (beyond slashes, but they're already treated as a directory separator...)
https://discussions.apple.com/thread/949275?tstart=0
http://xahlee.info/mswin/allowed_chars_in_file_names.html

Also found this google result which I think is the 'most' authoritative... https://books.google.co.uk/books?id=62xkJo6JXwAC&pg=PA616&lpg=PA616&dq=darwin+allowed+characters+in+file+names&source=bl&ots=PBQiurDAwK&sig=NE_nieRW_2iaZ3UyrfWsaSZ49wc&hl=en&sa=X&ved=0ahUKEwir2dLvyJXVAhXJB8AKHZmdBRgQ6AEITjAF#v=onepage&q=darwin%20allowed%20characters%20in%20file%20names&f=false
The first sentence of the 'File Paths' paragraph: "The Mac filesystem, HFS+, allows any characters except colons in filenames." [...because they are treated as delimiters...]

I've not yet found any Apple sourced specification on allowed characters.

@henrytndrly
Copy link
Author

(Also: my app is just focussing on iOS at the moment, however I think the code should also work on Android, as that probably doesn't care in the first place, and we're just operating on an 'internal' identifier)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants