From bb359796b80d2e8bd36f6c8eafe9510874184e32 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 21 Feb 2014 17:06:36 +0000 Subject: protect $@ whenever a block using $@ is non-trivial As noted in the Try::Tiny man page, eval/$@ can be quite awkward in corner cases, because $@ has the same properties and problems as C's errno. While writing a regression test for definetemplate in which it couldn't find an appropriate template, I received Error: failed to process template deftmpl instead of the intended Error: failed to process template deftmpl template deftmpl not found which turned out to be because the "catch"-analogous block called gettext before it used $@, and gettext can call define_gettext, which uses eval. This commit alters all current "catch"-like blocks that use $@, except those that just do trivial things with $@ (string interpolation, string concatenation) and call a function (die, error, print, etc.) --- IkiWiki/CGI.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki/CGI.pm') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 5baa6c179..c0d8f598b 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -351,7 +351,8 @@ sub cgi_getsession ($) { { FileName => "$config{wikistatedir}/sessions.db" }) }; if (! $session || $@) { - error($@." ".CGI::Session->errstr()); + my $error = $@; + error($error." ".CGI::Session->errstr()); } umask($oldmask); -- cgit v1.2.3