On Tue Sep 01 16:26:21 2009, BUBAFLUB wrote:
Show quoted text> I don't suppose there is any "easier" or more elegant way? Is there
> anyway to distinguish when escapeHTML is being called internally in
> CGI.pm and when it's being called on it's own? There are around 30
> instances of escapeHTML being called in internal functions. If not I'll
> just tag every line (that has escapeHTML() in it) with an if statement
> checking if $self->{'escape'} is set.
So, to clarify, autoescape() should control whether or not CGI.pm
functions escape internally. Any direct call to escapeHTML should always
escapeHTML, as you would expect.
If we are on the same page, then perhaps this is another way to approach
it.
Internal functions could call _maybe_escapeHTML().
This logic from escapeHTML would be moved there:
return $toencode if ref($self) && !$self->{'escape'};
Then, _maybe_escapeHTML() can a have a little internal code comment
explaining what's going on.
To me that seems a little cleaner than adding "if" blocks everywhere we
call escapeHTML() internally.
Mark