OSDN Git Service

Plugin::ResponseFilter: fix to work correctly when 'result' attribue is scalar
authorhylom <hylom@users.osdn.me>
Mon, 17 Jun 2019 09:09:23 +0000 (09:09 +0000)
committerhylom <hylom@users.osdn.me>
Mon, 17 Jun 2019 09:09:23 +0000 (09:09 +0000)
src/newslash_web/lib/Newslash/Plugin/ResponseFilter.pm

index ab3774f..37f75d8 100644 (file)
@@ -23,7 +23,11 @@ sub register {
                       return if (!defined $args->{json});
 
                       my $json = $args->{json};
-                      my $result = $json->{result} || $json;
+                      my $result = $json;
+                      if (defined $json->{result} && ref($json->{result} eq "HASH")) {
+                          $result = $json->{result};
+                      }
+
                       if ($result->{item}) {
                           if ($result->{item}->{content_type}) {
                               apply_seclev_filter($c, $result->{item}->{content_type}, $result->{item});