summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjake <jake@jakes-mail.top>2022-01-16 16:07:05 -0500
committerjake <jake@jakes-mail.top>2022-01-16 16:07:05 -0500
commit4b10c9527f1e9fb480cdcd3a7f6f8864aa1c72b3 (patch)
treee891ec85f434bb1a1b118bc5ea73249c740a0f45
parent46bce6221717dc0762539d50e9ab1c6b41b72876 (diff)
preventing segfault in url() rel. when supplied with '..' and current path is undef
-rwxr-xr-xgmi.pl15
1 files 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 = <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|^\./?|) {