From: Junio C Hamano Subject: Re: [PATCH] gitweb: Change to use explicitly function call cgi->escapHTML() Date: Tue, 06 Mar 2007 02:53:07 -0800 Message-ID: <7vveheprsc.fsf@assigned-by-dhcp.cox.net> References: <20070306093917.GA1761@coredump.intra.peff.net> <989B956029373F45A0B8AF02970818902DAA12@zch01exm26.fsl.freescale.net> <20070306104127.GA13096@coredump.intra.peff.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Li Yang-r58472 , Jakub Narebski , git@vger.kernel.org To: Jeff King X-From: git-owner@vger.kernel.org Tue Mar 06 11:53:14 2007 Return-path: Envelope-to: gcvg-git@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1HOXI9-0004lr-0b for gcvg-git@gmane.org; Tue, 06 Mar 2007 11:53:13 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964883AbXCFKxK (ORCPT ); Tue, 6 Mar 2007 05:53:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S964893AbXCFKxK (ORCPT ); Tue, 6 Mar 2007 05:53:10 -0500 Received: from fed1rmmtao102.cox.net ([68.230.241.44]:39359 "EHLO fed1rmmtao102.cox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964883AbXCFKxJ (ORCPT ); Tue, 6 Mar 2007 05:53:09 -0500 Received: from fed1rmimpo01.cox.net ([70.169.32.71]) by fed1rmmtao102.cox.net (InterMail vM.7.05.02.00 201-2174-114-20060621) with ESMTP id <20070306105307.KGUJ26279.fed1rmmtao102.cox.net@fed1rmimpo01.cox.net>; Tue, 6 Mar 2007 05:53:07 -0500 Received: from assigned-by-dhcp.cox.net ([68.5.247.80]) by fed1rmimpo01.cox.net with bizsmtp id XNt71W00H1kojtg0000000; Tue, 06 Mar 2007 05:53:08 -0500 In-Reply-To: <20070306104127.GA13096@coredump.intra.peff.net> (Jeff King's message of "Tue, 6 Mar 2007 05:41:27 -0500") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: Jeff King writes: > On Tue, Mar 06, 2007 at 06:31:23PM +0800, Li Yang-r58472 wrote: > >> Yes, it also fixed the problem. I'm not very familiar with perl. Will >> CGI::autoEscape(1) change CGI action for other users of CGI module on >> the system? If so, maybe it will break other CGIs. > > I don't know enough about mod_perl to say, but if all scripts share the > package globals from CGI, then yes, you're affecting all other scripts. > Without mod_perl, obviously you have no impact. > > If it is the case, then your original fix is probably better. But then you are letting _other_ mod_perl users to affect your behaviour, aren't you? "sub autoEscape" does this: sub autoEscape { my($self,$escape) = self_or_default(@_); my $d = $self->{'escape'}; $self->{'escape'} = $escape; $d; } If we worry about mod_perl (provided if $CGI::Q is shared across mod_perl users), I suspect we would need to be a bit more paranoid, perhaps like this, woudln't we? --- diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 653ca3c..9c4e060 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -26,6 +26,7 @@ our $cgi = new CGI; our $version = "++GIT_VERSION++"; our $my_url = $cgi->url(); our $my_uri = $cgi->url(-absolute => 1); +$cgi->autoEscape(1); # core git executable to use # this can just be "git" if your webserver has a sensible PATH