+2.06 2006-07-21
+ * Allow for JSONDump to swap --> to --"+">
+ * Fix memory issue in App with closures
+ * Remove weak_copy routine from Template (memory issue)
+
2.05 2006-07-19
* Allow for CGI::Ex to be compatible with Mandrake and Fedora mod_perl 2, as well as debian mod_perl2
and older mod_perl1.
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: CGI-Ex
-version: 2.05
+version: 2.06
version_from: lib/CGI/Ex.pm
installdirs: site
requires:
use base qw(Exporter);
BEGIN {
- $VERSION = '2.05';
+ $VERSION = '2.06';
$PREFERRED_CGI_MODULE ||= 'CGI';
@EXPORT = ();
@EXPORT_OK = qw(get_form
use vars qw($VERSION);
BEGIN {
- $VERSION = '2.05';
+ $VERSION = '2.06';
Time::HiRes->import('time') if eval {require Time::HiRes};
+ eval {require Scalar::Util};
}
sub croak {
my ($self, $step, $file, $swap) = @_;
my $args = $self->run_hook('template_args', $step);
- $args->{'INCLUDE_PATH'} ||= sub { $self->base_dir_abs || die "Could not find base_dir_abs while looking for template INCLUDE_PATH on step \"$step\"" };
+ my $copy = $self;
+ eval {require Scalar::Util; Scalar::Util::weaken($copy)};
+ $args->{'INCLUDE_PATH'} ||= sub { $copy->base_dir_abs || die "Could not find base_dir_abs while looking for template INCLUDE_PATH on step \"$step\"" };
require CGI::Ex::Template;
my $t = CGI::Ex::Template->new($args);
return $self->{'hash_base'} ||= do {
### create a weak copy of self to use in closures
- my $copy;
- if (eval {require Scalar::Util} && defined &Scalar::Util::weaken) {
- $copy = $self;
- Scalar::Util::weaken($copy);
- } else {
- $copy = bless {%$self}, ref($self); # hackish way to avoid circular refs on older perls (pre 5.8)
- }
-
+ my $copy = $self;
+ eval {require Scalar::Util; Scalar::Util::weaken($copy)};
my $hash = {
script_name => $ENV{'SCRIPT_NAME'} || $0,
path_info => $ENV{'PATH_INFO'} || '',
use Digest::MD5 qw(md5_hex);
use CGI::Ex;
-$VERSION = '2.05';
+$VERSION = '2.06';
###----------------------------------------------------------------###
);
@EXPORT_OK = qw(conf_read conf_write in_cache);
-$VERSION = '2.05';
+$VERSION = '2.06';
$DEFAULT_EXT = 'conf';
use strict;
use Exporter;
-$VERSION = '2.05';
+$VERSION = '2.06';
@ISA = qw(Exporter);
@EXPORT = qw(dex dex_warn dex_text dex_html ctrace dex_trace);
@EXPORT_OK = qw(dex dex_warn dex_text dex_html ctrace dex_trace debug);
use base qw(Exporter);
BEGIN {
- $VERSION = '2.05';
+ $VERSION = '2.06';
@EXPORT = qw(form_fill);
@EXPORT_OK = qw(fill form_fill html_escape get_tagval_by_key swap_tagval_by_key);
};
use base qw(Exporter);
BEGIN {
- $VERSION = '2.05';
+ $VERSION = '2.06';
@EXPORT = qw(JSONDump);
@EXPORT_OK = @EXPORT;
utf8::decode($str) if $self->{'utf8'} && &utf8::decode;
### escape <html> and </html> tags in the text
- $str =~ s{(</? (?: htm | scrip | !-))}{$1$quote+$quote}gx;
+ $str =~ s{(</? (?: htm | scrip | !-) | --(?=>) )}{$1$quote+$quote}gx;
### add nice newlines (unless pretty is off)
if ($self->{'str_nl'} && length($str) > 80) {
);
BEGIN {
- $VERSION = '2.05';
+ $VERSION = '2.06';
$PACKAGE_EXCEPTION = 'CGI::Ex::Template::Exception';
$PACKAGE_ITERATOR = 'CGI::Ex::Template::Iterator';
$WHILE_MAX = 1000;
$EXTRA_COMPILE_EXT = '.sto';
+
+ eval {require Scalar::Util};
};
###----------------------------------------------------------------###
$sub_tree = $sub_tree->[0]->[4];
}
- my $self_copy = $self->weak_copy;
+ my $self_copy = $self;
+ eval {require Scalar::Util; Scalar::Util::weaken($self_copy)};
### install a closure in the stash that will handle the macro
$self->set_variable($name, sub {
};
}
-### get a copy of self without circular refs for use in closures
-sub weak_copy {
- my $self = shift;
- my $self_copy;
- if (eval { require Scalar::Util }
- && defined &Scalar::Util::weaken) {
- $self_copy = $self;
- Scalar::Util::weaken($self_copy);
- } else {
- $self_copy = bless {%$self}, ref($self); # hackish way to avoid circular refs on old perls (pre 5.8)
- }
- return $self_copy;
-}
-
sub debug_node {
my ($self, $node) = @_;
my $info = $self->node_info($node);
Methods by these names implement virtual methods that are more than one line.
-=item C<weak_copy>
-
-Used to create a weak reference to self to avoid circular references. (this
-is needed by macros)
-
=back
@UNSUPPORTED_BROWSERS
);
-$VERSION = '2.05';
+$VERSION = '2.06';
$DEFAULT_EXT = 'val';
$QR_EXTRA = qr/^(\w+_error|as_(array|string|hash)_\w+|no_\w+)/;
=cut
use strict;
-use Test::More tests => 49;
+use Test::More tests => 52;
use_ok('CGI::Ex::JSONDump');
test_dump('<script>', "'<scrip'+'t>'", {single_quote => 1});
test_dump('<html>', '"<htm"+"l>"');
test_dump('<!--', '"<!-"+"-"');
+test_dump('-->', '"--"+">"');
+test_dump('---', '"---"');
+test_dump('--', '"--"');
test_dump('"', '"\\""');
test_dump('a', "'a'", {single_quote => 1});
test_dump('"', "'\"'", {single_quote => 1});