From 4b10c9527f1e9fb480cdcd3a7f6f8864aa1c72b3 Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 16 Jan 2022 16:07:05 -0500 Subject: preventing segfault in url() rel. when supplied with '..' and current path is undef --- gmi.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gmi.pl b/gmi.pl index 85d0df7..5fe0699 100755 --- a/gmi.pl +++ b/gmi.pl @@ -10,7 +10,7 @@ use bytes; use feature qw(refaliasing); no warnings qw(experimental::refaliasing); -our $VERSION = 'v0.0.15'; +our $VERSION = 'v0.0.16'; # TODO: # back() only works once; should fix this @@ -34,7 +34,7 @@ my $doc; my @links; my $current_url = ""; my @history; -my $prompt = "$current_url> "; +my $prompt = ""; my %commands = ( 'url' => [sub { url($_[0],0) }, 'Go to the specified URL.'], @@ -90,7 +90,7 @@ my %commands = ( print "Type 'cmds' to see available commands.\n"; while () { - $prompt = "$current_url> "; + $prompt = "$current_url > "; print "$prompt"; chomp(my $input = ); @@ -164,7 +164,14 @@ sub url { $url->{host} = $c_url->{host}; $url->{port} = $c_url->{port}; - my $cp_url = split_url_path($c_url->{path}, 256); + + my $cp_url; + if ($c_url->{path}) { + $cp_url = split_url_path($c_url->{path}, 256); + } + else { + $cp_url = ['']; + } $c_url->{path} = ''; #if ( $url->{path} =~ m|\.\.| or $url->{path} =~ m|^\./?|) { -- cgit v1.2.3