##// END OF EJS Templates
hgweb: prevent loading style map from directories other than specified paths...
Yuya Nishihara -
r24296:b73a22d1 stable
parent child Browse files
Show More
@@ -747,7 +747,11 b' def stylemap(styles, paths=None):'
747 styles = [styles]
747 styles = [styles]
748
748
749 for style in styles:
749 for style in styles:
750 if not style:
750 # only plain name is allowed to honor template paths
751 if (not style
752 or style in (os.curdir, os.pardir)
753 or os.sep in style
754 or os.altsep and os.altsep in style):
751 continue
755 continue
752 locations = [os.path.join(style, 'map'), 'map-' + style]
756 locations = [os.path.join(style, 'map'), 'map-' + style]
753 locations.append('map')
757 locations.append('map')
@@ -578,6 +578,45 b' phase changes are refreshed (issue4061)'
578
578
579
579
580
580
581 no style can be loaded from directories other than the specified paths
582
583 $ mkdir -p x/templates/fallback
584 $ cat <<EOF > x/templates/fallback/map
585 > default = 'shortlog'
586 > shortlog = 'fall back to default\n'
587 > mimetype = 'text/plain'
588 > EOF
589 $ cat <<EOF > x/map
590 > default = 'shortlog'
591 > shortlog = 'access to outside of templates directory\n'
592 > mimetype = 'text/plain'
593 > EOF
594
595 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
596 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log \
597 > --config web.style=fallback --config web.templates=x/templates
598 $ cat hg.pid >> $DAEMON_PIDS
599
600 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT "?style=`pwd`/x"
601 200 Script output follows
602
603 fall back to default
604
605 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '?style=..'
606 200 Script output follows
607
608 fall back to default
609
610 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '?style=./..'
611 200 Script output follows
612
613 fall back to default
614
615 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '?style=.../.../'
616 200 Script output follows
617
618 fall back to default
619
581 errors
620 errors
582
621
583 $ cat errors.log
622 $ cat errors.log
General Comments 0
You need to be logged in to leave comments. Login now