package WebGUI::Macro::Scratch; #------------------------------------------------------------------- # Scratch Macro is Copyright 2007 Snapcount Ventures, LLC # http://www.snapcount.org snapcount@snapcount.org #------------------------------------------------------------------- use strict; use WebGUI::HTML; #------------------------------------------------------------------- sub process { my $session = shift; my $scratchName = shift; my $clobber = shift; # Fetch the variable's value my $scratchValue = $session->scratch->get("www_".$scratchName); # Clobber it if told to $session->scratch->delete("www_".$scratchName) if $clobber; # Take away any naughty stuff my $scratchValue = WebGUI::HTML::filter( $scratchValue, "all" ) if defined $scratchValue; return $scratchValue; } 1; =head1 USAGE ^Scratch(scratchVariableName, [ 1 ]); =head2 returns Value of www_scratchVariableName after filtering out HTML, JS, etc =head2 example With the following URL /home/?op=setScratch;scratchName=foo;scratchValue=bar and the macro used in content on /home like this ^Scratch(foo); it would return bar =head2 notes 1 - The scratch value is deleted after it's fetched if you pass a true value after the name of the scratch var 2 - No HTML, JavaScript, or other sillyness is allowed. This is to prevent XSS and other poo. =cut