Skip to content

zero in int type #2

@interlab

Description

@interlab

https://github.com/rchouinard/bencode/blob/master/src/Decoder.php#L160

i-05e != -5
i05e != 5

Leading zeros are not allowed (although the number zero is still represented as "0").

  1. add after 140 line:
        if ('-' == $this->_getChar($currentOffset) && '0' == $this->_getChar($currentOffset + 1)) {
            throw new RuntimeException('Illegal zero-padding found in integer entity at offset ' . $this->_offset);
        }
  1. find:
        $absoluteValue = (string) abs($value);
        if (1 < strlen($absoluteValue) && "0" == $value[0]) {

replace:

        // $absoluteValue = (string) abs($value);
        if (1 < strlen($value) && '0' == $value[0]) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions