Hi Emma,
Good point regarding a null title. I am using 5.6.
The name is sanitized by util_text_to_url in upload_file.
I would suggest changing the regexp to allow for a period:
# substitute all non-word characters
regsub -all {([^a-z0-9\.])+} $text $replacement text
This sets the name with a proper extension unless there are name conflicts, in which case file.pdf becomes file.pdf_2.