[27124] in Athena Bugs
htmlview breaks on urls with '&'
daemon@ATHENA.MIT.EDU (Jacob Morzinski)
Tue Oct 2 15:33:29 2007
Message-Id: <200710021933.l92JX6hZ007407@horobi.mit.edu>
To: bugs@mit.edu
Date: Tue, 02 Oct 2007 15:33:06 -0400
From: Jacob Morzinski <jmorzins@mit.edu>
X-Spam-Flag: NO
X-Spam-Score: 0.00
Cc: jmorzins@mit.edu
Errors-To: bugs-bounces@mit.edu
System name: horobi.mit.edu
Type and version: i686 9.4.42 (with mkserv)
Display type: Intel Corporation 82915G/GV/910GL Integrated Graphics Controller (rev 04)
Shell: /bin/athena/bash
Window manager: metacity
What were you trying to do?
Use /usr/athena/bin/htmlview to open a URL that contains
an ampersand. For example:
htmlview 'http://scripts.mit.edu/~jmorzins/hes/?name=jmorzins&type=filsys'
What's wrong:
htmlview uses sed to substitute the URL into the html
handler command. Unfortunately, '&' is a special
character in old-style sed and grep regexps:
echo 'firefox %s' | sed -e 's|%s|http://....?name=jmorzins%stype=filsys|'
results in
firefox http://....?name=jmorzins%stype=filsys
Note that the '&' in the replacement text was filled in
with "%s", because that's what '&' does in sed regexps.
What should have happened:
The script could escape special characters from the
replacement text, or the script could use some form of
printf to do the replacement.
Current athena solaris and linux machines have a
/usr/bin/prinft program.
The following patch could fix the file:
--- /usr/athena/bin/htmlview 2007-01-22 18:43:31.000000000 -0500
+++ /tmp/htmlview 2007-10-02 15:29:21.000000000 -0400
@@ -90,3 +90,3 @@
*%s*)
- cmd=`echo "$http_command" | sed -e "s|%s|$url|"`
+ cmd=`printf "$http_command" "$url"`
;;
Please describe any relevant documentation references:
sed(1)