Skip to content

Commit

Permalink
Fix GH-10647: Spoofchecker isSuspicious/areConfusable methods
Browse files Browse the repository at this point in the history
error code's argument.

Closes GH-10653.
  • Loading branch information
NathanFreeman authored and devnexen committed Feb 21, 2023
1 parent da3ce60 commit 0a466e7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -31,6 +31,10 @@ PHP NEWS
. Fixed bug GH-10315 (FPM unknown child alert not valid). (Jakub Zelenka)
. Fixed bug GH-10385 (FPM successful config test early exit). (nielsdos)

- Intl:
. Fixed bug GH-10647 (Spoolchecker isSuspicious/areConfusable methods
error code's argument always returning NULL0. (Nathan Freeman)

- JSON:
. Fixed JSON scanner and parser generation build.
(Daniel Black, Jakub Zelenka)
Expand Down
6 changes: 4 additions & 2 deletions ext/intl/spoofchecker/spoofchecker_main.c
Expand Up @@ -43,7 +43,8 @@ PHP_METHOD(Spoofchecker, isSuspicious)

if (error_code) {
zval_ptr_dtor(error_code);
ZVAL_LONG(error_code, ret);
ZVAL_LONG(Z_REFVAL_P(error_code), ret);
Z_TRY_ADDREF_P(error_code);
}
RETVAL_BOOL(ret != 0);
}
Expand Down Expand Up @@ -76,7 +77,8 @@ PHP_METHOD(Spoofchecker, areConfusable)

if (error_code) {
zval_ptr_dtor(error_code);
ZVAL_LONG(error_code, ret);
ZVAL_LONG(Z_REFVAL_P(error_code), ret);
Z_TRY_ADDREF_P(error_code);
}
RETVAL_BOOL(ret != 0);
}
Expand Down
24 changes: 24 additions & 0 deletions ext/intl/tests/gh10647.phpt
@@ -0,0 +1,24 @@
--TEST--
Bug GH-10647 (Spoofchecker::isSuspicious $errorCode always null)
--SKIPIF--
<?php
if (!extension_loaded("intl")) die("skip intl extension not available");
?>
--FILE--
<?php
$error = 123;
var_dump($error);

$x = new Spoofchecker();
var_dump($x->isSuspicious("\u{041F}aypal.com", $error));
var_dump($error);

var_dump($x->areConfusable('google.com', 'goog1e.com', $error));
var_dump($error);
?>
--EXPECTF--
int(123)
bool(true)
int(%d)
bool(true)
int(%d)

0 comments on commit 0a466e7

Please sign in to comment.