Skip to content

Commit

Permalink
Item13278: dump support for qr in Foswiki.spec. It'll still work, but…
Browse files Browse the repository at this point in the history
… is discouraged
  • Loading branch information
Comment committed Mar 1, 2015
1 parent 3d0361b commit 7027a86
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions core/lib/Foswiki.spec
Expand Up @@ -461,7 +461,7 @@ $Foswiki::cfg{TemplateLogin}{AllowLoginUsingEmailAddress} = 0;
# environments may require funny characters in login names, such as \.
# This is a filter *in* expression, so a login name must match this
# expression or an error will be thrown and the login denied.
$Foswiki::cfg{LoginNameFilterIn} = qr/^[^\s\*?~^\$@%`"'&;|<>\x00-\x1f]+$/;
$Foswiki::cfg{LoginNameFilterIn} = '^[^\s\*?~^\$@%`"\'&;|<>\x00-\x1f]+$';

# **STRING 20 LABEL="Default User Login" EXPERT**
# Guest user's login name. You are recommended not to change this.
Expand Down Expand Up @@ -982,7 +982,7 @@ $Foswiki::cfg{UploadFilter} = '^(\.htaccess|.*\.(?i)(?:php[0-9s]?(\..*)?|[sp]htm
# include paths and skin names. This is a filter *out*, so if any of the
# characters matched by this expression are seen in names, they will be
# removed.
$Foswiki::cfg{NameFilter} = qr/[\s\*?~^\$@%`"'\x26;|\x3c>\[\]#\x00-\x1f]/;
$Foswiki::cfg{NameFilter} = '[\\s\\*?~^\\$@%`"\'\\x26;|\\x3c>\\[\\]#\\x00-\\x1f]';

# **BOOLEAN LABEL="Force unsafe Regular Expressions" EXPERT**
# If this is set, then the search module will use more relaxed
Expand Down
21 changes: 12 additions & 9 deletions core/lib/Foswiki/Configure/LoadSpec.pm
Expand Up @@ -391,17 +391,20 @@ sub parse {

# Configure treats all regular expressions as simple quoted string,
# Convert from qr/ / notation to a simple quoted string
if ( $open->{typename} eq 'REGEX' ) {
if ( $open->{default} =~ m/^qr/ ) {
my $value = eval "$open->{default}";
if ( $open->{typename} eq 'REGEX'
&& $open->{default} =~ /^qr(.)(.*)\1$/ )
{

# Strip off useless furniture (?^: ... )
$value =~ s/^\(\?\^:(.*)\)$/$1/;
$open->{default} = "$value";
}
else {
$open->{default} =~ s/\\\'/'/g; # Un-escape single quotes
# Convert a qr// into a quoted string

# Strip off useless furniture (?^: ... )
while ( $open->{default} =~ s/^\(\?\^:(.*)\)$/$1/ ) {
}

# Convert quoting for a single-quoted string. All we
# need to do is protect single quote
$open->{default} =~ s/'/\\\\'/g;
$open->{default} = "'" . $open->{default} . "'";
}

$open->{keys} = $keys;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/LoginManager.pm
Expand Up @@ -1336,7 +1336,7 @@ sub isValidLoginName {

# this function was erroneously marked as static
ASSERT( !ref($name) ) if DEBUG;
return $name =~ /$Foswiki::cfg{LoginNameFilterIn}/;
return $name =~ m/$Foswiki::cfg{LoginNameFilterIn}/o;
}

=begin TML
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Render.pm
Expand Up @@ -1513,7 +1513,7 @@ sub _handleSquareBracketedLink {
$link =~ s/\&\#[0-9]+\;//g;

# Filter junk
$link =~ s/$Foswiki::cfg{NameFilter}+/ /g;
$link =~ s/$Foswiki::cfg{NameFilter}+/ /go;

ASSERT( UNTAINTED($link) ) if DEBUG;

Expand Down
4 changes: 2 additions & 2 deletions core/lib/Foswiki/Sandbox.pm
Expand Up @@ -215,7 +215,7 @@ sub validateAttachmentName {
else {

# Filter nasty characters
$component =~ s/$Foswiki::cfg{NameFilter}//g;
$component =~ s/$Foswiki::cfg{NameFilter}//go;
push( @result, $component );
}
}
Expand All @@ -239,7 +239,7 @@ sub _cleanUpFilePath {
if ( $component eq '..' ) {
throw Error::Simple( 'relative path in filename ' . $string );
}
elsif ( $component =~ /$Foswiki::cfg{NameFilter}/ ) {
elsif ( $component =~ m/$Foswiki::cfg{NameFilter}/o ) {
throw Error::Simple( 'illegal characters in file name component "'
. $component
. '" of filename '
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/UserMapping.pm
Expand Up @@ -568,7 +568,7 @@ sub validateRegistrationField {

if ( ( lc( $_[1] ) eq 'username' )
&& length( $_[2] )
&& !( $_[2] =~ m/$Foswiki::cfg{LoginNameFilterIn}/ ) )
&& !( $_[2] =~ m/$Foswiki::cfg{LoginNameFilterIn}/o ) )
{
throw Error::Simple("Invalid $_[1]");
}
Expand Down

0 comments on commit 7027a86

Please sign in to comment.