OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: attachment filename with chinese characters failed

From: Victor Duchovni (Victor.DuchovniMorganStanley.com)
Date: Thu Apr 27 2006 - 14:05:31 CDT


On Thu, Apr 27, 2006 at 05:51:02PM +0000, Tom Lee wrote:

> I have modied the code, now it works. It will replace the filename only and
> keep the original extension if there is one. It is exactly what I want to
> have.
>
> /^(content-(type|disposition):.*;[[:space:]]*(file)?name[[:space:]]*=[[:space:]]*")([^[:print:]]+(\.|")*)(.*)/
> REPLACE ${1}changed_filename${5}${6}
>
> It has been tested and works for the following case:
>
> content-type: application/octet-stream; name="???????.xls"
> content-type: application/octet-stream; name="???????"
> content-type: application/octet-stream; name="???????.xls"; otherattr =
> "otherval"
> content-type: application/octet-stream; name="???????.xls"; otherattr =
> "test.xls"
> content-type: application/octet-stream; name="???????"; otherattr =
> "test.xls"

This is either incomplete or overly complex. If the characters before the
extension or closing <"> are always all non-printable, you can just drop
the last two sub-expressions from the pattern and remove ${5} and ${6}
from the replacement rule. Otherwise if sometimes printable characters
do follow the initial non-printables, but precede the .extention or <">,
your expression will not repair the filename. Choose one or the other
and adjust accordingly. It may be time to help you out:

        Change: (\.|")*
        To: ([^."]*)

and remove ${5} from the replacement string. This works for the second
alternative above.

--
        Viktor.

P.S. Morgan Stanley is looking for a New York City based, Senior Unix
     system/email administrator to architect and sustain the Unix email
     environment. If you are interested, please drop me a note.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:majordomopostfix.org?body=unsubscribe%20postfix-users>

If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.