esmero / ami

Archipelago Multi Importer. A module of mass ingest made for the masses
GNU Affero General Public License v3.0
2 stars 4 forks source link

ISSUE-159: Remove spaces and dots from the beginning in any combination for remote filenames #160

Closed DiegoPino closed 1 year ago

DiegoPino commented 1 year ago

See #159 This is a simple regular expression: '/^(\.|\h)*/m' It will match any combination of dots and horizontal spaces from the beginning. To be extra safe, after cleaning we check if anything is left and if not we actually default the the URL given name...

I only do this for Names provided by a header/remove HTTP idea. If a user decides to use local filenames or S3 ones, we don't want to modify their names at all (like really) and again, good practices are not something we SHOULD enforce via code. This is a way of getting around the strange filenames we are getting from remote sources.

Relates to https://github.com/esmero/strawberryfield/pull/266 which deals with actual filenames that have dots