From 75dbfe1dc03748957f07eca5ac583bedc6fdba76 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Tue, 9 Oct 2018 17:01:07 -0400 Subject: Bug 623384 - Use Module::Runtime instead of eval { require } or eval "use" --- Bugzilla/WebService/Server.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Bugzilla/WebService') diff --git a/Bugzilla/WebService/Server.pm b/Bugzilla/WebService/Server.pm index a76c4c48c..e02788911 100644 --- a/Bugzilla/WebService/Server.pm +++ b/Bugzilla/WebService/Server.pm @@ -11,12 +11,15 @@ use 5.10.1; use strict; use warnings; +use Bugzilla::Logging; use Bugzilla::Error; use Bugzilla::Util qw(datetime_from); use Digest::MD5 qw(md5_base64); use Scalar::Util qw(blessed); use Storable qw(freeze); +use Module::Runtime qw(require_module); +use Try::Tiny; sub handle_login { my ($self, $class, $method, $full_method) = @_; @@ -30,8 +33,13 @@ sub handle_login { Bugzilla->request_cache->{dont_persist_session} = 1; } - eval "require $class"; - ThrowCodeError('unknown_method', {method => $full_method}) if $@; + try { + require_module($class); + } + catch { + ThrowCodeError('unknown_method', {method => $full_method}); + FATAL($_); + }; return if ($class->login_exempt($method) and !defined Bugzilla->input_params->{Bugzilla_login}); Bugzilla->login(); -- cgit v1.2.3-24-g4f1b