* Gary Funck via RT (bug-Mail-Message@rt.cpan.org) [180520 15:43]:
Show quoted text
In all dimensions ;-)
Show quoted text> Can we have dispositionFilenameRaw(), or dispositionFilename(raw => 1), or
> a cleanup function callout? Barring that - break out the cleanup into its
> own sub that can be overridden by the user (via the symbol table)?
When you do not provide a directory, you get the unprocessed name back.
Show quoted text> Regarding your suggested change:
>
> for($filename) {
> s/\s+/ /g; s/ $//; s/^ //;
> s/[^\w .-]//g;
> }
>
> s/\s+/ /g; OK
> s/ $//; maybe s/ +$//; instead
> s/^ //; maybe s/^ +//; instead
After the first change, there can only be one blank at the beginning and the end.
Show quoted text> Regarding s/[^\w .-]//g;
>
> Won't that " " (space) in there undo the previous rewrites into space
> characters? If that is what you're after, then this will (I think) be an
> equivalent pattern, covering all of them.
>
> s/[\W\s.-]+//g;
This is very different. My expression says: do *not* throw away word-chars,
nor blanks, nor dots, nor dashes. That's what you want.
Show quoted text> BTW, what prevents the current code and the suggested new code from wiping
> out the final "." which delimits the file's extension?
It does not removee dots.
Show quoted text> Reading the current implementation, it looks like I might already have my
> 'raw' filename capability. [...]
> If that capability can be left in (and documented) that would meet
> my needs.
The docs are unclear, I agree:
Without $directory, the name found will be returned.
I will restructure the docs:
Various fields are searched for C<filename> and C<name> attributes. Without
$directory, the name found will be returned unmodified.
When a $directory is given, a filename is composed. For security reasons,
only the basename of the found name gets used and many potentially
dangerous characters removed. If no name was found, or when the found
name is already in use, then an unique name is generated.
Don't forget to read RFC6266 section 4.3 for the security aspects in your
email application.
Show quoted text
I think that handling the contents of the attachment is out-of-scope for
MailBox. Let's hope the author of the client know what he is doing ;-)
--
Regards,
MarkOv
------------------------------------------------------------------------
Mark Overmeer MSc MARKOV Solutions
Mark@Overmeer.net solutions@overmeer.net
http://Mark.Overmeer.net http://solutions.overmeer.net