]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commit
protect $@ whenever a block using $@ is non-trivial
authorSimon McVittie <smcv@debian.org>
Fri, 21 Feb 2014 17:06:36 +0000 (17:06 +0000)
committerSimon McVittie <smcv@debian.org>
Fri, 21 Feb 2014 17:06:36 +0000 (17:06 +0000)
commitbb359796b80d2e8bd36f6c8eafe9510874184e32
treefd25147af7e94441d0189810734a5f59617110ca
parentbe3483fe9be559a62dd88577b3a374d55b7262f3
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

    <span class="error">Error: failed to process template
    <span class="createlink">deftmpl</span> </span>

instead of the intended

    <span class="error">Error: failed to process template
    <span class="createlink">deftmpl</span> template deftmpl not
    found</span>

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
IkiWiki/Plugin/aggregate.pm
IkiWiki/Plugin/attachment.pm
IkiWiki/Plugin/editpage.pm
IkiWiki/Plugin/edittemplate.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/mdwn.pm
IkiWiki/Plugin/template.pm