Skip to content

Commit

Permalink
Fix phpGH-17469: UConverter::transcode() not hardcoding error handling.
Browse files Browse the repository at this point in the history
Respecting instead intl.use_exceptions/intl.error_level.
  • Loading branch information
devnexen committed Jan 16, 2025
1 parent a6a290d commit ae3af5a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ext/intl/converter/converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,25 +376,31 @@ static bool php_converter_set_encoding(php_converter_object *objval,
/* Should never happen */
actual_encoding = "(unknown)";
}
php_error_docref(NULL, E_WARNING, "Ambiguous encoding specified, using %s", actual_encoding);
char *msg;
spprintf(&msg, 0, "Ambigious encoding specified, using %s", actual_encoding);
intl_error_set(NULL, error, msg, 1);
efree(msg);
} else if (U_FAILURE(error)) {
if (objval) {
THROW_UFAILURE(objval, "ucnv_open", error);
} else {
php_error_docref(NULL, E_WARNING, "Error setting encoding: %d - %s", (int)error, u_errorName(error));
char *msg;
spprintf(&msg, 0, "Error setting encoding: %d - %s", (int)error, u_errorName(error));
intl_error_set(NULL, error, msg, 1);
efree(msg);
}
return 0;
return false;
}

if (objval && !php_converter_set_callbacks(objval, cnv)) {
return 0;
return false;
}

if (*pcnv) {
ucnv_close(*pcnv);
}
*pcnv = cnv;
return 1;
return true;
}
/* }}} */

Expand Down

0 comments on commit ae3af5a

Please sign in to comment.