From 20805809f42d8fa152aca46d0b737e90b308092a Mon Sep 17 00:00:00 2001 From: Yorhel Date: Tue, 21 Oct 2014 09:53:53 +0200 Subject: Use TUWF's reqBaseURI() instead of $self->{uri} on site links TUWF properly detects HTTPS and includes this in the returned URL, so this change ensures that all URLs adopt properly to HTTP and HTTPS. --- data/global.pl | 2 +- lib/VNDB/Handler/Misc.pm | 12 +++++++----- lib/VNDB/Handler/ULists.pm | 3 ++- lib/VNDB/Handler/Users.pm | 7 ++++--- lib/VNDB/Util/LayoutHTML.pm | 2 +- lib/VNDB/Util/Misc.pm | 3 ++- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/data/global.pl b/data/global.pl index 48dfd487..cf9a9fd4 100644 --- a/data/global.pl +++ b/data/global.pl @@ -20,7 +20,7 @@ our %O = ( # VNDB-specific options (object_data) our %S = (%S, version => `cd $VNDB::ROOT; git describe` =~ /^(.+)$/ && $1, - url => 'http://vndb.org', + url => 'http://vndb.org', # Only used by Multi, web pages infer their own address url_static => 'http://s.vndb.org', skin_default => 'angel', global_salt => 'any-private-string-here', diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index d801c667..357779bc 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -350,7 +350,8 @@ sub setlang { my $browser = VNDB::L10N->get_handle()->language_tag(); - (my $ref = $self->reqHeader('Referer')||'/') =~ s/^\Q$self->{url}//; + my $b = $self->reqBaseURI(); + (my $ref = $self->reqHeader('Referer')||'/') =~ s/^\Q$b//; $self->resRedirect($ref, 'post'); if($lang ne $self->{l10n}->language_tag()) { $self->authInfo->{id} @@ -396,6 +397,7 @@ sub prefs { sub opensearch { my $self = shift; + my $h = $self->reqBaseURI(); $self->resHeader('Content-Type' => 'application/opensearchdescription+xml'); xml; tag 'OpenSearchDescription', @@ -403,12 +405,12 @@ sub opensearch { tag 'ShortName', 'VNDB'; tag 'LongName', 'VNDB.org visual novel search'; tag 'Description', 'Search visual vovels on VNDB.org'; - tag 'Image', width => 16, height => 16, type => 'image/x-icon', $self->{url}.'/favicon.ico' + tag 'Image', width => 16, height => 16, type => 'image/x-icon', "$h/favicon.ico" if -s "$VNDB::ROOT/www/favicon.ico"; - tag 'Url', type => 'text/html', method => 'get', template => $self->{url}.'/v/all?q={searchTerms}', undef; - tag 'Url', type => 'application/opensearchdescription+xml', rel => 'self', template => $self->{url}.'/opensearch.xml', undef; + tag 'Url', type => 'text/html', method => 'get', template => "$h/v/all?q={searchTerms}", undef; + tag 'Url', type => 'application/opensearchdescription+xml', rel => 'self', template => "$h/opensearch.xml", undef; tag 'Query', role => 'example', searchTerms => 'Tsukihime', undef; - tag 'moz:SearchForm', $self->{url}.'/v/all'; + tag 'moz:SearchForm', "$h/v/all"; end 'OpenSearchDescription'; } diff --git a/lib/VNDB/Handler/ULists.pm b/lib/VNDB/Handler/ULists.pm index cdc30d01..bab30be6 100644 --- a/lib/VNDB/Handler/ULists.pm +++ b/lib/VNDB/Handler/ULists.pm @@ -101,7 +101,8 @@ sub rlist_e { $self->dbRListAdd($uid, $rid, $f->{e}) if $f->{e} >= 0; if($id) { - (my $ref = $self->reqHeader('Referer')||"/r$id") =~ s/^\Q$self->{url}//; + my $b = $self->reqBaseURI(); + (my $ref = $self->reqHeader('Referer')||"/r$id") =~ s/^\Q$b//; $self->resRedirect($ref, 'temp'); } else { # doesn't really matter what we return, as long as it's XML diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm index 804b9467..09be3d34 100644 --- a/lib/VNDB/Handler/Users.pm +++ b/lib/VNDB/Handler/Users.pm @@ -162,7 +162,8 @@ sub login { { post => 'usrpass', required => 1, minlength => 4, maxlength => 64, template => 'asciiprint' }, ); - (my $ref = $self->reqHeader('Referer')||'/') =~ s/^\Q$self->{url}//; + my $b = $self->reqBaseURI(); + (my $ref = $self->reqHeader('Referer')||'/') =~ s/^\Q$b//; $ref = '/' if $ref =~ /^\/u\//; if(!$frm->{_err}) { return if $self->authLogin($frm->{usrname}, $frm->{usrpass}, $ref); @@ -210,7 +211,7 @@ sub newpass { my $token; ($token, $o{passwd}) = $self->authPrepareReset(); $self->dbUserEdit($u->{id}, %o); - $self->mail(mt('_newpass_mail_body', $u->{username}, "$self->{url}/u$u->{id}/setpass?t=$token"), + $self->mail(mt('_newpass_mail_body', $u->{username}, $self->reqBaseURI()."/u$u->{id}/setpass?t=$token"), To => $frm->{mail}, From => 'VNDB ', Subject => mt('_newpass_mail_subject', $u->{username}), @@ -309,7 +310,7 @@ sub register { if(!$frm->{_err}) { my($token, $pass) = $self->authPrepareReset(); my $uid = $self->dbUserAdd($frm->{usrname}, $pass, $frm->{mail}); - $self->mail(mt('_register_mail_body', $frm->{usrname}, "$self->{url}/u$uid/setpass?t=$token"), + $self->mail(mt('_register_mail_body', $frm->{usrname}, $self->reqBaseURI()."/u$uid/setpass?t=$token"), To => $frm->{mail}, From => 'VNDB ', Subject => mt('_register_mail_subject', $frm->{usrname}), diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm index 07058b4f..fc7ec8ad 100644 --- a/lib/VNDB/Util/LayoutHTML.pm +++ b/lib/VNDB/Util/LayoutHTML.pm @@ -25,7 +25,7 @@ sub htmlHeader { # %options->{ title, noindex, search, feeds, svg } title $o{title}; Link rel => 'shortcut icon', href => '/favicon.ico', type => 'image/x-icon'; Link rel => 'stylesheet', href => $self->{url_static}.'/s/'.$skin.'/style.css?'.$self->{version}, type => 'text/css', media => 'all'; - Link rel => 'search', type => 'application/opensearchdescription+xml', title => 'VNDB VN Search', href => $self->{url}.'/opensearch.xml'; + Link rel => 'search', type => 'application/opensearchdescription+xml', title => 'VNDB VN Search', href => $self->reqBaseURI().'/opensearch.xml'; if($self->authPref('customcss')) { (my $css = $self->authPref('customcss')) =~ s/\n/ /g; style type => 'text/css', $css; diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm index b7503c24..48bc226d 100644 --- a/lib/VNDB/Util/Misc.pm +++ b/lib/VNDB/Util/Misc.pm @@ -105,7 +105,8 @@ sub ieCheck { $self->reqHeader('User-Agent') !~ /MSIE [67]/ || $self->reqCookie('ie_sucks'); if($self->reqGet('i-still-want-access')) { - (my $ref = $self->reqHeader('Referer') || '/') =~ s/^\Q$self->{url}//; + my $b = $self->reqBaseURI(); + (my $ref = $self->reqHeader('Referer') || '/') =~ s/^\Q$b//; $self->resRedirect($ref, 'temp'); $self->resCookie('ie_sucks' => 1); return; -- cgit v1.2.3