Treat undefined variables as empty string in tests.
[matthijs/upstream/blosxom-plugins.git] / general / interpolate_fancy
index 4f5b6ebc3ec01d201a416e57ec77bb9a45871fef..4b8b759777373a01aa5093a56b6d6b4151caeb2e 100644 (file)
@@ -134,7 +134,7 @@ sub do_interpolate {
     # Variable expansion (unconditional, recursive)
     #
     # e.g. <$var />
-    while( $template =~ s/<\$([a-zA-Z?]\w+(?:::\w+)*)\s+?\/>/"defined \$$1 ? \$$1 : undef"/gsee ) { }
+    while( $template =~ s/<\$([a-zA-Z?]\w+(?:::\w+)*)\s+?\/>/"defined \$$1 ? \$$1 : ''"/gsee ) { }
 
     #
     # Actions 
@@ -155,6 +155,11 @@ sub do_interpolate {
 
 sub _test {
   my($variable, $attr) = @_;
+  # If the variable is not defined, treat it as the empty string in
+  # comparisons below
+  if (!defined $variable) { 
+    $variable = '';
+  }
   my $attributes = interpolate_fancy::_attributes($attr);
 
   defined $attributes->{eq} and return $variable eq $attributes->{eq};