From: Jakub Narebski <jnareb@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Christopher M. Fuhrman" <cfuhrman@panix.com>,
git@vger.kernel.org, Christopher Wilson <cwilson@cdwilson.us>,
Sylvain Rabot <sylvain@abstraction.fr>
Subject: Re: [PATCH] gitweb: Strip non-printable characters from syntax highlighter output
Date: Fri, 16 Sep 2011 20:58:49 +0200 [thread overview]
Message-ID: <201109162058.51132.jnareb@gmail.com> (raw)
In-Reply-To: <7vwrd8fnxr.fsf@alter.siamese.dyndns.org>
On Fri, 16 Sep 2011, Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> Micronit:
>
> > +# Sanitize for use in XHTML + application/xml+xhtm (valid XML 1.0)
> > +sub sanitize {
> > + my $str = shift;
> > +
> > + return undef unless defined $str;
>
> Given that the _whole_ point of this subroutine is to make $str safe for
> printing, wouldn't you want to either (1) die, declaring that feeding an
> undef to this subroutine is a programming error, or (2) return an empty
> string?
Well, that
return undef unless defined $str;
line is copy'n'paste (as is most of sanitize() body) from esc_html().
This line was added in 1df4876 (gitweb: Protect escaping functions against
calling on undef, 2010-02-07) with the following explanation
This is a bit of future-proofing esc_html and friends: when called
with undefined value they would now would return undef... which would
probably mean that error would still occur, but closer to the source
of problem.
This means that we can safely use
esc_html(shift) || "Internal Server Error"
in die_error() instead of
esc_html(shift || "Internal Server Error")
So actually now I see that while this line is good to have in esc_html(),
it is not really necessary in sanitize().
But anyway we don't want to replace undef with an empty string; undef is
(usually) an error, and we want to catch it, not to hide it.
> Given that the input to this function is from the result of feeding $line
> to untabify, which relies on $line being defined, and that $line comes
> from "while (my $line = <$fd>)" (and then chomp $line), it may be Ok for
> this subroutine to make the same assumption as untabify makes.
Right.
Passing undef to sanitize() is usually an error, and we don't want to hide
it. We want for gitweb test to detect it.
--
Jakub Narebski
Poland
next prev parent reply other threads:[~2011-09-16 18:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-22 22:58 [PATCH] gitweb: highlight: strip non-printable characters via col(1) Christopher M. Fuhrman
2011-08-22 23:21 ` Junio C Hamano
2011-08-26 19:54 ` Jakub Narebski
2011-08-26 21:44 ` Junio C Hamano
2011-08-26 22:06 ` Jakub Narebski
2011-09-16 12:41 ` [PATCH] gitweb: Strip non-printable characters from syntax highlighter output Jakub Narebski
2011-09-16 16:32 ` Junio C Hamano
2011-09-16 18:58 ` Jakub Narebski [this message]
2011-09-16 20:24 ` Junio C Hamano
2011-09-16 18:11 ` Christopher M. Fuhrman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201109162058.51132.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=cfuhrman@panix.com \
--cc=cwilson@cdwilson.us \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sylvain@abstraction.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).