From 596a5b858942f15d3009a960afea61e9e2cea013 Mon Sep 17 00:00:00 2001 From: Nigel Kukard <nkukard@lbsd.net> Date: Sun, 30 Jun 2013 21:02:02 +0000 Subject: [PATCH] Fixed issues with the URI being passed with query --- opentrafficshaper/plugins/webserver/webserver.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/opentrafficshaper/plugins/webserver/webserver.pm b/opentrafficshaper/plugins/webserver/webserver.pm index 48be7b0..834b6be 100644 --- a/opentrafficshaper/plugins/webserver/webserver.pm +++ b/opentrafficshaper/plugins/webserver/webserver.pm @@ -25,6 +25,7 @@ use HTML::Entities; use HTTP::Response; use HTTP::Status qw(:constants :is status_message); use POE qw(Component::Server::TCP Filter::HTTPD); +use URI; use opentrafficshaper::logger; @@ -70,6 +71,7 @@ my $pages = { }, 'users' => { 'default' => \&opentrafficshaper::plugins::webserver::pages::users::default, + 'add' => \&opentrafficshaper::plugins::webserver::pages::users::add, }, }; @@ -114,8 +116,11 @@ sub handle_request goto END; } + # We need to parse the URI nicely + my $requestURI = URI->new($request->uri); + # Split off the URL into a module and action - my (undef,$dmodule,$daction,@dparams) = split(/\//,$request->uri); + my (undef,$dmodule,$daction,@dparams) = split(/\//,$requestURI->path); # If any is blank, set it to the default $dmodule = "index" if (!defined($dmodule)); $daction = "default" if (!defined($daction)); @@ -231,7 +236,7 @@ EOF # <li><a href="#">Link</a></li> # Loop with menu items foreach my $item (keys %{$menu->{$section}}) { - my $link = $module . "/" . $menu->{$section}->{$item}; + my $link = "/" . $module . "/" . $menu->{$section}->{$item}; # Sanitize slightly $link =~ s,/+$,,; -- GitLab