Skip to content

ZendStr should accept strings containing null bytes. #200

@ju1ius

Description

@ju1ius

Hi,

PHP strings are allowed to contain null bytes, but the current implementation of ZendStr doesn't allow it.

#[php_function]
pub fn class_name_of(obj: &ZendObject) -> String {
    obj.get_class_name().unwrap()
}
<?php

var_dump(class_name_of(new class {}));

Expected result:

string(%d) "class@anonymous/path/to/file.php:3$0"
// or, with XDebug enabled:
string(%d) "class@anonymous\000/path/to/file.php:3$0"

Actual result:

PHP Fatal error: Uncaught Exception: String given contains NUL-bytes which cannot be present in a C string. [...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions