If a filename has invalid characters convert them to "_" and shorten the filename if longer than what the filesystem can handle.
Ensure that the file path is cleaned before logging and that template vars needing cleaning do not remove unnecessary characters. Remove superfluous bad character check in getSavePageParams.
Add queryhash and queryq/queryhashq template variables for helping to derive a uniq filename from a request, independent of time.
Add *i file template variables for including the "index" as needed regardless of position in the template string.
Add dirname template variable and rework shelve.getDocumentFilename for efficiency and clarity.
Add dirnameshorten template variable which expands to the dirname with each path component, if longer than MAXNAMELEN, shortened to have a unique hash appended and be at MAXNAMELEN in length. Directory creation should never fail now.
Add archivefilename which generates a filename for archival purposes. The filename is shortened, if necessary, to include the hash of the filename, queryhashq, and extension.