comparison tests/test-hgweb.t @ 25777:1c2a8db33b8f

hgweb: allow symbolic revisions with forward slashes in urls It's possible to have a branch/tag/bookmark with all kinds of special characters, such as {}/\!?. While not very conveniently, symbolic revisions with such characters work from command line if user correctly quotes the characters. These characters also work in hgweb, when they are properly encoded, with one exception: '/' (forward slash, urlencoded as '%2F'), which was getting decoded before hgweb could parse it as a part of PATH_INFO. Because of that, hgweb was seeing it as any other forward slash, that is, as just another url parts separator. For example, if user wanted to see the content of dir/file at bookmark 'feature/eggs', url could be: '/file/feature%2Feggs/dir/file'. But hgweb tried to find a revision 'feature' and get contents of 'eggs/dir/file'. To fix this, let's assume forward slashes are doubly-urlencoded (%252F), so CGI/WSGI server decodes it into %2F. Then we can decode %2F in the revision part of the url into an actual '/' character. Making hgweb produce such urls will be done in the next 2 patches.
author Anton Shestakov <av6@dwimlabs.net>
date Sun, 12 Jul 2015 16:06:57 +0800
parents 63be46407a50
children eae3c6de71e5
comparison
equal deleted inserted replaced
25776:809c3e4a9e31 25777:1c2a8db33b8f
8 $ echo foo > da/foo 8 $ echo foo > da/foo
9 $ echo foo > foo 9 $ echo foo > foo
10 $ hg ci -Ambase 10 $ hg ci -Ambase
11 adding da/foo 11 adding da/foo
12 adding foo 12 adding foo
13 $ hg bookmark -r0 '@'
14 $ hg bookmark -r0 'a b c'
15 $ hg bookmark -r0 'd/e/f'
13 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log 16 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
14 $ cat hg.pid >> $DAEMON_PIDS 17 $ cat hg.pid >> $DAEMON_PIDS
15 18
16 manifest 19 manifest
17 20
262 265
263 <div class="main"> 266 <div class="main">
264 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> 267 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
265 <h3> 268 <h3>
266 directory / @ 0:<a href="/rev/2ef0ac749a14">2ef0ac749a14</a> 269 directory / @ 0:<a href="/rev/2ef0ac749a14">2ef0ac749a14</a>
267 <span class="tag">tip</span> 270 <span class="tag">tip</span> <span class="tag">@</span> <span class="tag">a b c</span> <span class="tag">d/e/f</span>
268 </h3> 271 </h3>
269 272
270 <form class="search" action="/log"> 273 <form class="search" action="/log">
271 274
272 <p><input name="rev" id="search1" type="text" size="30" /></p> 275 <p><input name="rev" id="search1" type="text" size="30" /></p>
555 user: test 558 user: test
556 date: Thu, 01 Jan 1970 00:00:00 +0000 559 date: Thu, 01 Jan 1970 00:00:00 +0000
557 summary: base 560 summary: base
558 branch: default 561 branch: default
559 tag: tip 562 tag: tip
563 bookmark: @
564 bookmark: a b c
565 bookmark: d/e/f
560 566
561 567
562 $ hg phase --draft tip 568 $ hg phase --draft tip
563 $ get-with-headers.py localhost:$HGPORT 'log?style=raw' 569 $ get-with-headers.py localhost:$HGPORT 'log?style=raw'
564 200 Script output follows 570 200 Script output follows
578 changeset: 2ef0ac749a14e4f57a5a822464a0902c6f7f448f 584 changeset: 2ef0ac749a14e4f57a5a822464a0902c6f7f448f
579 revision: 0 585 revision: 0
580 user: test 586 user: test
581 date: Thu, 01 Jan 1970 00:00:00 +0000 587 date: Thu, 01 Jan 1970 00:00:00 +0000
582 summary: base 588 summary: base
583 589 bookmark: @
584 590 bookmark: a b c
591 bookmark: d/e/f
592
593
594
595 access bookmarks
596
597 $ get-with-headers.py localhost:$HGPORT 'rev/@?style=paper' | egrep '^200|changeset 0:'
598 200 Script output follows
599 changeset 0:<a href="/rev/2ef0ac749a14?style=paper">2ef0ac749a14</a>
600
601 $ get-with-headers.py localhost:$HGPORT 'rev/%40?style=paper' | egrep '^200|changeset 0:'
602 200 Script output follows
603 changeset 0:<a href="/rev/2ef0ac749a14?style=paper">2ef0ac749a14</a>
604
605 $ get-with-headers.py localhost:$HGPORT 'rev/a%20b%20c?style=paper' | egrep '^200|changeset 0:'
606 200 Script output follows
607 changeset 0:<a href="/rev/2ef0ac749a14?style=paper">2ef0ac749a14</a>
608
609 $ get-with-headers.py localhost:$HGPORT 'rev/d%252Fe%252Ff?style=paper' | egrep '^200|changeset 0:'
610 200 Script output follows
611 changeset 0:<a href="/rev/2ef0ac749a14?style=paper">2ef0ac749a14</a>
585 612
586 no style can be loaded from directories other than the specified paths 613 no style can be loaded from directories other than the specified paths
587 614
588 $ mkdir -p x/templates/fallback 615 $ mkdir -p x/templates/fallback
589 $ cat <<EOF > x/templates/fallback/map 616 $ cat <<EOF > x/templates/fallback/map