From: Robert 'phaylon' Sedlacek Date: Wed, 20 Jun 2012 02:35:16 +0000 (+0000) Subject: double encode keys in address bar to make sur we don't conflict on file path keys X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FJSON-Tree-Viewer.git;a=commitdiff_plain;h=fd9adeae13d57af6de3e13a941b040d7acaf84f4 double encode keys in address bar to make sur we don't conflict on file path keys --- diff --git a/br.pl b/br.pl index 8f29ef2..5adc85d 100644 --- a/br.pl +++ b/br.pl @@ -5,6 +5,7 @@ use Module::Runtime qw(use_module); use Scalar::Util qw(blessed); use IO::All; use JSON; +use URI::Escape; has root => (is => 'lazy'); @@ -154,7 +155,7 @@ sub mangle_structure { sub link_to { my ($self, @to) = @_; use HTML::Tags; - s/\//\./g for my @link = @to; + my @link = map uri_escape(uri_escape($_)), @to; my $link = join('/', @link, ''); my $to = $to[-1]; my $html = join '', HTML::Tags::to_html_string( @@ -170,8 +171,8 @@ sub descend { $target = $self->json->decode(scalar $target->all); } return $target unless @path; - (my $undot = my $step = shift @path) =~ s/\./\//g; - $self->descend($target->{$step}||$target->{$undot}, @path); + my $step = uri_unescape(uri_unescape( shift @path)); + $self->descend($target->{$step}, @path); } sub render_table {