mirror of
https://github.com/php/php-src.git
synced 2025-08-21 01:45:16 +02:00
Hook into new unicode conversion error handling API
This commit is contained in:
parent
880dd406f2
commit
0260dfc9b1
2 changed files with 14 additions and 4 deletions
|
@ -706,9 +706,14 @@ PHPAPI int _php_stream_bucket_convert(php_stream_bucket *bucket, unsigned char t
|
||||||
} else {
|
} else {
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
char *dest;
|
char *dest;
|
||||||
int destlen;
|
int destlen, num_conv;
|
||||||
|
|
||||||
zend_convert_from_unicode(conv, &dest, &destlen, bucket->buf.u, bucket->buflen, &status);
|
num_conv = zend_convert_from_unicode(conv, &dest, &destlen, bucket->buf.u, bucket->buflen, &status);
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
|
int32_t offset = u_countChar32(bucket->buf.u, num_conv)-1;
|
||||||
|
|
||||||
|
zend_raise_conversion_error_ex("Could not convert Unicode string to binary string", conv, offset, (UG(from_u_error_mode) & ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC);
|
||||||
|
}
|
||||||
|
|
||||||
if (bucket->own_buf) {
|
if (bucket->own_buf) {
|
||||||
pefree(bucket->buf.u, bucket->is_persistent);
|
pefree(bucket->buf.u, bucket->is_persistent);
|
||||||
|
|
|
@ -1256,10 +1256,15 @@ static size_t _php_stream_write_buffer(php_stream *stream, int buf_type, zstr bu
|
||||||
|
|
||||||
if (stream->output_encoding && buf_type == IS_UNICODE) {
|
if (stream->output_encoding && buf_type == IS_UNICODE) {
|
||||||
char *dest;
|
char *dest;
|
||||||
int destlen;
|
int destlen, num_conv;
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
|
|
||||||
zend_convert_from_unicode(stream->output_encoding, &dest, &destlen, buf.u, buflen, &status);
|
num_conv = zend_convert_from_unicode(stream->output_encoding, &dest, &destlen, buf.u, buflen, &status);
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
|
int32_t offset = u_countChar32(buf.u, num_conv)-1;
|
||||||
|
|
||||||
|
zend_raise_conversion_error_ex("Could not convert Unicode string to binary string", stream->output_encoding, offset, (UG(from_u_error_mode) & ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC);
|
||||||
|
}
|
||||||
freeme = buf.s = dest;
|
freeme = buf.s = dest;
|
||||||
buflen = destlen;
|
buflen = destlen;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue