Skip Menu |

This queue is for tickets about the Term-Completion CPAN distribution.

Report information
The Basics
Id: 121992
Status: new
Priority: 0/
Queue: Term-Completion

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.00
Fixed in: (no value)



Subject: Two trailing spaces followed by a tabulator raises warnings: substr outside of string
If you run the example from Term::Completion::Path POD: $ cat test #!/usr/bin/perl use Term::Completion::Path; my $tc = Term::Completion::Path->new( prompt => "Enter path to your signature file: " ); my $path = $tc->complete(); print "You entered: $path\n"; And you type in a path followed by at least two spaces and the press a tabulator, two warnings are printed: petr@dhcp-0-146:/tmp $ ./test Enter path to your signature file: /root substr outside of string at /usr/share/perl5/vendor_perl/Term/Completion.pm line 207. Use of uninitialized value $test in concatenation (.) or string at /usr/share/perl5/vendor_perl/Term/Completion.pm line 211. You entered: /root Our user claims that following fix is possible: The error is caused when calculating the then length of substring to complete. In this case the length is negative, however it's accepted for completion as value of $add < 1 have boolean value of true. Accepting only positive values of $add fixes dais issue: --- a/lib/Term/Completion.pm 2013-02-23 16:39:15.000000000 +0100 +++ b/lib/Term/Completion.pm 2017-06-02 12:34:12.792097566 +0200 @@ -203,7 +203,7 @@ sub complete } } my $add = $l - $r; - if($add) { + if($add > 0) { $this->{out}->print($test = substr($test, $r, $add)); # reset counter if something was added $tab_pressed = 0;