Browse Source

Added workaround for Dancer Issue 909 (splat pollution)

It's not possible to allow arbitrary paramers if `params()` is used,
since in cases of route matching, this hash will always contain
key `splat`.

https://github.com/PerlDancer/Dancer/issues/909

Using `request->params('query')` leads to clean params reflecting query
in URL.
Alois Mahdal 11 years ago
parent
commit
5b9d861947
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      lib/SugarTrail.pm

+ 3
- 2
lib/SugarTrail.pm View File

@@ -17,11 +17,12 @@ my $r = SugarTrail::Repo->new(
17 17
 
18 18
 get qr|^/st/([^\?]*)(.*)$| => sub {
19 19
 
20
-    my $p = params();
20
+    my $params = request->params('query');
21 21
 
22 22
     &helper::dmup (ENV => \%ENV);
23 23
     &helper::dmup (params => scalar params);
24 24
     &helper::dmup (config => config);
25
+    &helper::dmup (real_params => $params);
25 26
 
26 27
     my ($stpath, $query) = splat;
27 28
     my $format = params->{__format} // 'plain';
@@ -31,7 +32,7 @@ get qr|^/st/([^\?]*)(.*)$| => sub {
31 32
 
32 33
     my $m = $r->load_master( source => "/$stpath.stm" )
33 34
         or return template 'not_found';
34
-    my $s = $m->generate_slave(scalar params);
35
+    my $s = $m->generate_slave($params);
35 36
 
36 37
     template 'st', {
37 38
         st_headers =>   $s->head(),