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