瀏覽代碼

[php] fixed EReg.split when called with malformed utf8 input (#10056)

* [php] fixed ERreg.split when called with malformed utf8 input

* updated testcase to use getString

* changed unittest to only run test on PHP target

* removed PHP specific test case
AlexHaxe 4 年之前
父節點
當前提交
aca1d209dc
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      std/php/_std/EReg.hx

+ 3 - 3
std/php/_std/EReg.hx

@@ -125,12 +125,12 @@ import php.*;
 	}
 
 	public function split(s:String):Array<String> {
-		var parts:NativeArray = Global.preg_split(reUnicode, s, (global ? -1 : 2));
-		if (parts == null) {
+		var parts:EitherType<Bool, NativeArray> = Global.preg_split(reUnicode, s, (global ? -1 : 2));
+		if (parts == false) {
 			handlePregError();
 			parts = Global.preg_split(re, s, (global ? -1 : 2));
 		}
-		return @:privateAccess Array.wrap(parts);
+		return @:privateAccess Array.wrap(cast parts);
 	}
 
 	public function replace(s:String, by:String):String {