Skip to content

Commit

Permalink
Item12180: Correct logging error. Finish URL Regexps. Substitute chan…
Browse files Browse the repository at this point in the history
…ge for hacks. Fix my initialization errors. Improve MAILHOST checking and UI. Simplify ws probe. Complicate ws probe.

git-svn-id: http://svn.foswiki.org/trunk@16227 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
TimotheLitt authored and TimotheLitt committed Dec 16, 2012
1 parent faa88a2 commit ae1e53d
Show file tree
Hide file tree
Showing 22 changed files with 130 additions and 88 deletions.
14 changes: 9 additions & 5 deletions core/lib/Foswiki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# to return the <code>DefaultUrlHost</code>.</p>
$Foswiki::cfg{ForceDefaultUrlHost} = $FALSE;

# **URLPATH CHECK="expand" T M**
# **URLPATH CHECK="expand" M**
# This is the 'cgi-bin' part of URLs used to access the Foswiki bin
# directory e.g. <code>/foswiki/bin</code><br />
# Do <b>not</b> include a trailing /.
Expand All @@ -70,7 +70,7 @@ $Foswiki::cfg{ForceDefaultUrlHost} = $FALSE;
# be manually added to <code>lib/LocalSite.cfg</code>
# $Foswiki::cfg{ScriptUrlPath} = '/foswiki/bin';

# **URLPATH CHECK='expand nullok' T E M U**
# **URLPATH CHECK='expand nullok' E M U**
# This is the complete path used to access the Foswiki view script including any suffix. Do not include a trailing /.
# (This is an exception override, so the ScriptSuffix is not automatically added.)
# e.g. <code>/foswiki/bin/view.pl</code><br /> Note: The default is acceptable except when shorter URLs are used.
Expand Down Expand Up @@ -1747,8 +1747,7 @@ $Foswiki::cfg{WebMasterEmail} = '';
# buttons to provide useful information.</p>
$Foswiki::cfg{WebMasterName} = 'Wiki Administrator';

# **STRING 30 FEEDBACK=AUTO \
# DISPLAY_IF /^Net::SMTP/.test({Email}{MailMethod})**
# **STRING 30 FEEDBACK=AUTO **
# Mail host for outgoing mail. This is only used if Net::SMTP is used.
# Examples: <tt>mail.your.company</tt> If the smtp server uses a different port
# than the default 25 # use the syntax <tt>mail.your.company:portnumber</tt>
Expand Down Expand Up @@ -1862,7 +1861,12 @@ $Foswiki::cfg{ConfigureGUI}{SMIME}{InstallCert} = '';
# Net::SMTP (SSL),\
# Net::SMTP (TLS),\
# Net::SMTP (STARTTLS),\
# MailProgram **
# MailProgram \
# CHANGE="var s = $('[name=\"{SMTP}{MAILHOST}\"]');\
# if( ele.options[ele.selectedIndex].value === 'MailProgram' )\
# s.val(' ---- Unused when MailProgram selected ---');\
# else { if( /^ ---- Unused/.test(s.val()) )\
# s.val('');}" **
# Select the method Foswiki will use for sending email. On Unix/Linux hosts
# "MailProgram" is generally acceptable. Otherwise choose one of the Email
# methods required by your ISP or Email server.
Expand Down
12 changes: 8 additions & 4 deletions core/lib/Foswiki/Configure/Checkers/Certificate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ Issued by %s for %s", $xpv, ( $x->issuer_cn || 'Unknown issuer' ),
}
$notes .= '<br />' unless ( $notes =~ />$/ );

my %ku = map { $_ => 1 } @{ $x->KeyUsage } if ( $x->KeyUsage );
my %xku = map { $_ => 1 } @{ $x->ExtKeyUsage } if ( $x->ExtKeyUsage );
my %ku;
%ku = map { $_ => 1 } @{ $x->KeyUsage } if ( $x->KeyUsage );
my %xku;
%xku = map { $_ => 1 } @{ $x->ExtKeyUsage } if ( $x->ExtKeyUsage );
if ( $usage eq 'email' ) {
$errors .= " Not valid for email protection"
unless ( $xku{emailProtection}
Expand Down Expand Up @@ -300,8 +302,10 @@ Issued by %s for %s<br />", ( $x->issuer_cn || 'Unknown issuer' ),
}
$notes .= '<br />' unless ( $notes =~ />$/ );

my %ku = map { $_ => 1 } @{ $x->KeyUsage } if ( $x->KeyUsage );
my %xku = map { $_ => 1 } @{ $x->ExtKeyUsage }
my %ku;
%ku = map { $_ => 1 } @{ $x->KeyUsage } if ( $x->KeyUsage );
my %xku;
%xku = map { $_ => 1 } @{ $x->ExtKeyUsage }
if ( $x->ExtKeyUsage );
$errors .= " Not valid for Certificate Authority"
unless ( $ku{critical}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ sub loadKey {
)
{
my ( $pem, $format, $type, $headers ) = ( $1, $2, $3, $4 );
my %h = map { split( /:\s*/, $_, 2 ) } split( /\n/, $headers )
my %h;
%h = map { split( /:\s*/, $_, 2 ) } split( /\n/, $headers )
if ( defined $headers );

@key = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ sub generateForm {
}
push( @$changesList, { key => $key, value => $valueString } );
}
my @items = sortHashkeyList( keys %$updated ) if $modified;
my @items;
@items = sortHashkeyList( keys %$updated ) if $modified;

my $passChanged = ( defined $cart->param('{Password}') ) ? 1 : 0;

Expand Down
3 changes: 2 additions & 1 deletion core/lib/Foswiki/Configure/Checkers/EMAILADDRESS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ sub check {
$e .= $this->ERROR("Not defined");
}
else {
my @addrs = split( qr{$list}, $value ) if ( defined $list );
my @addrs;
@addrs = split( qr{$list}, $value ) if ( defined $list );
push @addrs, $value unless ( defined $list );

$e .= $this->ERROR("An e-mail address is required")
Expand Down
8 changes: 7 additions & 1 deletion core/lib/Foswiki/Configure/Checkers/Email/SSLCaFile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ sub check {
my $this = shift;
my ($valobj) = @_;

return '' unless ( $Foswiki::cfg{Email}{SSLVerifyServer} );
return ''
unless ( $Foswiki::cfg{Email}{MailMethod} =~ /^Net::SMTP/
&& $Foswiki::cfg{Email}{SSLVerifyServer} );

my $value = $this->getCfg;

Expand Down Expand Up @@ -86,6 +88,10 @@ sub provideFeedback {
my $this = shift;
my ( $valobj, $button, $label ) = @_;

return ''
unless ( $Foswiki::cfg{Email}{MailMethod} =~ /^Net::SMTP/
&& $Foswiki::cfg{Email}{SSLVerifyServer} );

$this->{FeedbackProvided} = 1;

# Normally, we call check first, but not if called by check.
Expand Down
8 changes: 6 additions & 2 deletions core/lib/Foswiki/Configure/Checkers/Email/SSLCaPath.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ sub check {
my $this = shift;
my ($valobj) = @_;

return '' unless ( $Foswiki::cfg{Email}{SSLVerifyServer} );
return ''
unless ( $Foswiki::cfg{Email}{MailMethod} =~ /^Net::SMTP/
&& $Foswiki::cfg{Email}{SSLVerifyServer} );

# This is quite similar to CaFile, but we recompute
# the defaults in case they depended on Path, but
Expand Down Expand Up @@ -96,7 +98,9 @@ sub provideFeedback {
my $this = shift;
my ( $valobj, $button, $label ) = @_;

return '' unless ( $Foswiki::cfg{Email}{SSLVerifyServer} );
return ''
unless ( $Foswiki::cfg{Email}{MailMethod} =~ /^Net::SMTP/
&& $Foswiki::cfg{Email}{SSLVerifyServer} );

$this->{FeedbackProvided} = 1;

Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Checkers/EnableEmail.pm
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ sub autoconfigPerl {

my @serverAuth = split( /\s+/, $serverAuth );
my $ok;
my %systemAuthMethods =
%systemAuthMethods =
( none => 1, map { uc($_) => 1 } $smtp->authValid() )
unless ( keys %systemAuthMethods );
foreach my $method (@serverAuth) {
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Checkers/PubUrlPath.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sub check {
<span name="{PubUrlPath}Ok">$ok</span>
<span name="{PubUrlPath}Error">$fail</span></span>
<span class="foswikiNonJS">Content under $value is accessible if the Foswiki logo appears to the right of this text.
<img name="{PubUrlPath}TestImage" src="$value$t" testImg="$t" style="margin-left:10px;height:15px;"
<img src="$value$t" style="margin-left:10px;height:15px;"
onload='\$("[name=\\"\\{PubUrlPath\\}Error\\"],[name=\\"\\{PubUrlPath\\}Wait\\"]").hide();\$("[name=\\"\\{PubUrlPath\\}Ok\\"]").show();'
onerror='\$("[name=\\"\\{PubUrlPath\\}Ok\\"],[name=\\"\\{PubUrlPath\\}Wait\\"]").hide();\$("[name=\\"\\{PubUrlPath\\}Error\\"]").show();'><br >If it does not appear, check the setting and webserver configuration.</span>}
);
Expand Down
37 changes: 22 additions & 15 deletions core/lib/Foswiki/Configure/Checkers/SMTP/MAILHOST.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@ sub check {
my $e = '';

if ( $Foswiki::cfg{EnableEmail} ) {
if ( $Foswiki::cfg{Email}{MailMethod} eq "MailProgram" ) {
if ( $Foswiki::cfg{SMTP}{MAILHOST} ) {
$e .= $this->NOTE(
"MAILHOST is not used for configured MailMethod $Foswiki::cfg{Email}{MailMethod}"
);
my $host = $Foswiki::cfg{SMTP}{MAILHOST} || '';
my $method = $Foswiki::cfg{Email}{MailMethod} || 'Net::SMTP';
if ( $method =~ /^Net::SMTP/ ) {
if ( $host = $Foswiki::cfg{SMTP}{MAILHOST} ) {
if ( $host =~ m/^([^:]+)(?::([0-9]{2,5}))?$/ ) {
( $host, my $port ) = ( $1, $2 );
my ( undef, undef, undef, undef, @addrs ) =
gethostbyname($host);
unless (@addrs) {
$e .= $this->ERROR(
"$host is invalid: server has no IP address");
}
}
else {
$e .= $this->ERROR(
"Syntax error: must be hostname with optional : numeric port"
);
}
}
}
else {
unless ( $Foswiki::cfg{SMTP}{MAILHOST} ) {
$e .= $this->ERROR(
"Hostname or address required for $Foswiki::cfg{Email}{MailMethod}."
);
else {
$e .= $this->ERROR("Hostname or address required for $method.");
}
}
}
Expand All @@ -47,16 +56,14 @@ sub provideFeedback {

$this->{FeedbackProvided} = 1;

my $keys = $valobj->getKeys;

# Normally, we call check first, but not if called by check.

my $e = $button ? $this->check($valobj) : '';

my $keys = $valobj->getKeys();

delete $this->{FeedbackProvided};

# We only need to run the checker for button 1

return wantarray ? ( $e, 0 ) : $e;
}

Expand Down
4 changes: 2 additions & 2 deletions core/lib/Foswiki/Configure/Checkers/ScriptUrlPath.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ HERE
<span name="{ScriptUrlPath}Ok">$ok</span>
<span name="{ScriptUrlPath}Error">$fail</span></span>
<span class="foswikiNonJS">Content under $value is accessible if a green check appears to the right of this text.
<img name="{ScriptUrlPath}TestImage" src="$value$t" testImg="$t" style="margin-left:10px;height:15px;"
onload='\$("[name=\\"\\{ScriptUrlPath\\}Error\\"],[name=\\"\\{ScriptUrlPath\\}Wait\\"]").hide();\$("[name=\\"\\{ScriptUrlPath\\}Ok\\"]").show();'
<img src="$value$t" style="margin-left:10px;height:15px;"
onload='\$("[name=\\"\\{ScriptUrlPath\\}Error\\"],[name=\\"\\{ScriptUrlPath\\}Wait\\"]").hide().find("div.configureWarn,div.configureError").removeClass("configureWarn configureError");\$("[name=\\"\\{ScriptUrlPath\\}Ok\\"]").show();'
onerror='\$("[name=\\"\\{ScriptUrlPath\\}Ok\\"],[name=\\"\\{ScriptUrlPath\\}Wait\\"]").hide();\$("[name=\\"\\{ScriptUrlPath\\}Error\\"]").show();'><br >If it does not appear, check the setting and webserver configuration.</span>}
);
$this->{JSContent} = 1;
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Foswiki/Configure/Checkers/ScriptUrlPaths.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ sub check {
<span name="${keys}Ok">$ok</span>
<span name="${keys}Error">$fail</span></span>
<span class="foswikiNonJS">Content under $dval is accessible if a green check appears to the right of this text.
<img name="${keys}TestImage" src="$value$t" testImg="$t" style="margin-left:10px;height:15px;"
onload='\$("[name=\\"${qkeys}Error\\"],[name=\\"${qkeys}Wait\\"]").hide();\$("[name=\\"${qkeys}Ok\\"]").show();'
<img src="$value$t" style="margin-left:10px;height:15px;"
onload='\$("[name=\\"${qkeys}Error\\"],[name=\\"${qkeys}Wait\\"]").hide().find("div.configureWarn,div.configureError").removeClass("configureWarn configureError");configure.toggleExpertsMode("");\$("[name=\\"${qkeys}Ok\\"]").show();'
onerror='\$("[name=\\"${qkeys}Ok\\"],[name=\\"${qkeys}Wait\\"]").hide();\$("[name=\\"${qkeys}Error\\"]").show();'><br >If it does not appear, check the setting and webserver configuration.</span>}
);
$this->{JSContent} = 1;
Expand Down
15 changes: 11 additions & 4 deletions core/lib/Foswiki/Configure/Checkers/URL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ sub check {
if ( $parts->{path} ) {
if ( defined $path ) {
if ( $scheme =~ /^https?$/i || !$parts->{scheme} ) {
unless (
$path =~ m,^(?:/|(?:/(?:\w|%[[:xdigit:]]{2})+)*)$, )
unless ( $path =~
m{^(?:/|(?:/(?:[+a-zA-Z0-9\$_\@.&!*"'(),-]|%[[:xdigit:]]{2})+)*)$}
)
{
$e .= $this->ERROR("Path is not valid");
}
Expand All @@ -196,7 +197,11 @@ sub check {

if ( $parts->{query} ) {
if ( defined $query ) {
; # Validate?
unless ( $query =~
m{\?(?:[a-zA-Z0-9\$_\@.&!*"'(),-]|%[[:xdigit:]]{2})*} )
{
$e .= $this->ERROR("Query is not valid");
}
}
elsif ( $partsReq->{query} ) {
$e .= $this->ERROR("Query is required for this item");
Expand All @@ -211,7 +216,9 @@ sub check {
if ( $parts->{fragment} ) {
if ( defined $fragment ) {
if ( $scheme =~ /^https?$/i ) {
unless ( $fragment =~ m,(?:/(?:\w|%[[:xdigit:]]{2}))*, ) {
unless ( $fragment =~
m{#(?:[a-zA-Z0-9\$_\@.&!*"'(),-]|%[[:xdigit:]]{2})*} )
{
$e .= $this->ERROR("Fragment is not valid");
}
} # Checks for other schemes?
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Dispatch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use version 0.77;

# minimum version of client JavaScript that configure requires.
#
my $minScriptVersion = version->parse("v3.116");
my $minScriptVersion = version->parse("v3.117");

use Foswiki::Configure (qw/:DEFAULT :auth :cgi :config :session :trace/);

Expand Down
17 changes: 9 additions & 8 deletions core/lib/Foswiki/Configure/Package.pm
Original file line number Diff line number Diff line change
Expand Up @@ -827,14 +827,15 @@ sub createBackup {
}
}

my ( $rslt, $err ) =
Foswiki::Configure::Util::createArchive( $bkname, $bkdir, '1' )
unless ( $this->{_options}->{SIMULATE} );

$rslt = ' - Simulated backup, no files copied '
if ( $this->{_options}->{SIMULATE} );

$rslt = "FAILED \n" . $err unless ($rslt);
my $rslt;
if ( $this->{_options}->{SIMULATE} ) {
$rslt = ' - Simulated backup, no files copied ';
}
else {
( $rslt, my $err ) =
Foswiki::Configure::Util::createArchive( $bkname, $bkdir, '1' );
$rslt = "FAILED \n" . $err unless ($rslt);
}

return "Backup saved into $pkgstore \n Archived as $rslt \n";
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Pluggables/SCRIPTHASH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ sub new {
$value->set(
keys => $keys,
desc => "Full URL for $script script. Rarely modified.",
opts => 'EXPERT T E CHECK="expand nullok"',
opts => 'EXPERT E CHECK="expand nullok"',
);

$value->addAuditGroup(qw/PARS:0/);
Expand Down
3 changes: 2 additions & 1 deletion core/lib/Foswiki/Configure/UI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,8 @@ sub getTemplateParser {
$DEFAULT_TEMPLATE_PARSER);
# skin can be set using url parameter 'skin'
my $skin = $Foswiki::query->param('skin') if $Foswiki::query;
my $skin;
$skin = $Foswiki::query->param('skin') if $Foswiki::query;
$templateParser->setSkin($skin) if $skin;
}
return $templateParser;
Expand Down
20 changes: 16 additions & 4 deletions core/lib/Foswiki/Configure/UIs/Value.pm
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ qq{<span class="configureCheckOnChange"><img src="${Foswiki::resourceURI}autoche
"$itemErrors $itemWarnings",
!( $itemErrors + $itemWarnings )
);
push @cssClasses, 'configureDisplayForced'
if ( $itemErrors || $itemWarnings );

my $resetToDefaultLinkText = '';

Expand Down Expand Up @@ -270,11 +272,7 @@ HERE
# Generate a prompter for the value.
my $promptclass = $value->{typename} || '';
$promptclass .= ' configureMandatory' if ( $value->{mandatory} );
$promptclass .= ' configureHasTestImage'
if ( $value->{opts} =~ /\bT\b/ );
if ( $value->{opts} =~ /\bE\b/ ) {
$promptclass .= ' configureHasEnable';

my $name = $keys;
$name =~ s/\}$/_\}/;
$hiddenTypeOf .=
Expand Down Expand Up @@ -316,6 +314,20 @@ qq{<input type="checkbox" name="$name" value="1" class="BOOLEAN configureItemEna
$props{class} = join( ' ', @cssClasses ) if ( scalar @cssClasses );
$props{'data-displayif'} = $displayIf if $displayIf;
$props{'data-enableif'} = $enableIf if $enableIf;
my $changeAction = $value->{changeAction} || '';
if ( $value->{opts} =~ /\bE\b/ ) {
$changeAction = << 'ENABLEJS' . $changeAction;
if( ele.value.length ) {
$('[name="' + configure.utils.quoteName(ele.name.replace(/\}$/,'_}')) + '"]').each(function() {
if( !this.checked ) {
this.checked = true;
}
return true;
});
}
ENABLEJS
}
$props{'data-change'} = $changeAction if $changeAction;

$check =
qq{<div id="${keys}status" class="configureFeedback" >$check</div>};
Expand Down
6 changes: 5 additions & 1 deletion core/lib/Foswiki/Configure/Value.pm
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ sub _setopts {
$this->{label} = _fixqs($1)
if ( $value =~ s/(?:\b|^)LABEL=($qsRE)(?:\s+|$)// );

$this->{changeAction} = _fixqs($1)
if ( $value =~ s/(?:\b|^)CHANGE=($qsRE)(?:\s+|$)// );

push @{ $this->{checkerOpts} }, _fixqs($1)
while ( $value =~ s/(?:\b|^)CHECK=($qsRE)(?:\s+|$)// );

Expand Down Expand Up @@ -208,7 +211,8 @@ sub addAuditGroup {
my $this = shift;

my $audits = $this->{audits};
my %present = map { $_ => 1 } @$audits if ($audits);
my %present;
%present = map { $_ => 1 } @$audits if ($audits);

foreach my $item (@_) {
unless ( $present{$item} ) {
Expand Down
Loading

0 comments on commit ae1e53d

Please sign in to comment.