From 084da8e159053780145548082db7e3289c1ece52 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 4 Sep 2009 09:05:03 -0700 Subject: [PATCH] fix #10891: Change session->output->print to skip macros based on detecting the mime-type. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Session/Output.pm | 11 ++++++----- t/Session/Output.t | 7 ++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 82b826db4..6ef3824fe 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,6 +9,7 @@ - fixed #10883: Recover Password / Auth::WebGUI /getSiteUrl - fixed #10892: In/Out Board - fixed #10893: Code editor uses element-min.js + - fixed #10891: Asset manager JSON feed has macros processed 7.7.19 - fixed #10838: Forwarded forum post email to new CS adds reply to original thread diff --git a/lib/WebGUI/Session/Output.pm b/lib/WebGUI/Session/Output.pm index 3ad462f8d..fdff0c997 100644 --- a/lib/WebGUI/Session/Output.pm +++ b/lib/WebGUI/Session/Output.pm @@ -80,15 +80,16 @@ The content to output. =head3 skipMacros -A boolean indicating whether to skip macro processing on this content. +A boolean indicating whether to skip macro processing on this content. If the mime type +has been set to a non-text type, macros will automatically be skipped. =cut sub print { - my $self = shift; - my $content = shift; - my $skipMacros = shift; - WebGUI::Macro::process($self->session, \$content) unless $skipMacros; + my $self = shift; + my $content = shift; + my $skipMacros = shift || !($self->session->http->getMimeType =~ /^text/); + WebGUI::Macro::process($self->session, \$content) unless $skipMacros; my $handle = $self->{_handle}; if (defined $handle) { print $handle $content; diff --git a/t/Session/Output.t b/t/Session/Output.t index 539ed9190..bf5fdde14 100644 --- a/t/Session/Output.t +++ b/t/Session/Output.t @@ -17,7 +17,7 @@ use WebGUI::Session; use Test::More; # increment this value for each test you create -my $skip_tests = 7; +my $skip_tests = 8; my $num_tests = 1 + $skip_tests; plan tests => $num_tests; @@ -56,6 +56,11 @@ SKIP: { $output->print('^#;', 1); like($request->get_output, qr/\^#;\Z/, 'print: macro processing skipped'); + $session->http->setMimeType('application/json'); + $output->print('^#;'); + like($request->get_output, qr/\^#;\Z/, 'print: macro processing skipped'); + + $session->http->setMimeType(''); $output->setHandle($otherHandle); $output->print('New content'); is($otherHandleBuffer, 'New content', 'print: set to explicit handle');