From b91a0b4ee71c8f8f2bd2c03ae6fff7249303722c Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Tue, 4 Feb 2020 15:38:24 +0000 Subject: =?UTF-8?q?[Z=C3=BCrich]=20Fix=20crash=20on=20certain=20/report/aj?= =?UTF-8?q?ax/=20URLs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attempting to load the /report/ajax/ URL for a problem that had a public response and wasn't in the ‘external’ state was causing a crash because the call to FixMyStreet::App::View::Web::add_links in updates_as_hashref was returning a FixMyStreet::Template::SafeString that the JSON module didn't know how to serialise. This commit adds a TO_JSON method to SafeString, and ensures the output of /report/ajax is JSON-encoded with convert_blessed turned on so the TO_JSON method is called. --- perllib/FixMyStreet/Template/SafeString.pm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'perllib/FixMyStreet/Template/SafeString.pm') diff --git a/perllib/FixMyStreet/Template/SafeString.pm b/perllib/FixMyStreet/Template/SafeString.pm index 619bee048..263937b39 100644 --- a/perllib/FixMyStreet/Template/SafeString.pm +++ b/perllib/FixMyStreet/Template/SafeString.pm @@ -69,6 +69,12 @@ sub clone { return $clone; } +sub TO_JSON { + my $self = shift; + + return $$self; +} + 1; __END__ -- cgit v1.2.3