Reported in
TWiki:Support.SID-01595:
Each time you save configure values, the regex variables get an extra enclosing
(?^:
...
)
. For example, an empty regex field looks like this after multiple configure saves:
(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:(?^:))))))))))))))))))))))
Fix: Fix regex values in configure by removing extra patterns recursively.
--
TWiki:Main/PeterThoeny - 2012-11-30
Patch:
--- TWiki/Configure/Types/REGEX.pm (revision 24236)
+++ TWiki/Configure/Types/REGEX.pm (working copy)
@@ -27,19 +27,31 @@
use base 'TWiki::Configure::Types::STRING';
+# TWikibug:Item7067: Configure adds extra (?^:) to regex variables
+# on save under Perl 5.14. This needs to be cleaned up.
+# SMELL: Regex cleanup needs to be done on 3 places:
+# * Here in sub string2value,
+# * Here in sub equals,
+# * TWiki::Configure::Valuer in sub _getValue.
+
sub prompt {
my( $this, $id, $opts, $value ) = @_;
$value = '' unless defined($value);
$value = "$value";
- while ($value =~ s/^\(\?-xism:(.*)\)$/$1/) { };
- $value =~ s/([[\x01-\x09\x0b\x0c\x0e-\x1f"%&'*<=>@[_\|])/'&#'.ord($1).';'/ge;
+
+ # Disabling this because the value should not appears changed in the authorise screen
+ # while ( $value =~ s/^\(\?-xism:(.*)\)$/$1/ ) { }
+ # while ( $value =~ s/^\(\?\^:(.*)\)/$1/ ) { }
+ # $value =~ s/([[\x01-\x09\x0b\x0c\x0e-\x1f"%&'*<=>@[_\|])/'&#'.ord($1).';'/ge;
+
my $res = '<input name="'.$id.'" type="text" size="55%" value="'.$value.'" />';
return $res;
}
sub string2value {
my ($this, $value) = @_;
- while ($value =~ s/^\(\?-xism:(.*)\)$/$1/) { };
+ while ( $value =~ s/^\(\?-xism:(.*)\)$/$1/ ) { }
+ while ( $value =~ s/^\(\?\^:(.*)\)/$1/ ) { }
return qr/$value/;
}
@@ -51,10 +63,10 @@
} elsif (!defined $def) {
return 0;
}
- while ($val =~ s/^\(\?-xism:(.*)\)$/$1/) {
- }
- while ($def =~ s/^\(\?-xism:(.*)\)$/$1/) {
- }
+ while ( $val =~ s/^\(\?-xism:(.*)\)$/$1/ ) { }
+ while ( $def =~ s/^\(\?-xism:(.*)\)$/$1/ ) { }
+ while ( $val =~ s/^\(\?\^:(.*)\)/$1/ ) { }
+ while ( $def =~ s/^\(\?\^:(.*)\)/$1/ ) { }
return $val eq $def;
}
--- TWiki/Configure/Valuer.pm (revision 24236)
+++ TWiki/Configure/Valuer.pm (working copy)
@@ -54,7 +54,15 @@
# SMELL: Really shouldn't do this unless we are sure it's an RE,
# but the probability of this string occurring elsewhere than an
# RE is so low that we can afford to take the risk.
- while ($val =~ s/^\(\?-xism:(.*)\)$/$1/) {};
+
+ # TWikibug:Item7067: Configure adds extra (?^:) to regex variables
+ # on save under Perl 5.14. This needs to be cleaned up.
+ # SMELL: Regex cleanup needs to be done on 3 places:
+ # * TWiki::Configure::Types::REGEX in sub string2value,
+ # * TWiki::Configure::Types::REGEX in sub equals,
+ # * Here in sub _getValue.
+ while ( $val =~ s/^\(\?-xism:(.*)\)$/$1/ ) { }
+ while ( $val =~ s/^\(\?\^:(.*)\)$/$1/ ) { }
}
return $val;
}
--
TWiki:Main/PeterThoeny - 2012-11-30
For TWiki sites running under Perl 5.14 or newer do this to fix the issue:
- Apply above patch
- Run configure, save changes - this fixes the regex values
--
TWiki:Main.PeterThoeny - 2012-11-30
Patch confirmed to be working at
TWiki:Support.SID-01595
--
PeterThoeny - 2012-12-06