Skip to content

hex2bin, str_pad and strtr accept inputs php rejects (empty pad, empty key, bad hex) #281

Closed

Description

@blacktrs

Three edge cases found while speeding up the string functions in #278; each currently differs from php, and none has a test.

  • hex2bin("abc") / hex2bin("zz"): php warns and returns false; ours silently drops the stray byte or reads a bad digit as 0. Manticore's rule is to throw where php warns.
  • str_pad("a", 5, ""): php 8 throws ValueError: str_pad(): Argument #3 ($pad_string) must be a non-empty string; ours returns the input.
  • strtr("abc", ["" => "x"]): php warns "Ignoring replacement of empty string"; ours skips it silently (consistent with the throw-where-php-warns rule, it should throw or at least match).

Fix each with a case in tests/aot/cases whose expected output is php's (or the exception message where php only warns).

Activity

  1. added
    bug
    on Oct 16, 2026
  2. added a commit that references this issue on Oct 16, 2026
    5e8a5f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions