瀏覽代碼

[tests] add test for #10592 (#11975)

* [tests] check current state for #10592

* Not supported on hashlink, and PHP has a bug there

* [tests] run 10592 test for PHP >= 8.2
Rudy Ges 7 月之前
父節點
當前提交
9b37531449
共有 1 個文件被更改,包括 20 次插入1 次删除
  1. 20 1
      tests/unit/src/unitstd/EReg.unit.hx

+ 20 - 1
tests/unit/src/unitstd/EReg.unit.hx

@@ -117,4 +117,23 @@ new EReg("^" + EReg.escape("\\ ^ $ * + ? . ( ) | { } [ ]") + "$", "").match("\\
 // #3430
 ~/(\d+)/g.replace("a1234b12","$1") == "a1234b12";
 ~/(\d+)/g.replace("a1234b12","\\$1") == "a\\1234b\\12";
-~/(\d+)/g.replace("a1234b12","$$1") == "a$1b$1";
+~/(\d+)/g.replace("a1234b12","$$1") == "a$1b$1";
+
+// #10592 - null character
+#if !hl
+#if php
+// There is a bug in php < 8.2, see #10592
+if (php.Global.version_compare(php.Global.phpversion(), "8.2", ">=")) {
+#end
+var containingNull = new EReg("abc\x00def", "");
+f(containingNull.match("abc"));
+t(containingNull.match("abc\x00def"));
+f(containingNull.match("abc\x00fed"));
+var containingNull = ~/abc\x00def/;
+f(containingNull.match("abc"));
+t(containingNull.match("abc\x00def"));
+f(containingNull.match("abc\x00fed"));
+#if php
+}
+#end
+#end