I didn't know that.

It seems that most browsers are quite benevolent parsing this with
wrong space character encoding.

I have to update my code. 

Thank you very much! 

-----Mensaje original-----
De: Gustaf Neumann <neum...@wu.ac.at>
Responder a: naviserver-devel@lists.sourceforge.net
Para: naviserver-devel@lists.sourceforge.net
Asunto: Re: [naviserver-devel] ns_returnfile return original file
name
Fecha: Wed, 20 Jul 2022 22:08:05 +0200

Dear Oscar,
In principle, you are right concerning the encoding. A few comments:

- on most browsers, also utf-8 filenames are accepted,
   but the use of UTF-8 in the header fields is not recommended.

- For the percent encoding, one should use "ns_urlencode -path",
e.g., 

         ns_urlencode -part path {£ and € rates}

   since the "ns_urlencode" without parameters (as in your example)
uses a special rule for the space character.
One should actually provide an API along the lines of:
    ns_header_field_parameter -charset /charset/ -language /language/
name string
to ease its usage. ... maybe something for the next release...
All the best
-g
PS: Minor nitpick: RFC 5987 was obsoleted by RFC 8187
On 19.07.22 23:25, Oscar Rodriguez Fonseca wrote:
 
> Dear all,
> 
> Just for the sake of completeness. If you need an utf-8 encoded
> filename you may need to encode the filename (as per RFC 5987):
> 
> ns_set update [ns_conn outputheaders] Content-Disposition
> "attachment; filename*=UTF-8''[ns_urlencode $filename]"
> 
> ns_set update [ns_conn outputheaders] Content-Disposition
> "filename*=UTF-8''[ns_urlencode $filename]"
> 
> AFAIK it works well in any modern browser.
> 
> Best regards.
> 
> 
> -----Mensaje original-----
> De: Maksym Zinchenko <siqsu...@gmail.com>
> Responder a: naviserver-devel@lists.sourceforge.net
> Para: naviserver-devel@lists.sourceforge.net
> Asunto: Re: [naviserver-devel] ns_returnfile return original file
> name
> Fecha: Tue, 19 Jul 2022 16:33:58 -0100
> 
> Thank you all, that's exactly what I needed.
>  
> On Mon, Jul 18, 2022 at 1:00 PM Wolfgang Winkler via naviserver-
> devel <naviserver-devel@lists.sourceforge.net> wrote:
>  
> > Hi!
> > We use
> > ns_set update [ns_conn outputheaders] Content-Disposition
> > "attachment; filename=\"${filename}\""
> > for downloading and
> > ns_set update [ns_conn outputheaders] Content-Disposition
> > "filename=\"${filename}\""
> > for viewing files
> > Am 15.07.22 um 16:50 schrieb Maksym Zinchenko:
> >  
> >  
> > > Hello, I have a question about how to return the original file
> > > name. For example:
> > > 
> > > ns_register_proc GET /dev/rtrn_file ::dev::rtrn_file
> > >  proc rtrn_file {args} {
> > >  set f [file join /tmp test.csv]
> > >  ns_returnfile 200 [ns_guesstype "$f"] $f
> > >  }
> > > 
> > > When I do GET request  I'm getting "rtrn_file.csv" instead of
> > > "test.csv"
>  
>  
> _______________________________________________
> naviserver-devel mailing list
> naviserver-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to