Skip to content

[FREQ] decoding integer values doesn't allow for integer prefixes such as "0x" #29

@Azhrei

Description

@Azhrei

The IniReader checks whether an integer will overflow by using:

return (string) ($value + 0) === $value;

However, that will not work when the value has leading zeroes or a leading plus sign or any other characters that would be silently ignored by PHP.

In addition, the decode() method converts from string to int by simply adding zero to the string. This is effectively equivalent to using an (int) cast, which doesn't account for a leading radix indicator, such as 0t, 0x, 0b, and 0o (or just a leading 0).

Lastly, the methods that accomplish the above are all private which makes them impossible to override in PHP. I had to modify the private methods to be protected, so that a derived class could fix this deficiency.

I'm happy to package up my changes as a PR, if you wish.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions