comparison extra/soundsoftware/SoundSoftware.pm @ 733:c7a731db96e5 feature_318

Syntax fixes etc
author Chris Cannam
date Fri, 04 Nov 2011 11:02:56 +0000
parents 897bc2b63bfe
children 1d1b8170c2f7
comparison
equal deleted inserted replaced
732:897bc2b63bfe 733:c7a731db96e5
243 243
244 print STDERR "SoundSoftware.pm:$$: Project is private or nonexistent, auth required\n"; 244 print STDERR "SoundSoftware.pm:$$: Project is private or nonexistent, auth required\n";
245 # fall through 245 # fall through
246 } 246 }
247 247
248 my $cfg = Apache2::Module::get_config
249 (__PACKAGE__, $r->server, $r->per_dir_config);
248 if ($cfg->{SoundSoftwareSslRequired} eq "on") { 250 if ($cfg->{SoundSoftwareSslRequired} eq "on") {
249 if ($r->dir_config('HTTPS') eq "on") { 251 if ($r->dir_config('HTTPS') eq "on") {
250 return OK; 252 return OK;
251 } else { 253 } else {
252 my $redir_to = "https://" . $r->hostname() . $r->unparsed_uri(); 254 my $redir_to = "https://" . $r->hostname() . $r->unparsed_uri();
253 print STDERR "SoundSoftware.pm:$$: Need to switch to HTTPS, redirecting to $redir_to\n"; 255 print STDERR "SoundSoftware.pm:$$: Need to switch to HTTPS, redirecting to $redir_to\n";
254 $r->header_out(Location => $redir_to); 256 $r->headers_out->add('Location' => $redir_to);
255 return REDIRECT; 257 return REDIRECT;
256 } 258 }
257 } else if ($cfg->{SoundSoftwareSslRequired} eq "off") { 259 } elsif ($cfg->{SoundSoftwareSslRequired} eq "off") {
258 return OK; 260 return OK;
259 } else { 261 } else {
260 print STDERR "WARNING: SoundSoftware.pm:$$: SoundSoftwareSslRequired should be either 'on' or 'off'\n"; 262 print STDERR "WARNING: SoundSoftware.pm:$$: SoundSoftwareSslRequired should be either 'on' or 'off'\n";
261 return OK; 263 return OK;
262 } 264 }
506 508
507 # be timid about characters not permitted in auth realm and revert 509 # be timid about characters not permitted in auth realm and revert
508 # to project identifier if any are found 510 # to project identifier if any are found
509 if ($name =~ m/[^\w\d\s\._-]/) { 511 if ($name =~ m/[^\w\d\s\._-]/) {
510 $name = $project_id; 512 $name = $project_id;
513 } elsif ($name =~ m/^\s*$/) {
514 # empty or whitespace
515 $name = $project_id;
516 }
517
518 if ($name =~ m/^\s*$/) {
519 # nothing even in $project_id -- probably a nonexistent project.
520 # use repo name instead (don't want to admit to user that project
521 # doesn't exist)
522 my $location = $r->location;
523 my ($repo) = $r->uri =~ m{$location/*([^/]+)};
524 $name = $repo;
511 } 525 }
512 526
513 my $realm = '"Mercurial repository for ' . "'$name'" . '"'; 527 my $realm = '"Mercurial repository for ' . "'$name'" . '"';
514 528
515 $realm; 529 $realm;