##// 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 class wsgirequest(object):
85 if type is not None:
85 if type is not None:
86 headers.append(('Content-Type', type))
86 headers.append(('Content-Type', type))
87 if filename:
87 if filename:
88 filename = (filename.split('/')[-1]
89 .replace('\\', '\\\\').replace('"', '\\"'))
88 headers.append(('Content-Disposition',
90 headers.append(('Content-Disposition',
89 'inline; filename=%s' % filename.split('/')[-1]))
91 'inline; filename="%s"' % filename))
90 if length:
92 if length:
91 headers.append(('Content-Length', str(length)))
93 headers.append(('Content-Length', str(length)))
92 self.header(headers)
94 self.header(headers)
@@ -3,17 +3,17
3 hg init test
3 hg init test
4 cd test
4 cd test
5 mkdir sub
5 mkdir sub
6 cat >sub/sometext.txt <<ENDSOME
6 cat >'sub/some "text".txt' <<ENDSOME
7 This is just some random text
7 This is just some random text
8 that will go inside the file and take a few lines.
8 that will go inside the file and take a few lines.
9 It is very boring to read, but computers don't
9 It is very boring to read, but computers don't
10 care about things like that.
10 care about things like that.
11 ENDSOME
11 ENDSOME
12 hg add sub/sometext.txt
12 hg add 'sub/some "text".txt'
13 hg commit -d "1 0" -m "Just some text"
13 hg commit -d "1 0" -m "Just some text"
14 hg serve -p $HGPORT -A access.log -E error.log -d --pid-file=hg.pid
14 hg serve -p $HGPORT -A access.log -E error.log -d --pid-file=hg.pid
15 cat hg.pid >> $DAEMON_PIDS
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 sleep 5
18 sleep 5
19 kill `cat hg.pid`
19 kill `cat hg.pid`
@@ -1,10 +1,10
1 200 Script output follows
1 200 Script output follows
2 content-type: text/plain
2 content-type: text/plain
3 content-length: 157
3 content-length: 157
4 content-disposition: inline; filename=sometext.txt
4 content-disposition: inline; filename="some \"text\".txt"
5
5
6 This is just some random text
6 This is just some random text
7 that will go inside the file and take a few lines.
7 that will go inside the file and take a few lines.
8 It is very boring to read, but computers don't
8 It is very boring to read, but computers don't
9 care about things like that.
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