From ef711ce845ce488a42c0f8fd68e18998fb05cddf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 1 Nov 2016 11:00:30 +0100 Subject: [PATCH] Handle Referer not having a trailing slash Fixes #415. --- src/lib/Hydra/Controller/Root.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 0a1a2d10..8de67d1b 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -66,6 +66,8 @@ sub begin :Private { my $referer = $c->req->header('Origin'); $referer //= $c->req->header('Referer'); my $base = $c->req->base; + die unless $base =~ /\/$/; + $referer .= "/"; error($c, "POST requests should come from ‘$base’.") unless defined $referer && substr($referer, 0, length $base) eq $base; }