[Bps-public-commit] rt-extension-articletemplates branch, request-args, updated. 0.04-4-g27d3cb2

Thomas Sibley trs at bestpractical.com
Wed Dec 7 11:06:58 EST 2011


The branch, request-args has been updated
       via  27d3cb20a741c20378b07311d68e8677fa207a16 (commit)
      from  9ef8a63246ef7d557cdb4105995b1d1c7e080196 (commit)

Summary of changes:
 .../RT-Extension-ArticleTemplates/ProcessContent   |    8 +++++++-
 lib/RT/Extension/ArticleTemplates.pm               |   12 ++++++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 27d3cb20a741c20378b07311d68e8677fa207a16
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Dec 7 11:06:18 2011 -0500

    Optionalize passing in request args; off by default for lower risk

diff --git a/html/Elements/RT-Extension-ArticleTemplates/ProcessContent b/html/Elements/RT-Extension-ArticleTemplates/ProcessContent
index 98d469a..94d3b99 100644
--- a/html/Elements/RT-Extension-ArticleTemplates/ProcessContent
+++ b/html/Elements/RT-Extension-ArticleTemplates/ProcessContent
@@ -1,5 +1,11 @@
 <%init>
-my ($new, $msg) = $Article->ParseTemplate( $$content, Ticket => $Ticket, request_args => { $m->request_args } );
+my %variables = ( Ticket => $Ticket );
+
+if (RT->Config->Get('ArticleTemplatesWithRequestArgs')) {
+    $variables{'request_args'} = { $m->request_args };
+}
+
+my ($new, $msg) = $Article->ParseTemplate( $$content, %variables );
 unless ( defined $new && length $new ) {
     $RT::Logger->error("Couldn't parse article's content: $msg");
 } else {
diff --git a/lib/RT/Extension/ArticleTemplates.pm b/lib/RT/Extension/ArticleTemplates.pm
index 5d142f1..76b9d82 100644
--- a/lib/RT/Extension/ArticleTemplates.pm
+++ b/lib/RT/Extension/ArticleTemplates.pm
@@ -39,6 +39,18 @@ To install it run the following commands:
 You'll also need to add RT::Extension::ArticleTemplates to your @Plugins
 config line.
 
+=head1 CONFIGURATION
+
+=head2 ArticleTemplatesWithRequestArgs
+
+Enabling this option passes in the Mason request arguments to your article
+templates as the hashref C<$request_args>.
+
+B<Warning>: Request args are user-controlled direct input, so all the normal
+cautions of using them apply.  Never trust user input.
+
+Disabled by default.
+
 =head1 AUTHOR
 
 Kevin Falcone E<lt>falcone at bestpractical.comE<gt>

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list