Skip Menu |

This queue is for tickets about the JSON-RPC CPAN distribution.

Report information
The Basics
Id: 57045
Status: new
Priority: 0/
Queue: JSON-RPC

People
Owner: Nobody in particular
Requestors: e-user [...] fsfe.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.96
Fixed in: (no value)



Subject: Resolution of method names to procedures is irrational
Distribution: JSON-RPC-0.96 Perl: 5.10.1 OS: GNU/Linux (Fedora 13 beta) ATM JSON::RPC::Server::_find_procedure tries to find RPC functions by resolving namespaces to package names 1:1 with the exception of the `system' namespace. This results in either unnecessarily long namespaces also revealing security-sensitive information (package names) or forces users to create packages outside of project scope which is also undesirable. It would both be consistent and convenient to resolve namespaces like being done for `system' right now, e.g. RPC'alling `Foo.getBar' dispatched to `Baz::Bop' should result in a call to `getBar' in the package `Baz::Bop::Foo'. The attached patch targets this issue. Best regards
Subject: perl-JSON-RPC-0.96-sane-namespaces.patch
diff -up JSON-RPC-0.96/lib/JSON/RPC/Server.pm.sane-namespaces JSON-RPC-0.96/lib/JSON/RPC/Server.pm --- JSON-RPC-0.96/lib/JSON/RPC/Server.pm.sane-namespaces 2010-04-29 18:33:05.000000000 +0200 +++ JSON-RPC-0.96/lib/JSON/RPC/Server.pm 2010-04-29 18:48:41.000000000 +0200 @@ -248,42 +248,28 @@ sub _handle { sub _find_procedure { my ($self, $method) = @_; - my $found; - my $classname; - my $system_call; - - if ($method =~ /^system\.(\w+)$/) { - $system_call = 1; - $method = $1; - } - elsif ($method =~ /\./) { - my @p = split/\./, $method; - $method = pop @p; - $classname= join('::', @p); - } + + my $system_call = $method =~ /^system\.\w+$/; + my @namespace = split /\./, $method; + $method = pop @namespace; if ($self->{dispatch_path}) { my $path = $self->{path_info}; if (my $pkg = $self->{dispatch_path}->{$path}) { - - return if ( $classname and $pkg ne $classname ); return if ( $JSONRPC_Procedure_Able and JSON::RPC::Procedure->can( $method ) ); + $pkg .= sprintf '::%s', join('::', @namespace) if @namespace; $self->_load_module($pkg); - - if ($system_call) { $pkg .= '::system' } - return $self->_method_is_ebable($pkg, $method, $system_call); } } else { for my $pkg (@{$self->{loaded_module}->{order}}) { - next if ( $classname and $pkg ne $classname ); next if ( $JSONRPC_Procedure_Able and JSON::RPC::Procedure->can( $method ) ); - if ($system_call) { $pkg .= '::system' } + $pkg .= sprintf '::%s', join('::', @namespace) if @namespace; if ( my $ret = $self->_method_is_ebable($pkg, $method, $system_call) ) { return $ret;