Skip to content

Commit

Permalink
Item13186: Hijack this task to fix the script verify routine
Browse files Browse the repository at this point in the history
VERISON is an object, so we have to stringify it, or the JSON code
crashes.

The path checking needed changes in order of tests.
  • Loading branch information
gac410 committed Jan 9, 2015
1 parent 7a4e66b commit 50e50d9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
27 changes: 17 additions & 10 deletions core/lib/Foswiki/Configure/Wizards/ScriptHash.pm
Expand Up @@ -131,29 +131,36 @@ sub verify {
last;
}

my $target = $Foswiki::cfg{ScriptUrlPaths}{$script}
|| "$Foswiki::cfg{ScriptUrlPath}/$script"
. ( $Foswiki::cfg{ScriptSuffix} || '' );

if ( $info->{SCRIPT_NAME} eq $target ) {
$reporter->NOTE("Server received the expected path (=$target=)");
my $target = $Foswiki::cfg{ScriptUrlPaths}{$script};
unless ( defined $target ) {
$target = "$Foswiki::cfg{ScriptUrlPath}/$script"
. ( $Foswiki::cfg{ScriptSuffix} || '' );
}
elsif ( $script eq 'view' ) {
my $ptarget = ($target) ? $target : 'empty';

if ( $script eq 'view' ) {
if ( $info->{SCRIPT_NAME} eq $Foswiki::cfg{ScriptUrlPath} ) {
$reporter->NOTE(
"Server received =$info->{SCRIPT_NAME}=, which is the value of {ScriptUrlPaths}{$script}. This indicates that short(er) URLs are active and functioning correctly."
);
}
elsif ( $info->{SCRIPT_NAME} eq $target ) {
$reporter->NOTE(
"Server received the expected path: (=$ptarget=) ");
}
else {
$reporter->ERROR(
"Server received =$info->{SCRIPT_NAME}=, but the expected path is =$Foswiki::cfg{ScriptUrlPath}=.
Changing {ScriptUrlPaths}{view} to =$info->{SCRIPT_NAME}= will probably correct this error. (Server may be configured for Shorter URLs.)"
"Server received =($info->{SCRIPT_NAME})=, but the configured path to =view= is =($Foswiki::cfg{ScriptUrlPath})=.
Changing {ScriptUrlPaths}{view} to =($info->{SCRIPT_NAME})= will probably correct this error. (Server may be configured for Shorter URLs.)"
);
}
}
elsif ( $info->{SCRIPT_NAME} eq $target ) {
$reporter->NOTE("Server received the expected path: (=$ptarget=) ");
}
else {
$reporter->ERROR(
"Server received =$info->{SCRIPT_NAME}=, but the expected path is =$target=.
"Server received (=$info->{SCRIPT_NAME}=), but the expected path is =($ptarget)=.
The correct setting for $keys is probably =$info->{SCRIPT_NAME}=. (Server may be configured for Shorter URLs.)"
);
}
Expand Down
4 changes: 3 additions & 1 deletion core/lib/Foswiki/UI.pm
Expand Up @@ -236,11 +236,13 @@ sub handleRequest {
if ( $req->header('X-Foswiki-Tickle') ) {
my $data = {
SCRIPT_NAME => $ENV{SCRIPT_NAME},
VERSION => $Foswiki::VERSION,
VERSION => $Foswiki::VERSION->stringify(),
RELEASE => $Foswiki::RELEASE,
};
my $res = new Foswiki::Response();
$res->header( -type => 'application/json', -status => '200' );

# Need to allow_blessed since VERSION is a version object.
my $d = JSON->new->allow_nonref->encode($data);
$res->print($d);
return $res;
Expand Down

0 comments on commit 50e50d9

Please sign in to comment.