From: Jakub Narebski Date: Tue, 14 Jun 2011 01:33:57 GMT Subject: Re: [PATCH] gitweb: Make $prevent_xss protection for 'blob_plain' more usable Message-ID: <201106140333.58351.jnareb@gmail.com> In-Reply-To: <7vy615mily.fsf@alter.siamese.dyndns.org> Junio C Hamano wrote: > Jakub Narebski writes: > >>> Hmph, wouldn't it be more straightforward if you dropped the statement >>> modifier? I.e. >>> >>> my ($subtype, $rest) = ($1, $2); >>> $rest = '' unless defined $rest; >>> $type = "text/plain$rest"; >> >> Yes, of course. >> >> I don't know why I decided that avoiding rewriting 'text/plain; >> charset=utf-8' case was important. > > Just to make sure I understand what you are saying... > > my $type = 'text/plain; charset=utf-8'; > if ($type =~ m|^text/([a-z]+)\b(.*)$|) { > my ($subtype, $rest) = ($1, $2); > $rest = '' unless defined $rest; > $type = "text/plain$rest"; > print "Type is now <$type>\n"; > } > > > does yield "text/plain; charset=utf-8". It does rewrite but rewrite to > exactly the same thing, so... Yes, it does rewrite to the same thing. And the code is simpler, therefore better. -- Jakub Narebski Poland