From 371d72dab1d0327bfe09b175ad38db564e3e245a Mon Sep 17 00:00:00 2001 From: Lubomir Sedlacik Date: Wed, 11 Mar 2009 15:40:10 +0100 Subject: 6802008 webrev generates relative URI for workspace names containing colon which confuse browser --- usr/src/tools/scripts/webrev.sh | 56 ++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 12 deletions(-) (limited to 'usr/src') diff --git a/usr/src/tools/scripts/webrev.sh b/usr/src/tools/scripts/webrev.sh index 49703e1505..d0783057a6 100644 --- a/usr/src/tools/scripts/webrev.sh +++ b/usr/src/tools/scripts/webrev.sh @@ -21,7 +21,7 @@ # # -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # @@ -333,6 +333,27 @@ function upload_webrev return 0 } +# +# input_cmd | url_encode | output_cmd +# +# URL-encode (percent-encode) reserved characters as defined in RFC 3986. +# +# Reserved characters are: :/?#[]@!$&'()*+,;= +# +# While not a reserved character itself, percent '%' is reserved by definition +# so encode it first to avoid recursive transformation, and skip '/' which is +# a path delimiter. +# +function url_encode +{ + sed -e "s|%|%25|g" -e "s|:|%3A|g" -e "s|\&|%26|g" \ + -e "s|?|%3F|g" -e "s|#|%23|g" -e "s|\[|%5B|g" \ + -e "s|*|%2A|g" -e "s|@|%40|g" -e "s|\!|%21|g" \ + -e "s|=|%3D|g" -e "s|;|%3B|g" -e "s|\]|%5D|g" \ + -e "s|(|%28|g" -e "s|)|%29|g" -e "s|\'|%27|g" \ + -e "s|+|%2B|g" -e "s|\,|%2C|g" -e "s|\\\$|%24|g" +} + # # input_cmd | html_quote | output_cmd # or @@ -2918,12 +2939,14 @@ printCI $TOTL $TINS $TDEL $TMOD $TUNC print "" if [[ -f $WDIR/$WNAME.patch ]]; then + wpatch_url="$(print $WNAME.patch | url_encode)" print "Patch of changes:" - print "$WNAME.patch" + print "$WNAME.patch" fi if [[ -f $WDIR/$WNAME.pdf ]]; then + wpdf_url="$(print $WNAME.pdf | url_encode)" print "Printable review:" - print "$WNAME.pdf" + print "$WNAME.pdf" fi if [[ -n "$iflag" ]]; then @@ -2972,16 +2995,21 @@ do # If there's a diffs file, make diffs links if [[ -f $F.cdiff.html ]]; then - print "Cdiffs" - print "Udiffs" + cdiff_url="$(print $P.cdiff.html | url_encode)" + udiff_url="$(print $P.udiff.html | url_encode)" + print "Cdiffs" + print "Udiffs" if [[ -f $F.wdiff.html && -x $WDIFF ]]; then - print "Wdiffs" + wdiff_url="$(print $P.wdiff.html | url_encode)" + print "Wdiffs" fi - print "Sdiffs" + sdiff_url="$(print $P.sdiff.html | url_encode)" + print "Sdiffs" - print "Frames" + frames_url="$(print $P.frames.html | url_encode)" + print "Frames" else print " ------ ------ ------" @@ -2995,7 +3023,8 @@ do # If there's an old file, make the link if [[ -f $F-.html ]]; then - print "Old" + oldfile_url="$(print $P-.html | url_encode)" + print "Old" else print " ---" fi @@ -3003,19 +3032,22 @@ do # If there's an new file, make the link if [[ -f $F.html ]]; then - print "New" + newfile_url="$(print $P.html | url_encode)" + print "New" else print " ---" fi if [[ -f $F.patch ]]; then - print "Patch" + patch_url="$(print $P.patch | url_encode)" + print "Patch" else print " -----" fi if [[ -f $WDIR/raw_files/new/$P ]]; then - print "Raw" + rawfiles_url="$(print raw_files/new/$P | url_encode)" + print "Raw" else print " ---" fi -- cgit v1.2.3