Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/IO/Stty.pm
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,10 @@ sub _parse_char_value {
return hex($1);
}

# Octal: 0 followed by digits (but not plain "0" which is decimal zero)
if ( $val =~ /^0(\d+)$/ ) {
# Octal: 0 followed by octal digits (0-7). We deliberately exclude
# 8 and 9 so that inputs like "08" or "09" fall through to the decimal
# path instead of being silently truncated by oct().
if ( $val =~ /^0([0-7]+)$/ ) {
return oct($1);
}

Expand Down
5 changes: 5 additions & 0 deletions t/01-parse-char-value.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ my @tests = (
[ '017', 15, 'octal 017' ],
[ '0177', 127, 'octal 0177' ],

# Digits 8/9 after leading zero: NOT octal, treated as decimal
[ '08', 8, '08 is decimal 8, not invalid octal' ],
[ '09', 9, '09 is decimal 9, not invalid octal' ],
[ '019', 19, '019 is decimal 19 (contains non-octal digit)' ],

# undef / ^- (returns _POSIX_VDISABLE, which is 0 on Linux, 255 on macOS)
[ 'undef', $VDISABLE, 'undef disables character (returns _POSIX_VDISABLE)' ],
[ '^-', $VDISABLE, '^- disables character (returns _POSIX_VDISABLE)' ],
Expand Down
Loading