changeset 733:c7a731db96e5 feature_318

Syntax fixes etc
author Chris Cannam
date Fri, 04 Nov 2011 11:02:56 +0000
parents 897bc2b63bfe
children 1d1b8170c2f7
files extra/soundsoftware/SoundSoftware.pm
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/extra/soundsoftware/SoundSoftware.pm	Fri Nov 04 10:28:40 2011 +0000
+++ b/extra/soundsoftware/SoundSoftware.pm	Fri Nov 04 11:02:56 2011 +0000
@@ -245,16 +245,18 @@
 	# fall through
     }
 
+    my $cfg = Apache2::Module::get_config
+        (__PACKAGE__, $r->server, $r->per_dir_config);
     if ($cfg->{SoundSoftwareSslRequired} eq "on") {
 	if ($r->dir_config('HTTPS') eq "on") {
 	    return OK;
 	} else {
 	    my $redir_to = "https://" . $r->hostname() . $r->unparsed_uri();
 	    print STDERR "SoundSoftware.pm:$$: Need to switch to HTTPS, redirecting to $redir_to\n";
-	    $r->header_out(Location => $redir_to);
+	    $r->headers_out->add('Location' => $redir_to);
 	    return REDIRECT;
 	}
-    } else if ($cfg->{SoundSoftwareSslRequired} eq "off") {
+    } elsif ($cfg->{SoundSoftwareSslRequired} eq "off") {
 	return OK;
     } else {
 	print STDERR "WARNING: SoundSoftware.pm:$$: SoundSoftwareSslRequired should be either 'on' or 'off'\n";
@@ -508,6 +510,18 @@
     # to project identifier if any are found
     if ($name =~ m/[^\w\d\s\._-]/) {
 	$name = $project_id;
+    } elsif ($name =~ m/^\s*$/) {
+	# empty or whitespace
+	$name = $project_id;
+    }
+    
+    if ($name =~ m/^\s*$/) {
+        # nothing even in $project_id -- probably a nonexistent project.
+        # use repo name instead (don't want to admit to user that project
+        # doesn't exist)
+        my $location = $r->location;
+        my ($repo) = $r->uri =~ m{$location/*([^/]+)};
+        $name = $repo;
     }
 
     my $realm = '"Mercurial repository for ' . "'$name'" . '"';