use strictures 1;
use UNIVERSAL::ref;
use Safe::Isa;
+use Scalar::Util qw(blessed);
use Data::Munge;
use overload
;
sub new {
- if (ref($_[0])) { my $c = shift; return $c->_hsv_unescaped_string->new(@_) }
+ if (blessed($_[0])) {
+ my $c = shift;
+ return $c->_hsv_unescaped_string->new(@_);
+ }
my ($class, @raw_parts) = @_;
my $opts = (ref($raw_parts[-1]) eq 'HASH') ? pop(@raw_parts) : {};
s/</</g;
s/>/>/g;
s/"/"/g;
+ s/'/'/g;
} $_->[0]
: $_->[0]
), @{$self->{parts}};
push @parts, @new_parts;
}
- return ref($self)->new(@parts, { ignore => $self->{ignore} });
+ return bless({ %$self, parts => \@parts }, blessed($self));
}
sub _hsv_is_true {
return 1 if grep $_, map $_->[0], @{$self->{parts}};
}
+# we need to local $@ here because some modules (cough, TT, cough)
+# will do a 'die $@ if $@' without realising that it wasn't their eval
+# that set it
+
sub isa {
my $self = shift;
return (
- eval { $self->_hsv_unescaped_string->isa(@_) }
+ do {
+ local $@;
+ eval { blessed($self) and $self->_hsv_unescaped_string->isa(@_) }
+ }
or $self->SUPER::isa(@_)
);
}
sub can {
my $self = shift;
return (
- eval { $self->_hsv_unescaped_string->can(@_) }
+ do {
+ local $@;
+ eval { blessed($self) and $self->_hsv_unescaped_string->isa(@_) }
+ }
or $self->SUPER::can(@_)
);
}
[ 'some text that will not be escaped', 0 ]
- [ 'text that you DO want to be scaped', 1 ]
+ [ 'text that you DO want to be escaped', 1 ]
$existing_html_string_value