diff options
author | jake <jake@jakes-mail.top> | 2022-01-16 16:07:05 -0500 |
---|---|---|
committer | jake <jake@jakes-mail.top> | 2022-01-16 16:07:05 -0500 |
commit | 4b10c9527f1e9fb480cdcd3a7f6f8864aa1c72b3 (patch) | |
tree | e891ec85f434bb1a1b118bc5ea73249c740a0f45 | |
parent | 46bce6221717dc0762539d50e9ab1c6b41b72876 (diff) |
preventing segfault in url() rel. when supplied with '..' and current path is undef
-rwxr-xr-x | gmi.pl | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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 = <STDIN>); @@ -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|^\./?|) { |