Project

General

Profile

Actions

Feature #5219

closed

Array#pack should warn (or raise) if an invalid pack string is given

Added by drbrain (Eric Hodel) over 12 years ago. Updated almost 12 years ago.

Status:
Closed
Target version:
[ruby-core:39067]

Description

If garbage characters are inserted into the pack string ruby ignores them:

$ ruby19 -e 'p [1, 2, 3].pack("*N")'
"\x00\x00\x00\x01"

$ ruby19 -e 'p [1, 2, 3].pack("yN")'
"\x00\x00\x00\x01"

Ruby should at least warn like printf when -w is active:

$ ruby19 -we 'printf "%d %d", 1, 2, 3'
-e:1: warning: too many arguments for format string

A future version could raise an exception.

See also: https://github.com/rubinius/rubinius/issues/1127


Files

pack.c.warn_on_unknown_directive.patch (1.51 KB) pack.c.warn_on_unknown_directive.patch drbrain (Eric Hodel), 03/27/2012 09:09 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0