##// END OF EJS Templates
hgweb: Quote filenames when downloading raw files.
Thomas Arendsen Hein -
r6137:1c0e7afe default
parent child Browse files
Show More
@@ -85,8 +85,10 b' class wsgirequest(object):'
85 85 if type is not None:
86 86 headers.append(('Content-Type', type))
87 87 if filename:
88 filename = (filename.split('/')[-1]
89 .replace('\\', '\\\\').replace('"', '\\"'))
88 90 headers.append(('Content-Disposition',
89 'inline; filename=%s' % filename.split('/')[-1]))
91 'inline; filename="%s"' % filename))
90 92 if length:
91 93 headers.append(('Content-Length', str(length)))
92 94 self.header(headers)
@@ -3,17 +3,17 b''
3 3 hg init test
4 4 cd test
5 5 mkdir sub
6 cat >sub/sometext.txt <<ENDSOME
6 cat >'sub/some "text".txt' <<ENDSOME
7 7 This is just some random text
8 8 that will go inside the file and take a few lines.
9 9 It is very boring to read, but computers don't
10 10 care about things like that.
11 11 ENDSOME
12 hg add sub/sometext.txt
12 hg add 'sub/some "text".txt'
13 13 hg commit -d "1 0" -m "Just some text"
14 14 hg serve -p $HGPORT -A access.log -E error.log -d --pid-file=hg.pid
15 15 cat hg.pid >> $DAEMON_PIDS
16 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/?f=37afcac6d393;file=sub/sometext.txt;style=raw' content-type content-length content-disposition) >getoutput.txt &
16 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/?f=a23bf1310f6e;file=sub/some%20%22text%22.txt;style=raw' content-type content-length content-disposition) >getoutput.txt &
17 17
18 18 sleep 5
19 19 kill `cat hg.pid`
@@ -1,10 +1,10 b''
1 1 200 Script output follows
2 2 content-type: text/plain
3 3 content-length: 157
4 content-disposition: inline; filename=sometext.txt
4 content-disposition: inline; filename="some \"text\".txt"
5 5
6 6 This is just some random text
7 7 that will go inside the file and take a few lines.
8 8 It is very boring to read, but computers don't
9 9 care about things like that.
10 host - - [date] "GET /?f=37afcac6d393;file=sub/sometext.txt;style=raw HTTP/1.1" 200 -
10 host - - [date] "GET /?f=a23bf1310f6e;file=sub/some%20%22text%22.txt;style=raw HTTP/1.1" 200 -
General Comments 0
You need to be logged in to leave comments. Login now