OSDN Git Service

Plugin::ResponseFilter: fix to work correctly when 'result' attribue is scalar
[newslash/newslash.git] / 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});