Skip to content

Null character breaks regex patterns #10592

@tobil4sk

Description

@tobil4sk

When a regex pattern created directly using the constructor that contains a null character, it does not match properly on Eval, Neko, C++, lua, and Hashlink. PHP throws an error on the first match call due of the null character (Null byte in regex).

final containingNull = new EReg("abc\x00def", "");

trace(containingNull.match("abc")); // true, should be false
trace(containingNull.match("abc\x00def")); // true
trace(containingNull.match("abc\x00fed")); // true, should be false

On all other targets it works as expected.

On the other hand, the following works fine on (almost) all targets, where we use the regex literal syntax.

final containingNull = ~/abc\x00def/;

trace(containingNull.match("abc")); // false
trace(containingNull.match("abc\x00def")); // true (apart from on hashlink)
trace(containingNull.match("abc\x00fed")); // false

Targets affected:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions