Subject: | Infinite loop condition in Text/Shellwords/Cursor.pm parsel() |
This perl command line demonstrates the problem:
$ perl -MData::Dumper -MText::Shellwords::Cursor -e '$p=Text::Shellwords::Cursor->new(); $p->{debug}=9; @t = $p->parse_line("open c:\\u"); print Dumper(\@t); print "\n\n---\n"; @t = $p->parse_line("open foo close c:\\"); print Dumper(\@t);' | head -75
The second call to parse_line() will never return (infinite loop), without output as follows:
-- top, pos=0
Found unquoted string 'open'
pushing 'open'
-- top, pos=4
trimmed 1 whitespace chars,
Found unquoted string 'foo'
pushing 'foo'
-- top, pos=8
trimmed 3 whitespace chars,
Found unquoted string 'close'
pushing 'close'
-- top, pos=16
trimmed 1 whitespace chars,
Found unquoted string 'c:'
pushing 'c:'
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
-- top, pos=19
...
Adding these lines of code after line 311 i Text/Shellwords/Cursor.pm will prevent the infinite loop, but likely is not the entirety of the needed fix:
if(/\G\\/gco) {
$pieces[$#pieces] .= '\\';
}
Thanks